Estimate the partial derivatives of the scalar expression
d(a,b,c)=ab+c.Here a, b, and c are scalar inputs and d is the expression value. Use the supplied positive step h and forward differences, such as
∂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.
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)
enumerate can track which input receives a perturbation.
list.copy keeps each perturbed input list separate from the original.
Accepts: number
Accepts: number
Accepts: number
Accepts: number
Estimate the partial derivatives of the scalar expression
d(a,b,c)=ab+c.Here a, b, and c are scalar inputs and d is the expression value. Use the supplied positive step h and forward differences, such as
∂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.
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)
enumerate can track which input receives a perturbation.
list.copy keeps each perturbed input list separate from the original.
Accepts: number
Accepts: number
Accepts: number
Accepts: number