Change of variables example in an ODE I do not understand how this was obtained

Why the $(y')^2$ becomes $y'$ and the $y'$ becomes $(y')^2$ and why $y^2$ becomes $x^2 (y')^3$ in the new ode?
How does $\frac{d y(x)}{d x}$ change under this change of variables?
 A: You are changing the direction of dependence. Without changing variable names this means that you are deriving a differential equation for the inverse function $x(y)$. Now
$$
x=x(y(x))\\
1 = x'(y(x))y'(x)\\
0=x''(y(x))y'(x)^2+x'(y(x))y''(x)
$$
and with the last two together
$$
0=x''(y)+x'(y)^3y''(x)
$$
So replacing the $y$ derivatives in the original equation gives
$$
-\frac{x''(y)}{x'(y)^3}-\frac{1}{yx'(y)^2 }+\sin(x(y))\frac{y}{x'(y)}+\cos(x(y))y^2=0
$$
Now multiply with $-x'(y)^3$ to get
$$
x''(y)+\frac{x'(y)}{y}-\sin(x(y))yx'(y)^2-\cos(x(y))x'(y)^3=0
$$
Finally to get the claimed equation you need to exchange the variable names $x,y$.
A: IMO Leibniz's notation is a bit easier to follow.
$$\frac{d^2y}{dx^2} - \frac1y \left(\frac{dy}{dx}\right)^2 + \sin(x) y \frac{dy}{dx} + \cos(x) y^2 = 0$$
By the chain rule,
$$\frac{dy}{dx} = \frac1{\frac{dx}{dy}} \implies \frac{d^2y}{dx^2} = -\frac1{\left(\frac{dx}{dy}\right)^2} \frac{d\frac{dx}{dy}}{dx} = -\frac1{\left(\frac{dx}{dy}\right)^2} \frac{d^2x}{dy^2} \frac{dy}{dx} = -\frac1{\left(\frac{dx}{dy}\right)^3} \frac{d^2x}{dy^2}$$
The ODE transforms to
$$-\frac1{\left(\frac{dx}{dy}\right)^3} \frac{d^2x}{dy^2} - \frac1y \left(\frac1{\frac{dx}{dy}}\right)^2 + \sin(x) y \left(\frac1{\frac{dx}{dy}}\right) + \cos(x) y^2 = 0,$$
simplifies to
$$- \frac{d^2x}{dy^2} - \frac1y \frac{dx}{dy} + \sin(x) y \left(\frac{dx}{dy}\right)^2 + \cos(x) y^2 \left(\frac{dx}{dy}\right)^3 = 0,$$
and with the last variable change, we end up with
$$-\frac{d^2y}{dx^2} - \frac1x \frac{dy}{dx} + x \sin(y) \left(\frac{dy}{dx}\right)^2 + x^2 \cos(y) \left(\frac{dy}{dx}\right)^3 = 0$$
Multiply by $-1$ and swap out $\frac{dy}{dx}$ for $y'$ to get the exact same ODE.
