# Second derivative of function of two variables

I'm having problemes using the chain rule in the 2-variables case. I know that the first derivative of a function $f=f\left(t,u(t)\right)$ is

$$\frac{df}{dt}=\frac{df}{dt}+\frac{df}{du}\frac{du}{dt}$$

Then, if I apply the chain rule in this expression I get:

$$\frac{d^2f}{d^2t}=\left[\frac{df}{dtdu}\frac{du}{dt}+\frac{d^2f}{d^2t}\right]+\left[\frac{d^2u}{d^2t}\frac{df}{du}+\frac{du}{dt}\left(\frac{d^2f}{d^2u}\frac{du}{dt}+\frac{df}{dudt}\right)\right]$$

where the first group comes from derivating the first term of $\frac{df}{dt}$ and the second group from derivating the second one.

However, shouldn't this derivative look like the following?

$$\frac{d^2f}{d^2t}=\frac{d^2f}{d^2t}+2\frac{du}{dt}\frac{df}{dudt}+\frac{d^2f}{d^2u}\left(\frac{du}{dt}\right)^2$$

I'd appreciate if someone could explain me a little bit what I am doing wrong.

-

I always get lost with higher-order chain rules. My antidote is Taylor expansions. For convenience, let's work at the origin $(0,0)$. Write $$f(t,u)=f_1 t + f_2 u+\frac{f_{11}}{2}t^2+\frac{f_{22}}{2}u^2+f_{12}t u + \dots$$ and plug $$u=u_1 t + \frac{u_2}{2}t^2 + \dots$$ to get \begin{align}f(t,u(t)) & = f_1 t + f_2 \left(u_1 t + \frac{u_2}{2}t^2\right)+\frac{f_{11}}{2}t^2+\frac{f_{22}}{2}(u_1 t)^2+f_{12}t (u_1 t) + \dots \\ &= (f_1 t + f_2 u_1 ) t + \frac{1}{2}(f_2u_2+ f_{11} + f_{22}u_1^2 + 2f_{12}u_1)\, t^2 + \dots \end{align} The coefficient of $t$ gives the familiar first-order chain rule. The coefficient of $t^2$ tells us that that the second derivative of the composition is $$\frac{\partial f}{\partial u}u'' + \frac{\partial^2 f}{\partial t^2} + \frac{\partial^2 f}{\partial u^2}(u')^2 + 2\frac{\partial^2 f}{\partial t\partial u}u'$$ This agrees with your first formula. Your second formula would be also correct if it included the term $\frac{\partial f}{\partial u}u''$.