Double derivative of $f\circ c$ using chain rule 
Let $f:\mathbb{R}^2\to\mathbb{R}$ be a $C^2$ function and let $c(t)$ be a $C^2$ curve in $\mathbb{R}^2$.
Write a formula for the second derivative $\frac{\mathrm{d}^2}{\mathrm{d}t^2}(f\circ c)(t)$ using the chain rule twice.

and the answer is below.
$$\frac{\partial^2 f}{\partial x^{2}} \left(\frac{\mathrm{d}x}{\mathrm{d}t}\right)^2 + 2  \frac{\partial^2 f}{\partial x \partial y} \frac{\mathrm{d}x}{\mathrm{d}t}\frac{\mathrm{d}y}{\mathrm{d}t} + \frac{\partial^2 f}{\partial y^2} \left(\frac{\mathrm{d}y}{\mathrm{d}t}\right)^2 + 
\frac{\partial f}{\partial x} \frac{\mathrm{d}^2 x}{\mathrm{d}t^2} + \frac{\partial f}{\partial y} \frac{\mathrm{d}^2 y}{\mathrm{d}t^2}$$
where $c(t)=(x(t),y(t))$
But when I solved this problem, I got the answer:
$$\frac{\partial^2 f}{\partial x^2}\left(\frac{\mathrm{d}x}{\mathrm{d}t}\right)^2 + \frac{\partial^2 f}{\partial y^2} \left(\frac{\mathrm{d}y}{\mathrm{d}t}\right)^2 + 
\frac{\partial f}{\partial x}  \frac{\mathrm{d}^2 x}{\mathrm{d}t^2} + \frac{\partial f}{\partial y} \frac{\mathrm{d}^2 y}{\mathrm{d}t^2}$$ what is wrong?... Am i wrong?
 A: I think you must regard $\dfrac{\partial f}{\partial x}$ and $\dfrac{\partial f}{\partial y}$ as functions of $(x,y)$. I mean, in a first step we have (due to Chain Rule)
$$\frac{\text{d}}{\text{d}t}(f\circ c)(t)=\frac{\partial f}{\partial x}\frac{\text{d}x}{\text{d}t}+\frac{\partial f}{\partial y}\frac{\text{d}y}{\text{d}t}$$
Then, cause $\dfrac{\partial f}{\partial x}$ and $\dfrac{\partial f}{\partial y}$ depend on $(x,y)$, we have due to Chain Rule again:
\begin{align}
\frac{\text{d}^2}{\text{d}t^2}(f\circ c)(t) & =\frac{\text{d}}{\text{d}t}\left(\frac{\partial f}{\partial x}\frac{\text{d}x}{\text{d}t}+\frac{\partial f}{\partial y}\frac{\text{d}y}{\text{d}t}\right) \\
&  =\frac{\text{d}}{\text{d}t}\left(\frac{\partial f}{\partial x} \right)\frac{\text{d}x}{\text{d}t}+\frac{\partial f}{\partial x}\frac{\text{d}^2x}{\text{d}t^2}+\frac{\text{d}}{\text{d}t}\left(\frac{\partial f}{\partial y} \right)\frac{\text{d}y}{\text{d}t}+\frac{\partial f}{\partial y}\frac{\text{d}^2y}{\text{d}t^2} \\
& = \left(\frac{\partial^2 f}{\partial x^2}\frac{\text{d}x}{\text{d}t}+\frac{\partial^2 f}{\partial y \partial x}\frac{\text{d}y}{\text{d}t}\right)\frac{\text{d}x}{\text{d}t}+\frac{\partial f}{\partial x}\frac{\text{d}^2x}{\text{d}t^2}+\left(\frac{\partial^2 f}{\partial x \partial y}\frac{\text{d}x}{\text{d}t}+\frac{\partial^2 f}{\partial y^2}\frac{\text{d}y}{\text{d}t}\right)\frac{\text{d}y}{\text{d}t}+\frac{\partial f}{\partial y}\frac{\text{d}^2y}{\text{d}t^2} \\
\end{align}
Also, cause $\displaystyle{\frac{\partial^2 f}{\partial y \partial x}=\frac{\partial^2 f}{\partial x \partial y}}$, we can write
$$\frac{\text{d}^2}{\text{d}t^2}(f\circ c)(t)=\frac{\partial^2 f}{\partial x^2}\left(\frac{\text{d}x}{\text{d}t}\right)^2+2\frac{\partial^2 f}{\partial x \partial y}\frac{\text{d}x}{\text{d}t}\frac{\text{d}y}{\text{d}t}+\frac{\partial^2 f}{\partial y^2}\left(\frac{\text{d}y}{\text{d}t}\right)^2+\frac{\partial f}{\partial x}\frac{\text{d}^2x}{\text{d}t^2}+\frac{\partial f}{\partial y}\frac{\text{d}^2y}{\text{d}t^2}$$
