In my mechanics class we had a differential equation arise from a spring oscillator via its energy ($x^2_{max}$ is some constant maximum length) :
$$\begin{align}\frac{1}{2}kx^2_{max}&=\frac{1}{2}mv^2+\frac{1}{2}kx^2\\\frac{k}{m}x^2_{max}&=\dot{x}^2+\frac{k}{m}x^2\\\end{align}$$
So we have $\dot{x}^2+\frac{k}{m}x^2-\frac{k}{m}x^2_{max}=0$ from this. I've been having some trouble solving this and WFA wasn't any help either. In the lecture my professor took the derivative and solved from there :
$$\begin{align}2\ddot{x}\dot{x}+2\frac{k}{m}x\dot{x}&=0\\\implies\ddot{x}+\frac{k}{m}x&=0\end{align}$$
In the end this would mean $x=x_{max}\cos(\omega t+\phi)$, but I'm still really confused about the technique of just taking the derivative here to solve. I thought maybe it's something like $y=x^2\implies\dot{y}=2x\dot{x}$ in disguise, but it doesn't really simplify once I rearrange for $\dot{x}^2$. How can I understand this?
Maybe moving away from the dot notation (which I have always hated but is sometimes necessary) may be helpful...
$$\frac{1}{2}kx^2_{max}=\frac{1}{2}mv^2+\frac{1}{2}kx^2$$ $$\therefore\frac{k}{m}x_{max}^2=v^2+\frac{k}{m}x^2$$
Applying the $\frac{d}{dt}$ operator on both sides of our equation yields;
$$0=\frac{d}{dt}(v\cdot v)+\frac{k}{m}\bigg[\frac{d}{dt}(x\cdot x)\bigg]$$
Which, by the product rule, gives us;
$$0=2(v' \cdot v)+2\frac{k}{m}(x'\cdot x)$$
$$\therefore0=2(x'' \cdot x')+2\frac{k}{m}(x'\cdot x)=2x'\bigg[x''+\frac{k}{m}x\bigg]$$
Now, this equality must hold for all $t$ but we know that $2x'$ is not equal to $0$ at all times. Therefore we must have;
$$x''+\frac{k}{m}x=0 $$