Taking the derivative of a differential equation

My book jumps from

$$\frac{\partial f}{\partial x}(x, g(x)) + \frac{\partial f}{\partial y}(x, g(x))g'(x) = 0 $$

to

$$\frac{\partial^2 f}{\partial x^2}(x, g(x)) + 2 \cdot \frac{\partial f}{\partial x \partial y} (x, g(x))g'(x) + \frac{\partial^2 f}{\partial y^2}(x, g(x))(g'(x))^2 + \frac{\partial f}{\partial y}(x, g(x))g''(x) = 0.$$

It is left as an exercise to verify that this new equality can be obtained by differentiating both sides of the first equation. I've been trying to do this, but I haven't been able to get to the desired result. I'm sort of new to partial derivatives, and I would really appreciate it if someone can show me the steps that are taken when differentiating the first equation. I'm pretty sure my setup itself is wrong.

I've looked at many examples now, but I still haven't been able to get anywhere, since they are not too similar to what I have

I would really appreciate any help.

Thanks


My try:

$$\frac{\partial}{\partial x}\left(\frac{\partial f}{\partial x}(x, g(x)) + \frac{\partial f}{\partial y}(x, g(x))g'(x)\right) $$

$$= \underbrace{\frac{\partial}{\partial x}\left(\frac{\partial f}{\partial x}(x,g(x)) \right)}_{\text{Term 1}} + \underbrace{\frac{\partial}{\partial x}\left(\frac{\partial f}{\partial y}(x, g(x))g'(x)\right)}_{\text{Term 2}}$$

Now computing Term 1:

$$\frac{\partial}{\partial x}\left(\frac{\partial f}{\partial x}(x,g(x)) \right) = \frac{\partial^{2}f}{\partial x^{2}}(x, g(x)) \cdot \text{ some chain rule term} $$

What would the chain rule term be? I know in single-variable calculus, if you're doing the derivative of $f(g(x))$, then you need to multiply by $g'(x)$. But here, there are two variables.


You're presumably given a function $f$ whose domain is a subset of $\mathbb R^2$. Since this isn't specified, I'll take the simpler approach and assume the domain is $\mathbb R^2$. This allow us to write $f\colon \mathbb R^2 \to \mathbb R$.

Also presumably, you're given a differential function $g\colon \mathbb R\to \mathbb R$.

Now let's define $\varphi$ as $\varphi \colon \mathbb R\to \mathbb R^2, x\mapsto (x, g(x))$.

You want to differentiate the function given below (with the appropriate implicit domain)

$$ x\mapsto \frac{\partial f}{\partial x}(x, g(x)) + \frac{\partial f}{\partial y}(x, g(x))g'(x) $$

This can be rewritten as

$$ x\mapsto \left(\frac{\partial f}{\partial x}\circ\varphi\right)(x) + \left(\frac{\partial f}{\partial y}\circ\varphi\right)(x)\cdot g'(x) $$

Since the derivative of a sum is the sum of the derivatives (when they all exist), we can focus on each member of this sum separately.

We want to differentiate $\color{blue}{x\mapsto \left(\dfrac{\partial f}{\partial x}\circ\varphi\right)(x)}$. Now allow me to change the notation $\dfrac{\partial f}{\partial x}$ to $\partial_1f$. They denote the same thing: the derivative with respect to the first coordinate.

In the notation of this answer we have $m=2$, $n=1=p$, $G=\partial_1f$, $F=\varphi$, (now because the choice of letters in both questions gets confusing, I'll use $\varphi_1$ and $\varphi_2$ (in place of $f_1$ and $f_2$ used in the linked answer), $\varphi_1\colon \mathbb R\to \mathbb R, x\mapsto x$ and $\varphi_2\colon \mathbb R\to \mathbb R, x\mapsto g(x)$. Now set $H=G\circ F$.

We have that $\color{blue}{H}$ is $\color{blue}{\left(\partial_1f\right)\circ \varphi}$ and this is what we wish to differentiate, in other words we wish to find $H'$. Since $H$ is a scalar function whose domain is $\mathbb R$, its components are just a singular $h_1$ in the notation of the linked answer, which yields:

$$ \begin{align} \overbrace{ \begin{bmatrix} \partial _1h_1 \end{bmatrix}_{x} }^{H'(x)} &= \begin{bmatrix} \partial_1\left(\partial_1f\right) & \partial_2\left(\partial_1f\right) \end{bmatrix}_{\varphi(x,y)} \overbrace{\begin{bmatrix} \partial _1\varphi_1\\ \partial_1\varphi_2 \end{bmatrix}_{x}}^{\begin{bmatrix} \varphi_1'\\ \varphi_2' \end{bmatrix}_{x}}\\ &= \begin{bmatrix} \left(\partial _1\left(\partial_1f\right)\right)(x,g(x)) & \left(\partial_2\left(\partial_1f\right)\right)(x, g(x)) \end{bmatrix} \begin{bmatrix} 1\\ g'(x) \end{bmatrix}\\ &= \begin{bmatrix} \left(\partial _1\left(\partial_1f\right)\right)(x,g(x)) + \left(\partial_2\left(\partial_1f\right)\right)(x, g(x))\cdot g'(x) \end{bmatrix}_. \end{align} $$

The last term above can be translated back to

$$ \dfrac{\partial^2f}{\partial x^2}(x,g(x)) + \dfrac{\partial^2f}{\partial y\partial x}(x, g(x))\cdot g'(x) $$

It is similar for $\dfrac{\partial f}{\partial y}\circ\varphi$.


Hint: The notation can be a bit confusing here. $f$ is a function of two variables. A derivative with respect to the first variable is denoted by $\frac{\partial f}{\partial x}$, a derivative with respect to the second variable is denoted by $\frac{\partial f}{\partial y}$. If instead you denote them by $\frac{\partial f}{\partial x_1}$ and $\frac{\partial f}{\partial x_2}$ it might be a bit clearer. At the same time you plug in the function $x$ into the first variable and the function $g(x)$ into the second variable. You are differentiating with respect to $x$ and need to apply the chain rule.

Edit: I will write out what happens in the first term with the renaming of variables. We want to compute: $$\frac{\partial}{\partial x}\left(\frac{\partial f}{\partial x_1}(x, g(x))\right)$$ So we have $$\frac{\partial}{\partial x}\left(\frac{\partial f}{\partial x_1}(x, g(x))\right)=\frac{\partial }{\partial x_1}\frac{\partial f}{\partial x_1}(x, g(x)) \cdot \frac{\partial }{\partial x}(x) + \frac{\partial }{\partial x_2}\frac{\partial f}{\partial x_1}(x, g(x)) \cdot \frac{\partial }{\partial x}g(x)$$ Simplify a bit:

$$\frac{\partial}{\partial x}\left(\frac{\partial f}{\partial x_1}(x, g(x))\right)=\frac{\partial^2 f}{\partial^2 x_1}(x, g(x)) + \frac{\partial^2 f}{\partial x_2\partial x_1}(x, g(x)) \cdot g'(x)$$ The second term is almost the same, you just have an extra factor of $g(x)$ that requires the product rule.