TensorTonicTensorTonic
Problems
Study PlansProjectsInterviewPricingFeedback
Study Plan
Measure Scalar Expression Partials
Calculus
Easy

Estimate the partial derivatives of the scalar expression

d(a,b,c)=ab+c.d(a,b,c)=ab+c.d(a,b,c)=ab+c.

Here aaa, bbb, and ccc are scalar inputs and ddd is the expression value. Use the supplied positive step hhh and forward differences, such as

∂d∂a≈d(a+h,b,c)−d(a,b,c)h.\frac{\partial d}{\partial a}\approx\frac{d(a+h,b,c)-d(a,b,c)}{h}.∂a∂d​≈hd(a+h,b,c)−d(a,b,c)​.

The partial-derivative symbol measures sensitivity to one input with the others fixed. Apply the same definition to b and c. Return a four-item tuple of Python floats: the original expression value, then its numerical partial derivatives for a, b, and c.

Loading visualization...

Examples

Input: a=2.0, b=-3.0, c=10.0, h=0.001

Output: (4.0,-3.0,2.0,1.0)

Explanation: Changing one variable at a time recovers the local sensitivities of ab+c.

Input: a=0.0, b=0.0, c=0.0, h=0.01

Output: (0.0,0.0,0.0,1.0)

Input: a=0.5, b=1.25, c=-2.0, h=0.0001

Output: (-1.375,1.25,0.5,1.0)

Hint 1

enumerate can track which input receives a perturbation.

Hint 2

list.copy keeps each perturbed input list separate from the original.

Requirements

  • Use 64-bit floating-point arithmetic; NumPy is available.
  • Return forward-difference estimates using the supplied h, not analytic derivatives.
  • Keep the partials in a, b, c order.

Constraints

  • a, b, and c are finite numbers.
  • h is a finite positive number.
  • All expression values and returned partial derivatives must be finite.
Try Similar Problems
Finite Difference Derivative in Python: Autograd Step 1EasyCheck a Product-Chain GradientMediumApply Local Vector-Jacobian RulesEasyCreate a Multiplication Value NodeEasyCreate an Addition Value NodeEasyBackpropagate Through a Scalar NeuronMediumTopologically Sort a Computation DAGMediumAccumulate Shared-Path GradientsMediumSecond-Order Partial DerivativesEasyBasic AutogradEasyDerivatives of Common Activation FunctionsEasyJacobian of a Vector-Valued PolynomialEasy

Accepts: number

Accepts: number

Accepts: number

Accepts: number

You must run your code first.

Measure Scalar Expression Partials

Calculus
Easy

Estimate the partial derivatives of the scalar expression

d(a,b,c)=ab+c.d(a,b,c)=ab+c.d(a,b,c)=ab+c.

Here aaa, bbb, and ccc are scalar inputs and ddd is the expression value. Use the supplied positive step hhh and forward differences, such as

∂d∂a≈d(a+h,b,c)−d(a,b,c)h.\frac{\partial d}{\partial a}\approx\frac{d(a+h,b,c)-d(a,b,c)}{h}.∂a∂d​≈hd(a+h,b,c)−d(a,b,c)​.

The partial-derivative symbol measures sensitivity to one input with the others fixed. Apply the same definition to b and c. Return a four-item tuple of Python floats: the original expression value, then its numerical partial derivatives for a, b, and c.

Loading visualization...

Examples

Input: a=2.0, b=-3.0, c=10.0, h=0.001

Output: (4.0,-3.0,2.0,1.0)

Explanation: Changing one variable at a time recovers the local sensitivities of ab+c.

Input: a=0.0, b=0.0, c=0.0, h=0.01

Output: (0.0,0.0,0.0,1.0)

Input: a=0.5, b=1.25, c=-2.0, h=0.0001

Output: (-1.375,1.25,0.5,1.0)

Hint 1

enumerate can track which input receives a perturbation.

Hint 2

list.copy keeps each perturbed input list separate from the original.

Requirements

  • Use 64-bit floating-point arithmetic; NumPy is available.
  • Return forward-difference estimates using the supplied h, not analytic derivatives.
  • Keep the partials in a, b, c order.

Constraints

  • a, b, and c are finite numbers.
  • h is a finite positive number.
  • All expression values and returned partial derivatives must be finite.
Try Similar Problems
Finite Difference Derivative in Python: Autograd Step 1EasyCheck a Product-Chain GradientMediumApply Local Vector-Jacobian RulesEasyCreate a Multiplication Value NodeEasyCreate an Addition Value NodeEasyBackpropagate Through a Scalar NeuronMediumTopologically Sort a Computation DAGMediumAccumulate Shared-Path GradientsMediumSecond-Order Partial DerivativesEasyBasic AutogradEasyDerivatives of Common Activation FunctionsEasyJacobian of a Vector-Valued PolynomialEasy

Accepts: number

Accepts: number

Accepts: number

Accepts: number

You must run your code first.