Numerical partial derivative of a composite function

numerical-calculuspartial derivative

I have found the two similar questions:

  1. Numerical derivative of composite function

  2. Partial derivative of composite function

but don't know how to combine them properly.

I have

$x=[x_1,x_2]^T$

and

$F(x) = g(f_1(x), f_2(x)) = g(f_1(x_1,x_2), f_2(x_1, x_2))$

The goal is to compute $\frac{\partial F}{\partial x_1}$

My assumption is: $ \frac{\partial F}{\partial x_1} =\frac{F(x_1+h)-F(x_1-h)}{2h}=\frac{g(f_1(x_1+h,x_2),f_2(x_1+h,x_2))-g(f_1(x_1-h,x_2),f_2(x_1-h,x_2))}{2h}$, given the fact that $x_2$ is constant while $F$ is being differentiated by $x_1$.

Is this formula correct?

Best Answer

Your formular is correct, you are using central finite differences applied to $F(x)$.

(There are many other possibilities to approximation the derivatives as well. It always depends on the application what is needed and what is useful.

In some applications, when the derivatives of $f$ and $g$ are known functions, it is useful to employ $$ \frac{d F}{d x_1} = \frac{\partial g}{ \partial y_1} \frac{\partial f_1}{ \partial x_1} + \frac{\partial g}{ \partial y_2} \frac{\partial f_2}{ \partial x_1} $$ Here I use the notation $g(y_1,y_2)$. Using this chain rule iteratively allows to get exact derivatives in the computer and it is called automatic differentiation.)

Related Question