Second total derivative of composite function and second partial derivatives, cant find my mistake Problem 1   given a composite function $z=f(u,v)$ where $u=xy$ and $v=\frac{x}{y}$ find the first and second total derivative in terms of $\mathrm dx$ and $\mathrm dy$.
My work is as follows $\mathrm d u=ydx+xdy  $ and $\mathrm dv=\frac{1}{y} \mathrm dx+\frac{-x}{y^2}\mathrm dy$ and i just substitute that in to $dz=f'_1 du+f'_2 dv$ and that is the correct solution now where im having trouble when i have to calculate second total differential i get $$\mathrm d^2 z=f''_{11}(y\mathrm dx+x\mathrm dy)+f''_{22}(\frac{y \mathrm dx - x \mathrm d y}{y^2})^2 + 2f''_{12}\frac{y^2 \mathrm dx^2-x^2 \mathrm dy^2}{y^2}$$ and the solution given in the book is $$ \mathrm d^2 z=f''_{11}(y\mathrm dx+x\mathrm dy)+f''_{22}(\frac{y \mathrm dx - x \mathrm d y}{y})^2 + 2f''_{12}\frac{y^2 \mathrm dx^2-x^2 \mathrm dy^2}{y^2}+2f'_1 \mathrm dx \mathrm dy-2f'_2\frac{(y\mathrm dx-x\mathrm dy)\mathrm dy}{y^3} $$ and i dont understand where the extra $2f'_1 \mathrm dx \mathrm dy-2f'_2\frac{(y\mathrm dx-x\mathrm dy)\mathrm dy}{y^3}$ come from. since following the logic of $\mathrm d(\mathrm d z)$ i am getting the wrong answer.
Problem 2 -mistake given a function $u=f(r)$ where $r=\sqrt{x^2+y^2+z^2}$ now in order to finish the problem i need to compute the first and second partial derivative with respect to $x$ and i get  $$ \frac { \partial u } { \partial x }=\frac { \partial f(r) } { \partial r }\frac { \partial r } { \partial x }=f'\frac{x}{r}$$ and now where the mistake happens when i try to compute the second partial derivative  as $$ \frac { \partial ^ 2 u } {  \partial x^2 }=\frac{\partial}{\partial x}(f'\frac{x}{r})=\frac { \partial (f'(r)\frac{x}{r}) } { \partial r }\frac { \partial r } { \partial x }=f''\frac{x^2}{r^2}-f'\frac{x^2}{r^3}$$ instead of the correct solution of $f''\frac{x^2}{r^2}-f'\frac{x^2}{r^3} +f'\frac{1}{r}$ if i just calculated without introducing $\partial r$ and just used $x$ and chain rule. Can someone explain to me where i made the mistake when introducing $\partial r$?
Thank you for the help in advance :D
 A: For the second problem,
$\frac { \partial ^ 2 u } {  \partial x^2 }=\frac{\partial}{\partial x}(f'\frac{x}{r}) = \frac{x}{r}\frac{\partial}{\partial x}(f') + f' \frac{\partial}{\partial x} (\frac{x}{r})$
$ = \frac{x}{r}\frac{\partial}{\partial x}(f') + f' \frac{\partial}{\partial x} (\frac{x}{r})$
$ = \frac{x}{r}  \frac{\partial (f')}{\partial r}   \frac{\partial r}{\partial x} + f' (\frac{1}{r} - \frac{x}{r^2} \frac{\partial r}{\partial x})$
$ = \frac{x^2}{r^2}  f'' + f' (\frac{1}{r} - \frac{x^2}{r^3})$
Edit: here is my earlier solution and I have added the missing terms.
$dz=f_1 du+f_2 dv$
Then $d^2z = f_{11} (du)^2 + f_{12} du \ dv + f_1 d^2u + f_{12} du \ dv + f_{22} (dv)^2 + f_2 d^2v$
You are missing $f_1 d^2u + f_2 d^2v$.
$f_1 d^2u = f_1 \ d (y dx + x dy) = f_1 (2 dx dy + y d^2x + x d^2y)$
Similarly, $f_2 d^2v = f_2 \ d (\frac{ydx - xdy}{y^2}) = f_2 \ [-\frac{2}{y^2} dx dy + \frac{1}{y} d^2x - \frac{x}{y^2} d^2y + \frac{2x}{y^3} (dy)^2]$
Or the way Graham Kemp explained,
$d^2 z = d^2x~\partial_x(z) + d^2y~\partial_y(z) + (d x)^2~\partial^2_x(z) + (d y)^2~\partial^2_y(z) + 2~dx~dy~\partial_y\partial_x(z)$
You can now differentiate each term and rearrange to get the same result. For example,
$d^2x~\partial_x(z) = d^2x~ (y f_1 + \frac{1}{y} f_2)$
I will take another term and let you work through the rest yourself.
$2 ~ dx ~ dy ~ \partial_y\partial_x(z) = 2 ~ dx ~ dy ~[\partial_y (y f_1 + \frac{1}{y}f_2]$
$ = 2 ~ dx ~ dy ~[f_1 - \frac{1}{y^2} f_2 + xy f_{11} - \frac{x}{y^3} f_{22}]$
