Dependent variable substitution of a differential equation. I am attempting to answer a question from a textbook. The question is as follows:
"Use the substitution $y = x^2$ to turn the differential equation $x\frac{d^2x}{(dt)^2} + (\frac{dx}{dt})^2 + x\frac{dx}{dt} = 0$ into a second order differential equation with constant coefficients involving y and t."
The answer according to the textbook is $\frac{d^2y}{(dt)^2} + \frac{dy}{dt} = 0$
I am unsure what to do with the $(\frac{dx}{dt})^2$ term in the original equation. Is it equivalent to $\frac{d}{dt}(x^2)$? If this is the case then my working gets as far as the following before I get stuck:

$x\frac{d^2x}{(dt)^2} + (\frac{dx}{dt})^2 + x\frac{dx}{dt} = 0$


$\Rightarrow x\frac{d^2x}{(dt)^2} + \frac{d}{dt}(x^2) + x\frac{dx}{dt} = 0$


$\frac{dy}{dt} =\frac{dy}{dx}\frac{dx}{dt}=2x\frac{dx}{dt} \Rightarrow \frac{d^2x}{(dt)^2}=\frac{d}{dx}(\frac{1}{2x}\frac{dy}{dt})$


$\Rightarrow x\frac{d}{dx}(\frac{1}{2x}\frac{dy}{dt}) + 2x + x\frac{1}{2x}\frac{dy}{dt} = 0$


$\Rightarrow \frac{1}{2x}\frac{dy}{dt} + \frac{1}{2}\frac{d^2y}{(dt)^2} + 2x + \frac{1}{2}\frac{dy}{dt} = 0$

Please can someone show me where I have gone wrong?
 A: In general, you are incorrect that $\left(\frac{dx}{dt}\right)^2 = \frac{d}{dt}\left(x^2\right)$ since $\frac{d}{dt}\left(x^2\right) = 2x\left(\frac{dx}{dt}\right)$, so they're equal only in the special case where $2x = \frac{dx}{dt}$. Instead, multiply the original equation on both sides by $2$ to get
$$2x\frac{d^2x}{(dt)^2} + 2\left(\frac{dx}{dt}\right)^2 + 2x\frac{dx}{dt} = 0 \tag{1}\label{eq1A}$$
Next, differentiating $y = x^2$ gives
$$\frac{dy}{dt} = 2x\left(\frac{dx}{dt}\right) \tag{2}\label{eq2A}$$
and then differentiating again, using the product rule this time, gives
$$\frac{d^2y}{(dt)^2} = 2\left(\frac{dx}{dt}\right)^2 + 2x\left(\frac{d^2x}{dt^2}\right)  \tag{3}\label{eq3A}$$
As you can see, with the left side of \eqref{eq1A}, we have \eqref{eq3A} matching the first $2$ terms and \eqref{eq2A} matching the final third term. Thus, \eqref{eq1A} can be rewritten as
$$\frac{d^2y}{(dt)^2} + \frac{dy}{dt} = 0 \tag{4}\label{eq4A}$$
A: As noticed $$\left(\frac{dx}{dt}\right)^2=\frac{dx}{dt}\cdot \frac{dx}{dt}\neq \frac{d(x^2)}{dt}$$
By the suggested substitution we have
$$y=x^2 \implies  \frac{dy}{dt}=2x  \frac{dx}{dt} \implies \frac{d^2y}{dt^2}=2  \left(\frac{dx}{dt}\right)^2+2x  \frac{d^2x}{dt^2}$$
that is

*

*$\frac{dx}{dt}=\frac1{2x}\frac{dy}{dt} $

*$\frac{d^2x}{dt^2}=\frac1{2x}\frac{d^2y}{dt^2}-\frac1{4x^3}\left(\frac{dy}{dt}\right)^2 $
then
$$x\frac{d^2x}{dt^2} + \left(\frac{dx}{dt}\right)^2 + x\frac{dx}{dt}=0$$
$$\frac1{2}\frac{d^2y}{dt^2}\color{red}{-\frac1{4x^2}\left(\frac{dy}{dt}\right)^2 +\frac1{4x^2}\left(\frac{dy}{dt}\right)^2}+ \frac1{2}\frac{dy}{dt}=0$$
$$\frac1{2}\frac{d^2y}{dt^2}+ \frac1{2}\frac{dy}{dt}=0$$
A: $$x\frac{d^2x}{dt^2} + \left(\frac{dx}{dt}\right)^2 + x\frac{dx}{dt} = 0$$
With another notation:
$$\color {blue}{xx''+ (x')^2} + xx' = 0$$
$$\color {blue}{(xx')'}+xx'=0$$
Multiply by $2$:
$$(2xx')'+2xx'=0$$
Since $(x^2)'=2xx'$:
$$(x^2)''+(x^2)'=0$$
And as $y=x^2$ this is simply:
$$y''+y'=0$$
