Taking the derivative of a differential equation

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.