Tricky derivative with chain rule. Let $z = 1/x$ and $y = f(z)$, find $\dfrac{d^2y}{dx^2}$
So the answer was $$\frac{\mathrm{d} y}{\mathrm{d} x} = \frac{\mathrm{d} y}{\mathrm{d} z}\frac{\mathrm{d}z }{\mathrm{d}x }$$
Where $$\frac{\mathrm{d} y}{\mathrm{d} x} = \frac{\mathrm{d} y}{\mathrm{d} z}\frac{\mathrm{d}z }{\mathrm{d}x } =-\frac{\mathrm{d} y}{\mathrm{d} z}\frac{1}{x^2} = -\frac{\mathrm{d} y}{\mathrm{d} z}z^2$$
$$\dfrac{d^2y}{dx^2} =  \frac{\mathrm{d} }{\mathrm{d} x}\left ( \frac{\mathrm{d} y}{\mathrm{d} x} \right ) = \frac{\mathrm{d} }{\mathrm{d} x}\left ( \frac{\mathrm{d} y}{\mathrm{d} z}\frac{\mathrm{d}z }{\mathrm{d}x }\right ) = \frac{\mathrm{d} ^2y}{\mathrm{d} z^2}\left (\frac{\mathrm{d} z}{\mathrm{d} x}  \right )^2 + \frac{\mathrm{d} y}{\mathrm{d} z}\frac{\mathrm{d} ^2z}{\mathrm{d} x^2} $$
Could someone explain to me how on earth did $\frac{\mathrm{d} ^2y}{\mathrm{d} z^2}\left (\frac{\mathrm{d} z}{\mathrm{d} x}  \right )^2$ appear?
EDIT: I am going to show what I did. 
$$\frac{\mathrm{d} }{\mathrm{d} x}\left ( \frac{\mathrm{d} y}{\mathrm{d} z}\frac{\mathrm{d}z }{\mathrm{d}x }\right ) = \frac{d}{dx}\left(\frac{dy}{dz}\right) \frac{dz}{dx}+\frac{d
^2z}{dx^2}\frac{dy}{dz} = \frac{d}{dx}\left(\frac{-1}{z^2} \frac{dy}{dx}\right) \frac{dz}{dx}+\frac{d
^2z}{dx^2}\frac{dy}{dz}$$
Basically I don't understand how $$\frac{d}{dx}\left(\frac{-1}{z^2} \frac{dy}{dx}\right)$$ could turn into $$\frac{\mathrm{d} ^2y}{\mathrm{d} z^2}\left (\frac{\mathrm{d} z}{\mathrm{d} x}  \right )^2$$
In fact I got  $$\frac{d}{dx}\left(\frac{-1}{z^2} \frac{dy}{dx}\right) = 2z^{-3}\frac{\mathrm{d} z}{\mathrm{d} x}\frac{\mathrm{d} y}{\mathrm{d} x} - \frac{1}{z^2}\frac{\mathrm{d} ^2 y}{\mathrm{d} x^2}$$
 A: You need to use the product rule:
$$\frac{d^2y}{dx^2}=\frac{d}{dx}\left(\frac{dy}{dz}\frac{dz}{dx}\right) $$ 
$$\frac{d^2y}{dx^2}=\frac{d}{dx}\left(\frac{dy}{dz}\right) \frac{dz}{dx}+\frac{d}{dx}\left(\frac{dz}{dx}\right)\frac{dy}{dz} $$ 
So that
$$\frac{d^2y}{dx^2}=\frac{d}{dx}\left(\frac{dy}{dz}\right) \frac{dz}{dx}+\frac{d
^2z}{dx^2}\frac{dy}{dz} $$ 
Note that you're dealing implicitly with the derivatives, so if you substitute for any of the functions, you'll crash the whole manipulation (you can do it afterwards, but first get the expression, understand?)
So you need to find:
$$D=\frac{d}{{dx}}\left( {\frac{{dy}}{{dz}}} \right)$$
By the chain rule, this "simply" is:
$$\frac{d}{{dx}}\left( {\frac{{dy}}{{dz}}} \right) = \frac{d}{{dz}}\left( {\frac{{dy}}{{dz}}} \right)\frac{{dz}}{{dx}} = \frac{{{d^2}y}}{{d{z^2}}}\frac{{dz}}{{dx}}$$
So you get
$$\frac{{{d^2}y}}{{d{x^2}}} = \frac{{{d^2}y}}{{d{z^2}}}{\left( {\frac{{dz}}{{dx}}} \right)^2} + \frac{{{d^2}z}}{{d{x^2}}}\frac{{dy}}{{dz}}$$
Now you can calculate all those expressions separately and get what you want.
A: You have $ \frac{\mathrm{d} }{\mathrm{d} x}\left ( \frac{\mathrm{d} y}{\mathrm{d} z}\frac{\mathrm{d}z }{\mathrm{d}x }\right ) $, which is the derivative of a product, so you use the product rule:$ \frac{\mathrm{d} }{\mathrm{d} x}\left ( \frac{\mathrm{d} y}{\mathrm{d} z}\frac{\mathrm{d}z }{\mathrm{d}x }\right )= \frac{\mathrm{d}z }{\mathrm{d}x }\frac{\mathrm{d} }{\mathrm{d} x}\frac{\mathrm{d} y}{\mathrm{d} z}+\frac{\mathrm{d} y}{\mathrm{d} z}\frac{\mathrm{d} }{\mathrm{d} x}\frac{\mathrm{d}z }{\mathrm{d}x }$ and the first term yields another factor of $\frac{\mathrm{d}z }{\mathrm{d}x }$ because the derivative is with respect to $x$ while the "denominator" is $\mathrm{d}z$ so you need the chain rule.
