# Solve the ODE $\ddot{y}+2\lambda\dot{y} + n^2y=f\cos(wt)$ for given boundary conditions.

I'm having trouble understanding the given solution to this problem.

Solve the ODE $$\ddot{y}+2\lambda\dot{y} + n^2y=f\cos(wt)$$ with $$y(0)=\dot{y}(0)=0$$, where $$f$$, $$n$$, $$w$$ and $$\lambda$$ are positive constants with $$\lambda <.

Solution

The 3rd line onward is what I am having difficulty understanding. My attempt is below.

Attempt

$$y_h=e^{-\lambda t}(A_1\cos(\sigma t)+A_2\sin(\sigma t))$$ where $$y_h$$ is the homogeneous solution.

For the particular solution guess $$y_p=B_1\cos(wt)+B_2\sin(wt)$$, so $$\dot{y}_p=-B_1 w\sin(wt)+B_2 w\cos(wt)$$, and $$\ddot{y}_p=-B_1 w^2\cos(wt)-B_2 w^2\sin(wt)$$.

Substitute these into the ODE to get $$\cos(wt)[B_1 (n^2-w^2)+2\lambda w B_2]+\sin(wt)[B_2(n^2-w^2)-2\lambda w B_1]=f\cos(wt).$$

Then $$B_1 (n^2- w^2)+2\lambda w B_2 =f \quad\&\quad B_2(n^2-w^2)-2\lambda w B_1=0$$

The 2nd equation gives $$B_1=B_2\dfrac{(n^2-w^2)}{2\lambda w}$$. Substituting into the 1st equation gives $$B_2=\dfrac{2\lambda w f}{(n^2-w^2)^2+4\lambda^2w^2}$$, which implies $$B_1=\dfrac{f(n^2-w^2)}{(n^2-w^2)^2+4\lambda^2w^2}$$.

Substituting these back into the original guess we get $$y_p=\dfrac{2\lambda w f}{(n^2-w^2)^2+4\lambda^2w^2}\cos(wt)+\dfrac{f(n^2-w^2)}{(n^2-w^2)^2+4\lambda^2w^2}\sin(wt).$$

So the general solution is

$$y=y_h+y_p=e^{-\lambda t}(A_1\cos(\sigma t)+A_2\sin(\sigma t))+\dfrac{2\lambda w f}{(n^2-w^2)^2+4\lambda^2w^2}\cos(wt)+\dfrac{f(n^2-w^2)}{(n^2-w^2)^2+4\lambda^2w^2}\sin(wt).$$

...and now I just feel lost (partly due to being rusty and the solution being written in a foreign style).

The solutions are both correct, if you were to insert the constants $$B_1,B_2$$ correctly back into $$y_p$$. The difference of the forms is "hidden" in the not largely discussed nature of $$\alpha$$.

The cited solution considers the original equation as the real part of the complex equation $$\ddot z+2λ\dot z+n^2z=f\,e^{i\omega t}.$$ This equation now only has a single exponential as inhomogeneity, so that the standard procedure of the method of undetermined coefficients easily applies, trying $$z_p(t)=C\,e^{i\omega t}$$ one finds $$C=\frac{f}{-ω^2+2iλω+n^2}.$$

At this point, instead of using the polar decomposition of $$C=R\cdot e^{iα}$$, you could as well just compute the real part of the solution found, $$y_p(t)=Re(z_p(t))=Re\left(\frac{f((n^2-ω^2)-2iλω)(\cos ωt+i\sin ωt)}{(n^2-ω^2)^2+(2λω)^2}\right) \\ =\frac{f((n^2-ω^2)\cos ωt+2λω\sin ωt)}{(n^2-ω^2)^2+(2λω)^2}$$ which is your solution with the constants inserted correctly.

This kind of DE (linear with constant coefficients) is well suited to be solved with the called operational methods like the Laplace transform method. After applying the transform we have:

$$\mathcal{L}\left(\ddot{y}+2\lambda\dot{y} + n^2y\right)=\mathcal{L}\left(f\cos(wt)\right)$$

or

$$s^2Y(s)-sy_0-\dot y_0+2\lambda(s Y(s)-y_0)+n^2Y(s) = \frac{f s}{s^2+w^2}$$

or

$$Y(s) = \frac{(s+2\lambda)y_0+\dot y_0}{s^2+2\lambda s+n^2}+\frac{f s}{(s^2+w^2)(s^2+2\lambda s+n^2)}$$

here we have

$$Y_h(s) = \frac{(s+2\lambda)y_0+\dot y_0}{s^2+2\lambda s+n^2}\\ Y_p(s) = \frac{f s}{(s^2+w^2)(s^2+2\lambda s+n^2)}$$

$$Y_h(s)$$ is the homogeneous solution which in this case is null due to the initial conditions $$\dot y_0=y_0= 0$$ so here

$$y(t) = \mathcal{L}^{-1}\left(\frac{f s}{(s^2+w^2)(s^2+2\lambda s+n^2)}\right)$$

that can be easily determined using the anti-transform tables.

NOTE

$$\frac{f s}{(s^2+w^2)(s^2+2\lambda s+n^2)} = \frac{a_1 s+ b_1}{s^2+w^2}+\frac{a_2s+b_2}{s^2+2\lambda s+n^2}$$

and

$$\mathcal{L}^{-1}\left(\frac{a_1 s+ b_1}{s^2+w^2}\right) = \frac 1 w(a_1 w \cos (w t)+b_1 \sin (w t))\phi(t)\\ \mathcal{L}^{-1}\left(\frac{a_2s+b_2}{s^2+2\lambda s+n^2}\right) = \frac{e^{-\lambda t} \left((b_2-a_2 \lambda ) \sinh \left(t \sqrt{\lambda ^2-n^2}\right)+a_2 \sqrt{(\lambda -n) (\lambda +n)} \cosh \left(t \sqrt{\lambda ^2-n^2}\right)\right)}{\sqrt{(\lambda -n) (\lambda +n)}}\phi(t)$$

Here $$\phi(t)$$ is the Heavside step function. We can observe also that

$$y_p(t) = y_{ss}(t)+y_{tr}(t)$$

with

$$y_{ss}(t) = \frac 1 w(a_1 w \cos (w t)+b_1 \sin (w t))\phi(t)$$

the steady state response to the forcing input $$(f\cos(wt))$$

and

$$y_{tr} = \frac{e^{-\lambda t} \left((b_2-a_2 \lambda ) \sinh \left(t \sqrt{\lambda ^2-n^2}\right)+a_2 \sqrt{(\lambda -n) (\lambda +n)} \cosh \left(t \sqrt{\lambda ^2-n^2}\right)\right)}{\sqrt{(\lambda -n) (\lambda +n)}}\phi(t)$$

the transitory response to the forcing input