# Find coefficients for harmonic oscillator ODE

Related to Small mismatch in theoretical vs MMA solutions of a damped harmonic oscillator differential equation, given the ODE $$\ddot y + 2\xi \omega \dot y + \omega^2 y = fo \cos( \omega_{dr}x), \quad y(0)=1,\ \dot y(0)=1 \quad(3)$$ can anyone give me the expressions for the coefficients $A, \phi$ in the solution $$y(x)= A e^{-\xi\omega x}\sin(\omega_d x + \theta) + A_0 \cos(\omega_{dr} x - \phi) \quad(4)$$ I believe they are $$A = \sqrt{[1+\xi \omega -A_0(\sin(\phi)+\xi \omega \cos(\phi))]^2+(1-A_0 \cos(\phi))^2} \quad (5)$$ $$\theta = atan2(1-A_0 \cos(\phi),1+\xi \omega -A_0(\sin(\phi)+\xi \omega \cos(\phi))) \quad (6)$$ but I got a mismatch between my results and the ones from a software. $atan2$ is the four-quadrant inverse tangent, as in Matlab software.

EDIT The theory of ODE says you can evaluate coefficients $A_0, \phi$ of the steady state solution from the coefficients of equation (3), $$A_0 = \frac{fo}{\sqrt{(\omega^2 - \omega_{dr}^2)^2 + (2\xi \ \omega \ \omega_{dr})^2}}$$ $$\phi = atan2(\omega^2 - \omega_{dr}^2,2\xi \ \omega \ \omega_{dr})$$ while the coefficients $A, \theta$ should be found from the initial conditions.

• Is $f_0$ the same as $A_0$? Have you plugged your initial conditions back into you solution to check it? Have you tried evaluating your solution numerically to check it? – horchler Feb 6 '15 at 18:59
• @horchler See EDIT. I just wonder if anyone can find the expression for coefficients $A, \theta$, and check if (5) , (6) are correct. – Nicola Feb 7 '15 at 10:59

You almost have it. The total solution is $$y(t) = y_h(t)+y_p(t)$$, where $$y_h(t)$$ is the solution to the homogenous equation and $$y_p(t)$$ is a particular solution to the equation.

The full derivation of the answer can be find in Rao, Mechanical Vibrations. It follows like that for the underdamped system:

$$\ddot{y}+2\xi\omega_n\dot{y}+\omega_n^2y=f_0\cos(\omega t)$$

The particular solution is

$$y_p(t)=Y\cos(\omega t-\phi)$$

Substituting it in the original equation, we get

$$Y=\frac{f_0}{\sqrt{(\omega_n^2-\omega^2)^2+(2\xi\omega_n\omega)^2}}\\ \phi= atan2(\omega_n^2-\omega^2,2\xi\omega_n\omega)$$

which is exactly what you wrote.

The homogeneous solution is the solution to $$\ddot{y}_h+2\xi\omega_n\dot{y}_h+\omega_n^2y_h=0$$ . For the undamped case is:

$$y_h(t) = Y_0e^{-\xi\omega_n t}\cos\left( \sqrt{1-\xi^2}\omega_n t-\phi_0 \right)$$

To ease the equations, we call $$\sqrt{1-\xi^2}\omega_n=\omega_d$$.

The complete solution can be written as $$y(t)=y_h(t)+y_p(t)$$:

$$y(t)=Y_0e^{-\xi\omega_nt}\cos(\omega_dt-\phi_0)+Y\cos(\omega t-\phi)$$

Substituting the initial conditions $$y(0)=y_0$$ and $$\dot{y}(0)=\dot{y}_0$$, we get:

$$y_0 = Y_0\cos\phi_0+Y\cos\phi\\ \dot{y}_0=-\xi\omega_n Y_0\cos\phi_0+\omega_d Y_0\sin\phi_0+\omega Y\sin\phi$$

Solving this set of equations, we get:

$$Y_0 = \left[ (y_0-Y\cos\phi)^2 + \frac{1}{\omega_d^2}(\xi\omega_n y_0+\dot{y}_0 - \xi\omega_n Y \cos\phi - \omega Y\sin\phi)^2\right]^2\\ \tan\phi_0=\frac{ \xi\omega_n y_0 + \dot{y}_0 - \xi\omega_n Y\cos\phi-\omega Y\sin\phi}{\omega_d(y_0-Y\cos\phi)}$$