How to solve harmonic oscillator differential equation: $\dfrac{d^2x}{dt^2} + \dfrac{kx}{m} = 0$ I am able to solve simple differential equations like :
$$\dfrac{dy}{dx} = 3x^2 + 2x$$
We simply bring $dx$ to other site and integrate.
But how do we find solutions of differential equations like :
$$\frac{d^2x}{dt^2} + \dfrac{kx}{m} = 0$$
?
We have been told the solution is $x(t) = A\cos ( \omega t + \phi_o)$ where $\omega\ =\sqrt{\dfrac{k}{m}}$
but how do we actually find it?
 A: HINT:
$$x''(t)+\frac{kx(t)}{m}=0\Longleftrightarrow$$
$$\frac{\text{d}^2x(t)}{\text{d}t^2}+\frac{kx(t)}{m}=0\Longleftrightarrow$$

Assume a solution will be proportional to $e^{\lambda t}$ for some constant $\lambda$.
Substitute $x(t)=e^{\lambda t}$ into the differential equation:

$$\frac{\text{d}^2}{\text{d}t^2}\left(e^{\lambda t}\right)+\frac{ke^{\lambda t}}{m}=0\Longleftrightarrow$$

Substitute $\frac{\text{d}^2}{\text{d}t^2}\left(e^{\lambda t}\right)=\lambda^2e^{\lambda t}$:

$$\lambda^2e^{\lambda t}+\frac{ke^{\lambda t}}{m}=0\Longleftrightarrow$$
$$e^{\lambda t}\left(\lambda^2+\frac{k}{m}\right)=0\Longleftrightarrow$$

Since $e^{\lambda t}\ne 0$ for any finite $\lambda$, the zeros must come from the polynomial:

$$\lambda^2+\frac{k}{m}=0\Longleftrightarrow$$
$$\frac{k+m\lambda^2}{m}=0\Longleftrightarrow$$
$$\lambda=\pm\frac{i\sqrt{k}}{\sqrt{m}}$$
A: Basically, you are solving $\ddot{x}=-\omega_0^2x$. Double dot over $x$ means double derivative wrt time $t$. This is easily seen to be equivalent to $$\Big(\frac{d}{dt}+i\omega_0\Big)\Big(\frac{d}{dt}-i\omega_0\Big)x=0.$$ This would imply $$\Big(\frac{d}{dt}-i\omega_0\Big)x= const$$ You can take it from here using the method you use by transferring $dt$ on the other side and integrating.
A: The equation:
$y'' = -k^2 \cdot y$
Has the completesolution:
$y = f(x) = c_1 \cos(kx) + c_2 \sin(kx)$
Proof:
First we define two function g(x) and h(x)
$g(x)=f(x)\cos(kx)-\frac{1}{k}f'(x)\sin(kx)$
$h(x) = f(x)\sin(kx)+\frac{1}{k}f'(x)\cos(kx)$
We differentiate g(x) and h(x): (Using the product and chain rule)
$g'(x)=f'(x)\cos(kx)-f(x)k\sin(kx)-\frac{1}{k}(f''(x)\sin(kx)+f'(x)k\cos(kx))$
$h'(x)=f'(x)\sin(kx)+f(x)k\cos(kx)+\frac{1}{k}(f''(x)\cos(kx)-f'(x)k\sin(kx))$
Now comes the critical point. Lets assume the function f(x) is a solution to the differentialequation. If and only if f(x) is a solution the we can write:
$f''(x)=-k^2f(x)$
We can use this in the g(x) and h(x) functions and substitute for f''(x) and reduce the expression:
$g'(x)=f'(x)\cos(kx)-f(x)k\sin(kx)-\frac{1}{k}(\color{red}{-k^2f(x)}\sin(kx)+f'(x)k\cos(kx)) \Leftrightarrow$
$g'(x)=0$
$h'(x)=f'(x)\sin(kx)+f(x)k\cos(kx)+\frac{1}{k}(\color{red}{-k^2f(x)}\cos(kx)-f'(x)k\sin(kx)) \Leftrightarrow$
$h'(x)=0$
When the derivative of the functions are 0, then the functions themself must be constants:
$g(x)=c_1 \;\;\;$   and   $\;\;\;h(x)=c_2$
So we insert this in the two first equations:
$c_1=f(x)\cos(kx)-\frac{1}{k}f'(x)\sin(kx)$
$c_2 = f(x)\sin(kx)+\frac{1}{k}f'(x)\cos(kx)$
We multiply the $c_1$ equation with cos(kx) and we multiply the $c_2$ equation with sin(kx):
$c_1 \cos(kx)=f(x)\cos(kx)^2-\frac{1}{k}f'(x)\sin(kx)\cos(kx)$
$c_2 \sin(kx) = f(x)\sin(kx)^2+\frac{1}{k}f'(x)\cos(kx)\sin(kx)$
We then add the two equations:
$c_1 \cos(kx) + c_2 \sin(kx) = f(x)\cos(kx)^2-\frac{1}{k}f'(x)\sin(kx)\cos(kx) + f(x)\sin(kx)^2+\frac{1}{k}f'(x)\cos(kx)\sin(kx) \Leftrightarrow$
$c_1 \cos(kx) + c_2 \sin(kx) = f(x)\cos(kx)^2 + f(x)\sin(kx)^2 \Leftrightarrow$
$c_1 \cos(kx) + c_2 \sin(kx) = f(x)(\cos(kx)^2 + \sin(kx)^2) \Leftrightarrow$
$c_1 \cos(kx) + c_2 \sin(kx) = f(x)(1) \Leftrightarrow$
$c_1 \cos(kx) + c_2 \sin(kx) = f(x)$
All that is left is to test if this is a solutions by inserting in the differential equation. If you do that, you will find it is a solution.
Q.E.D
