# Confusion on taking the second partial derivative:

From this previous question I gained understanding of why the chain rule for a function $u(x,y)=f(p)$ is expressed as $$\frac{\partial u}{\partial x}=\frac{\mathrm{d}f(p)}{\mathrm{d}p}\times \frac{\partial p}{\partial x}$$ where $p=p(x,y)$

Now suppose that $u(x,y)=f(ax+by)$ therefore $$\color{blue}{\frac{\partial u}{\partial x}=a\frac{\mathrm{d}f(p)}{\mathrm{d}p}\tag{A}}$$ where $p=ax + by$

I need to compute $$\frac{\partial^2 u}{\partial x^2}$$

So my attempt is to recognize that $$\frac{\partial^2 u}{\partial x^2}=\frac{\partial}{\partial x}\left(\frac{\partial u}{\partial x}\right)$$ Therefore from equation $\color{blue}{\mathrm{(A)}}$ it should follow that $$\frac{\partial^2 u}{\partial x^2}=\frac{\partial}{\partial x}\left(a\frac{\mathrm{d}f(p)}{\mathrm{d}p}\right)$$ but according to my book source this is wrong and the correct answer is $$\frac{\partial^2 u}{\partial x^2}=\color{#A0F}{a^2}\color{#F80}{\frac{\mathrm{d^2}f(p)}{\mathrm{d}p^2}}$$

Could someone please kindly explain how this equation was obtained?

Specifically, I have no idea where the $\color{#A0F}{a^2}$ and the $\color{#F80}{\dfrac{\mathrm{d^2}f(p)}{\mathrm{d}p^2}}$ came from.

$\color{red}{\text{For some more context here is an image of the book source:}}$ ## 1 Answer

Neither you nor the book are wrong. The book just takes the calculation a step further: $$\frac{\partial}{\partial x}\left(a\frac{df}{dp}\right) =a\frac{\partial}{\partial x}\left(\frac{df}{dp}\right).$$ Treating $df/dp$ as a function $g(p) = \frac{df}{dp}(p)$, we apply the same reasoning you initially applied to $f$ to obtain $$\frac{\partial}{\partial x}\left(\frac{df}{dp}\right) = \frac{\partial}{\partial x}g(p) = \frac{dg}{dp}\frac{\partial p}{\partial x} = a\frac{d^2f}{dp^2}.$$ Putting this back into the first equation, $$\frac{\partial}{\partial x}\left(a\frac{df}{dp}\right) = a^2\frac{d^2f}{dp^2}.$$