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?

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