# Numerical partial derivative of a composite function

I have found the two similar questions:

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?

• $∂F/∂𝑥_1$ = $∂g/∂f*∂f/∂𝑥_1$ – Äres Dec 24 '19 at 12:14
• Sure but i need numerical solution while you provide analytical. – Elia Dec 24 '19 at 12:24

Your formular is correct, you are using central finite differences applied to $$F(x)$$.
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.)