# 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}$$

-

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.

-
 I know what you guys mean, but it shouldn't come out with the square. see my edit – sizz Jun 28 '12 at 1:11 @jak Let me get to that – Peter Tamaroff Jun 28 '12 at 1:41 How did you get $\frac{d}{{dx}}\left( {\frac{{dy}}{{dz}}} \right) = \frac{d}{{dz}}\left( {\frac{{dy}}{{dz}}} \right)\frac{{dz}}{{dx}}$ relation? – sizz Jun 28 '12 at 1:50 That is a Leibnizian way of stating the chain rule! Else, you can get the intuition with $$\frac{d}{{dx}}\left( {\frac{{dy}}{{dz}}} \right) = \frac{d}{{dx}}\left( {\frac{{dy}}{{dz}}} \right)\frac{{dz}}{{dz}} = \frac{d}{{dz}}\left( {\frac{{dy}}{{dz}}} \right)\frac{{dz}}{{dx}}$$ but some people might not like it! – Peter Tamaroff Jun 28 '12 at 1:53 I had to reread my Multivariable Calculus Chain rule to understand because that's how I always understood the chain rule. – sizz Jun 28 '12 at 19:32

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.

-