Problem with Hessian of a composite function I'm troubling calculating the Hessian of the following function. particularly , I was able to calculate correctly $\frac{\partial f}{\partial x}$ and hence, also $\frac{\partial ^2 f}{\partial x^{2}}$ , but when I try to  calculate $\frac{\partial f}{\partial y}$ and hence $\frac{\partial ^2 f}{\partial y^{2}}$ I get it wrong and I cannot find the source of my mistake. I will show you my try :
$f(x,y)$ = $g(x^{2}+ \phi(x,y), y) $
$u$= $\big(x^{2} + \phi(x,y)\big)$ and 
$v$= $y$
Thus, we can write:
$f(x,y)$ = $g(u,v)$  , so
$$\frac{\partial f(x,y)}{\partial y} =\frac{\partial}{\partial y} \big(g(u,v)\big)$$
$$\frac{\partial f(x,y)}{\partial y}= \frac{\partial g(u,v)}{\partial u} \frac{\partial u}{\partial y} + \frac{\partial g(u,v)}{\partial v} \frac{\partial v}{\partial y}$$
$$\frac{\partial f(x,y)}{\partial y}=\frac{\partial g(u,v)}{\partial u} \frac{\partial \phi(x,y)}{\partial y} +\frac{\partial g(u,v)}{\partial v}$$
Now I  do the second order derivative: 
$$\frac{\partial ^2 f(x,y)}{\partial y^{2}}= \frac{\partial }{\partial y}\big(\frac{\partial f(x,y)}{\partial y}\big)$$
$$\frac{\partial ^2 f(x,y)}{\partial y^{2}}= \frac{\partial }{\partial y} \Big(\big(\frac{\partial g(u,v)}{\partial u} \frac{\partial \phi(x,y}{\partial y} \big) + \frac{\partial g(u,v)}{\partial v}\Big) $$
$$\frac{\partial ^2 f(x,y)}{\partial y^{2}}= \frac{\partial}{\partial y} \Big(\frac{\partial g(u,v)}{\partial u}\big(\frac{\partial \phi(x,y)}{\partial y} \big) \Big) + \frac{\partial }{\partial y} \frac{\partial g(u,v)}{\partial v}$$
$$\frac{\partial ^2 f(x,y)}{\partial y^{2}}= \Bigg(\Big(\frac{\partial                          ^2 g(u,v)}{\partial u^2} \frac{\partial u}{\partial y}\Big)\frac{\partial \phi(x,y)}{\partial y} + \frac{\partial ^2 \phi(x,y)}{\partial y^2} \frac{\partial g(u,v)}{\partial u}\Bigg) + \Bigg(\frac{\partial ^2 g(u,v)}{\partial v^2} \frac{\partial v}{\partial y}\Bigg)$$
$$\frac{\partial ^2 f(x,y)}{\partial y^{2}}= \Bigg(\Big(\frac{\partial                          ^2 g(u,v)}{\partial u^2} \frac{\partial u}{\partial y}\Big)\frac{\partial \phi(x,y)}{\partial y} + \frac{\partial ^2 \phi(x,y)}{\partial y^2} \frac{\partial g(u,v)}{\partial u}\Bigg) + \Bigg(\frac{\partial ^2 g(u,v)}{\partial v^2}\Bigg)$$
But this result is not entirely correct,  because there is a whole term missed in my solution, the term of mixed derivatives, and I have not idea  how this kind of terms may arise. 
I really will appreciate some help. 
Thanks :D 
 A: Your first derivative is correct. In your second derivative, there are two chain-rule errors when going from line 3 to line 4: $$\frac{\partial}{\partial y}\frac{\partial g}{\partial u} = \frac{\partial^2 g}{\partial u^2}\frac{\partial u}{\partial y} \color{red}{+ \frac{\partial^2 g}{\partial u \partial v}\frac{\partial v}{\partial y}} $$ $$\frac{\partial}{\partial y}\frac{\partial g}{\partial v} = \frac{\partial^2 g}{\partial v^2}\frac{\partial v}{\partial y} \color{red}{+ \frac{\partial^2 g}{\partial u \partial v}\frac{\partial u}{\partial y}} $$
With that correction, the answer is complete. 
(Remember that $\frac{\partial g}{\partial u} = \frac{\partial g}{\partial u}(u,v)$; therefore, its derivative with respect to $y$ will depend on $\frac{\partial u}{\partial y}$ and $\frac{\partial v}{\partial y}$)

In detail, define $h(x,y) \equiv \langle x + \varphi(x,y), y\rangle$.

We have $f \equiv g \circ h$.
By the chain rule,
$$
\begin{align*}
\partial_y f &\equiv (\nabla g \circ h )\cdot \partial_y h\\
&= \left\langle \frac{\partial g}{\partial u}(x+\varphi(x,y),y),\; \frac{\partial g}{\partial v}(x+\varphi(x,y),y)\right\rangle \cdot \left\langle \frac{\partial \varphi}{\partial y}, 1 \right\rangle\\
&= \frac{\partial g}{\partial u}(x+\varphi(x,y),y)\cdot \frac{\partial \varphi}{\partial y} +\; \frac{\partial g}{\partial v}(x+\varphi(x,y),y) 
\end{align*}
$$
To compute the second derivative $\partial_{yy} f$, we'll split this sum into two terms. The easiest term is the second:
$$
\begin{align*}
\partial_y \left(\frac{\partial g}{\partial v}(x+\varphi(x,y), y)\right) &= \partial_y \left(\frac{\partial g}{\partial v}\circ h\right)\\& = \left(\nabla \frac{\partial g}{\partial v} \circ h \right)\;\cdot\partial_y h \\
&= \left\langle \frac{\partial^2 g}{\partial u \partial v }(x+\varphi(x,y), y), \frac{\partial^2 g}{\partial v \partial v }(x+\varphi(x,y), y)\right\rangle\cdot \left\langle \frac{\partial\varphi}{\partial y}, 1\right\rangle\\
&=  \frac{\partial^2 g}{\partial u \partial v }(x+\varphi(x,y), y)\cdot \frac{\partial \varphi}{\partial y} +  \frac{\partial^2 g}{\partial v ^2}(x+\varphi(x,y), y)\\
\end{align*}\\
$$
(Note that we have introduced a mixed partial derivative of $g$.)
To compute the other term, we use the product rule.
$$
\begin{align*}
\partial_y \left(\frac{\partial g}{\partial u}(x+\varphi(x,y),y)\cdot \frac{\partial \varphi}{\partial y}\right) &=  \frac{\partial g}{\partial u}(x+\varphi(x,y),y)\cdot \frac{\partial^2 \varphi}{\partial y^2} \;\;+\;\; \frac{\partial \varphi}{\partial y} \cdot \partial_y \left[\frac{\partial g}{\partial u}(x+\varphi(x,y),y)\right]\\
&=  \frac{\partial g}{\partial u}(x+\varphi(x,y),y)\cdot \frac{\partial^2 \varphi}{\partial y^2} \;\;+\;\; \frac{\partial \varphi}{\partial y} \cdot \partial_y \left[\frac{\partial g}{\partial u}\circ h\right]\\
&=  \frac{\partial g}{\partial u}(x+\varphi(x,y),y)\cdot \frac{\partial^2 \varphi}{\partial y^2} \;\;+\;\; \frac{\partial \varphi}{\partial y} \cdot \left[\left(\nabla\frac{\partial g}{\partial u}\circ h\right) \cdot \partial_y h\right]\\
&=  \frac{\partial g}{\partial u}(x+\varphi(x,y),y)\cdot \frac{\partial^2 \varphi}{\partial y^2} \;\;+\;\; \frac{\partial \varphi}{\partial y} \cdot \underbrace{\left[ \frac{\partial^2 g}{\partial u^2 }(x+\varphi(x,y), y)\cdot \frac{\partial \varphi}{\partial y} +  \frac{\partial^2 g}{\partial u\partial v}(x+\varphi(x,y), y) \right]}_{\text{(By analogy with the term we computed above.)}}\\
\end{align*}
$$
Adding the two terms together, we find that
$$\frac{\partial^2 f}{\partial y^2} = \frac{\partial^2 g}{\partial v^2}(x^2+\varphi, y) \;+\; 2 \frac{\partial \varphi}{\partial y}\frac{\partial^2 g}{\partial u\partial v}(x+\varphi, y) \;+\; \left(\frac{\partial \varphi}{\partial y}\right)^2 \frac{\partial^2 g}{\partial u^2}(x+\varphi, y) \;+\; \frac{\partial^2 \varphi}{\partial y^2} \frac{\partial g}{\partial u}(x+\varphi, y)$$
