Let's say we have a mass on a spring being driven by a forcing function. Given hook's law, $F = -kx$, and a forcing function of $$F(t) = F_0\sin(\omega t) .$$ We can write:
$$ m\frac{d^2x}{dt^2} = -kx + F_0\sin(\omega t) $$
All the physics resources I've come across assume that the motion of the spring follows the applied force, and present the solution as some form of:
$$ x = C\sin(\omega t) $$
They typically then go onto substitute x into the differential equation and obtain:
$$ C = \frac{F_0}{m(\omega_0^2-\omega^2)} $$
This is a pretty cool formula. I really wanted understand, why, if $\omega>\omega_0$, $C$ becomes negative and our motion is exactly out of phase with our force. This is not intuitive to me, and in an effort to better understand it, I decided to run a numerical analysis.
I started my mass initially at rest at position zero and to my horror, my numerical analysis yielded these results:
Clearly the motion of the mass can not be described by a single sine! What's going on here? After pulling my hair out a bit, I realized that my numeric analysis was in fact correct, and it was the analytical solution that was lacking. The full solution to our equation of motion is:
$$ x(t) = A\sin(\omega_0 t) + B\cos(\omega_0 t) + \frac{F_0 \sin(\omega t)}{m(\omega_0^2-\omega^2)} $$
And when we setup out initial conditions correctly, this analytical solution agrees with the numerical solution! Our earlier solution is a special case of this solution - but the initial conditions must be set to very specific values for this to happen.
So my question is - what the heck is going on here? Is this solution just not important, or not relevant? It seems to me that unless the initial conditions are exactly right, you won't even see the behavior shown in most physics resources. In real applications, does the solution taught typically just not happen, or am I missing something?