# What is the position as a function of time, after transient, in damped driven harmonic ocillator?

The problem is covered in many books but nowhere I found the answer to this question: wondering what is $$x=x(t)$$ it looks to me not so trivial because it emerge a sign problem I can't find anywhere. Let me explain. The differential equation that rules the motion can be written $$$$\tag{1} \ddot{x} + \frac{1}{a} \dot{x}+\omega_0^2 x = f_0 \sin \omega t$$$$ where $$\omega_0$$ is the proper frequency, $$\omega$$ is the frequency of the external sinusoidal force, $$f_0=\frac{F_0}{m}$$ (being $$F_0$$ the maximum of the external force $$F(t)=F_0 \sin \omega t$$) and $$a=\frac{m}{c}$$ (being $$c$$ the friction constant, for what matters, the important thing here is that all these are constant). Let's suppose true the reasonable hypothesis that the particular solution we are looking for is sinusoidal (in other words, let's suppose that no matter the initial boundary conditions, far away in time the motion will be sinusoidal, the problem is finding amplitude and phase shift with force) $$$$\tag{2} x(t) = x_0 \sin (\omega t - \phi)$$$$ Exploiting trigonometric identities and doing derivatives, we get $$$$\tag{3} x(t) = x_0 (\sin \omega t \cos \phi - \cos \omega t \sin \phi)$$$$ $$$$\tag{4} \dot{x}(t) = x_0 \omega (\sin \omega t \sin \phi + \cos \omega t \cos \phi)$$$$ $$$$\tag{5} \ddot{x}(t) = -x_0 \omega^2 (\sin \omega t \cos \phi - \cos \omega t \sin \phi)$$$$ Putting in the differential equation I can find that $$x(t)$$ is solution if it is satisfied the system $$$$\tag{6} \begin{cases} - \omega^2 \cos \phi + \frac{\omega}{a} \sin \phi + \omega_0^2 \cos \phi = \frac{f}{x_0} \\ \omega^2 \sin \phi + \frac{\omega}{ a } \cos \phi - \omega_0^2 \sin \phi = 0 \end{cases}$$$$ From the second we have $$$$\tag{7} \sin \phi = \frac{\omega/a}{\omega_0^2 - \omega^2} \cos \phi$$$$ and by replacing in the first we have $$$$\tag{8} \cos \phi = \frac{f_0}{x_0} \cdot \frac{\omega_0^2 - \omega^2}{(\omega/ a )^2 + (\omega_0^2 - \omega^2)^2}$$$$ and by replacing (8) into (7) we get $$$$\tag{9} \sin \phi = \frac{f_0}{x_0} \cdot \frac{\omega / a}{(\omega/ a )^2 + (\omega_0^2 - \omega^2)^2}$$$$ From (7) we have $$$$\tag{10} \tan \phi = \frac{\omega/a}{\omega_0^2 - \omega^2}$$$$ so we get $$$$\tag{11} \phi = \arctan \left( \frac{\omega/a}{\omega_0^2 - \omega^2} \right) + n \pi \qquad n \in \mathbb{Z}$$$$ But $$\sin (\arctan(x) + n \pi) = \frac{(-1)^n x}{\sqrt{1+x^2}}$$ and $$\cos (\arctan(x) + n \pi) = \frac{(-1)^n}{\sqrt{1+x^2}}$$ so from (11) we have $$$$\tag{12} \sin \phi = \frac{\omega / a}{\sqrt{(\omega_0^2 - \omega^2)^2 + (\omega / a)^2}} \cdot \frac{(-1)^n}{\mathrm{sgn}(\omega_0^2 - \omega^2)}$$$$ where $$\frac{\omega_0^2 - \omega^2}{|\omega_0^2 - \omega^2|}$$ is written as $$\mathrm{sgn}(\omega_0^2 - \omega^2)$$ (no matter if the argument is dimensional: because of how sgn function is defined) and $$$$\tag{13} \cos \phi = \frac{|\omega_0^2 - \omega^2|}{\sqrt{(\omega_0^2 - \omega^2)^2 + (\omega / a)^2}} \cdot (-1)^n$$$$ these are coherent with (10) and with fundamental equation of trigonometry. By equaling (8) to (13) (or (9) to (12), it's the same) we get $$$$\tag{14} x_0 = \frac{f_0}{\sqrt{(\omega_0^2 - \omega^2)^2 + (\omega / a )^2}} (-1)^n \mathrm{sgn}(\omega_0^2 - \omega^2)$$$$ By exploiting (11) and (14) we can write the law of motion (2) as $$$$\tag{15} x(t) = \frac{f_0}{\sqrt{(\omega_0^2 - \omega^2)^2 + (\omega / a)^2}} (-1)^n \mathrm{sgn}(\omega_0^2 - \omega^2) \sin \left(\omega t - \arctan \left( \frac{\omega/a}{\omega_0^2 - \omega^2} \right) + n \pi \right)$$$$ But $$(-1)^n\sin(x+n\pi)=\sin x$$ so we have (no matter if $$n$$ is even or odd: from here $$n$$ leaves us) $$$$\tag{16} x(t) = \frac{f_0}{\sqrt{(\omega_0^2 - \omega^2)^2 + (\omega / a)^2}} \sin \left(\omega t - \arctan \left( \frac{\omega/a}{\omega_0^2 - \omega^2} \right) \right) \mathrm{sgn}(\omega_0 - \omega)$$$$ where I wrote $$\mathrm{sgn}(\omega_0^2 - \omega^2)$$ simply as $$\mathrm{sgn}(\omega_0 - \omega)$$ because $$\omega_0, \omega > 0$$ by definition and $$$$\tag{17} \mathrm{sgn}(\omega_0^2 - \omega^2) = \mathrm{sgn}((\omega_0 - \omega)(\omega_0 + \omega)) = \mathrm{sgn}(\omega_0 - \omega) \mathrm{sgn}(\omega_0 + \omega) = \mathrm{sgn}(\omega_0 - \omega)$$$$ Question: is (16) the equation of motion after the transient? Does the expression $$x=x(t)$$ change sign depending on $$\omega_0 \lessgtr \omega$$? Of course this doesn't influence the plot of function explaining resonance, the value of $$\omega$$ that maximize amplitude, the maximum amplitude, etc., however I can't find anywhere the explicit writing of $$x(t)$$ after transient, and this trouble me. I put (16) into (1) checking that the differential equation is actually satisfied: I'm inclined to believe that the sign function must be included in $$x=x(t)$$ as I did, but I can't find it anywhere so I'm asking for confirmation. In other words, I suspect that I cannot write an always valid formula for $$x(t)$$ after transient without using the sgn function, if I don't know which is greater between $$\omega$$ and $$\omega_0$$. Is this true?

You are correct. If we sweep the frequency of the external force $$\omega$$ across the resonant frequency $$\omega_0$$, the response will change its phase at the resonance. Mathematically, if you express $$x_0$$ (amplitude) as a function of $$f$$ and $$\omega$$ from your Eq. 6, you"ll get something like $$\frac{1}{\omega_0^2-\omega^2}$$ (I dropped the damping intentionally). This factor is responsible for the sign change.

• In absence of friction, after transient $x(t) = \frac{f_0}{\omega_0^2-\omega^2} \sin(\omega t)$ and the amplitude term change sign when we cross the resonance frequency (with no sgn function, and diverging when $\omega=\omega_0$). But the case with damping is much harder and the sgn function looks unavoidable. – Fausto Vezzaro May 4 at 22:59

parametrize damping coefficient to

$$\ddot{x} + (2 \zeta \omega_0) \dot{x} + (\omega_0^2) x = f_0 \sin \omega t$$

where $$\zeta$$ is the damping ratio.

and fit the general solution of the homogeneous equation to the particular one as follows:

• Underdamped, $$\zeta < 1$$ \begin{aligned} x(t) & = \exp(-\zeta \omega_0 t) \left( A \sin \omega_d t + B \cos \omega_d t \right) + C \sin \omega t + D \cos \omega t \\ & \omega_d =\omega_0 \sqrt{1-\zeta^2} \\ & C = f_0 \frac{\omega_0^2-\omega^2}{\omega^4+2 \omega^2 \omega_0^2 (2 \zeta^2-1)+\omega_0^4} \\ & D = -f_0 \frac{2\, \omega\, \omega_0\, \zeta}{\omega^4+2 \omega^2 \omega_0^2 (2 \zeta^2-1)+\omega_0^4} \end{aligned}
• Overdamped, $$\zeta > 1$$ \begin{aligned} x(t) & = \exp(-\zeta \omega_0 t) \left( A \sinh \omega_d t + B \cosh \omega_d t \right) + C \sin \omega t + D \cos \omega t \\ & \omega_d =\omega_0 \sqrt{\zeta^2-1} \\ & C = f_0 \frac{\omega_0^2-\omega^2}{\omega^4+2 \omega^2 \omega_0^2 (2 \zeta^2-1)+\omega_0^4} \\ & D = -f_0 \frac{2\, \omega\, \omega_0\, \zeta}{\omega^4+2 \omega^2 \omega_0^2 (2 \zeta^2-1)+\omega_0^4} \end{aligned}
• Critically Damped, $$\zeta = 1$$ \begin{aligned} x(t) & = B \exp(-\omega_0 t) + C \sin \omega t + D \cos \omega t \\ & \omega_d = 0 \\ & C = f_0 \frac{\omega_0^2-\omega^2}{\omega^4+2 \omega^2 \omega_0^2 +\omega_0^4} \\ & D = -f_0 \frac{2\, \omega\, \omega_0}{\omega^4+2 \omega^2 \omega_0^2 +\omega_0^4} \end{aligned}

Notice how when $$\zeta>1$$ the sign changes in the damped frequency calculation from $$\omega_d = \omega_0 \sqrt{1-\zeta^2}$$ to $$\omega_d =\omega_0 \sqrt{\zeta^2-1}$$. In addition, the homogeneous response changes from $$\sin$$ and $$\cos$$ to $$\sinh$$ and $$\cosh$$.

All of the above functions are to solved for $$A$$ and $$B$$ based on the initial conditions $$x(0) = x_0$$ and $$\dot{x}(0)=v_0$$.