Harmonic oscillator equation
The definition of harmonic motion is that the acceleration is proportional to the position:
\[a(t) \propto -x(t)\ \forall t.\]
Let us denote the constant of proportionality by \(\omega^2\):
\[a(t) = -\omega^2 x(t).\]
For a spring-mass system:
\[\omega^2 = \frac{k}{m} \ \Rightarrow\ \omega = \sqrt{\frac{k}{m}}.\]
Using the definition of the acceleration, we get
\[\frac{\mathrm{d}^2x}{\mathrm{d}t^2} = -\omega^2 x(t).\]
This is the harmonic oscillator equation.
To solve it, consider which function is proportional to its own second derivative. The \(\sin(x)\) function is a likely candidate:
\[\frac{\mathrm{d}}{\mathrm{d}x}\left[\sin(x)\right] = \cos(x),\]
\[\frac{\mathrm{d}^2}{\mathrm{d} x^2} \left[\sin(x)\right] = \frac{\mathrm{d}}{\mathrm{d}x}\left[\cos(x)\right] = -\sin(x).\]
Now let us search the solution in the form \(x(t) = c \cdot \sin\left(\omega t + \phi_0\right)\):
\[\frac{\mathrm{d}x}{\mathrm{d}t} = c \cdot \cos\left(\omega t + \phi_0\right) \cdot \underbrace{\frac{\mathrm{d}}{\mathrm{d}t}\left(\omega t + \phi_0\right)}_{\omega} = c \cdot \omega \cdot \cos\left(\omega t + \phi_0\right),\]
\[\frac{\mathrm{d}^2x}{\mathrm{d}t^2} = \frac{\mathrm{d}}{\mathrm{d}t}\left[c \cdot \omega \cdot \cos\left(\omega t + \phi_0\right)\right] = c \cdot \omega \cdot \frac{\mathrm{d}}{\mathrm{d}t}\left[\cos\left(\omega t + \phi_0\right)\right],\]
\[\frac{\mathrm{d}^2x}{\mathrm{d}t^2} = c \cdot \omega \cdot \left[-\sin\left(\omega t + \phi_0\right)\right] \cdot \underbrace{\frac{\mathrm{d}}{\mathrm{d}t}\left(\omega t + \phi_0\right)}_{\omega} = - c \cdot \omega^2 \sin\left(\omega t + \phi_0\right) = -\omega^2 x(t).\]
Which means that \(x(t) = c \cdot \sin\left(\omega t + \phi_0\right)\) is a solution of the harmonic oscillator equation.
What is the constant \(c\)? Let us define the amplitude \(A\) as the maximum displacement from the equilibrium position: \(A := x_{\mathrm{max}}.\)
The value of \(x(t)\) is maximum when \(\sin\left(\omega t + \phi_0\right) = 1\), so the constant \(c\) is the amplitude itself:
\[x_{\mathrm{max}} = A = c \cdot 1 = c.\]
What is the meaning of \(\phi_0\)? It is called the initial phase and it determines the initial position \(x_0\) of the oscillator:
\[x_0 := x(t = 0) = A \cdot \sin\left(\omega \cdot 0 + \phi_0\right) = A \cdot \sin\left(\phi_0\right).\]