Simple harmonic oscillator position function We know from Hooke's law $$F=-kx $$ and $$ md^2x/dt^2 = -kx$$ therefore
$$x''+w^2x=0$$
we must get $$x(t) =A\cos(wt)$$ but I don't know how
I  know how to derive the position function from graph, but i don't know how to solve it as linear differential equation. May someone do that?
 A: Let's start from the equation of motion
\begin{equation}\tag{1}
m\frac{d^2x}{dt^2} = -kx
\end{equation}
and introduce the constant
\begin{equation}\tag{2}
\omega^2 = \frac{k}{m}
\end{equation}
so that equation (1) becomes
\begin{equation}\tag{3}
\frac{d^2x}{dt^2} = -\omega^2 x.
\end{equation}
This is a second order linear differential equation with constant coefficients and one way to solve it is by letting $x = e^{\lambda t}$ where $\lambda$ is another constant. Substituting this form in (3) we get
\begin{equation}\tag{4}
(\lambda^2 + \omega^2)e^{\lambda t} = 0.
\end{equation}
Since $e^{\lambda t} \ne 0$, we have $\lambda = \pm i\omega$ and the general solution of (3) is
\begin{equation}\tag{5}
x(t) = A_1 e^{i\omega t} + A_2e^{-i\omega t},
\end{equation}
where $A_1$ and $A_2$ are constant of integration to be determined from the initial conditions. If, for example, $x(0) = A$ and $\dot{x}(0) = 0$ then we have
\begin{eqnarray}
A &=& A_1 + A_2 \\
0 &=& i\omega(A_1 - A_2).
\end{eqnarray}
The solution of these equations is $A_1 = A/2, A_2 = A/2$. Therefore, for this choice of initial conditions, equation (5) becomes,
\begin{equation}\tag{6}
x(t) = \frac{A}{2}\left(e^{i\omega t} + e^{-i\omega t}\right) = A\cos(\omega t).
\end{equation}
The number $A$ is called the amplitude of the oscillator.
A: *

*Complex and binomial formula:
$$
0=(D^2+w^2)x=(D+iw)(D-iw)x=0
$$
leads to recognize basis solutions $x=e^{\pm iwt}$. Linear combinations that are real functions are $\cos(wt)$ and $\sin(wt)$ and with phase $A\cos(wt+\phi)$.


*Finding a first integral, multiply with $2x'$ and integrate to
$$
2x'x''+2w^2xx'=0\implies x'^2+w^2x^2=R^2
$$
Recognize this as circle equation and parametrize $x'=R\cos(u(t))$, $wx=R\sin(u(t))$, explore the consequences to find $u'=w$.


*Find/guess an integrating factor (there is such a thing also for second order linear DE)
$$
0=\cos(wt)x''+\cos(wt)w^2x=[\cos(wt)x''-w\sin(wt)x']+w[\sin(wt)x'+w\cos(wt)x]
\\
\implies
C=\cos(wt)x'+w\sin(wt)x
$$
and continue solving as first-order linear DE with integrating factor $1/\cos^2(wt)$.
A: First, $Acos(\omega t)$ is not the general solution this would be $x(t)=Acos(\omega t)+Bsin(\omega t)$ the only thing you have to know if you are not familiar with komplex functions is that $(Acos(b t))''=-A*b^2cos(bt) and (Bsin(b t))''=-Bb^2sin(b t)$ so you have not really  to "solve" it but just look for a known function with f''=-f. just f you want to solve x^2=4 you remember that $4=2^2 and (-2)^2$
