# The general solution for inhomogeneous differential equation

I am working with the following inhomogeneous differential equation, $$x''+x=3\cos (\omega t)$$

The general solution for this is $x(t)=x_h(t)+x_p(t)$

First step is to find $x_h(t):$

So the characteristic equation is, $$\lambda^2+0 \lambda+1=0$$ and its roots are $$\lambda =\frac{\sqrt{-4}}{2}=\frac{i\sqrt{4}}{2}=\pm i$$ So $$x_h(t)=c_1 \cos(t)+c_2 \sin(t)$$

Second step is to find $x_p(t):$

My guess will be, $$x_p(t)=A \cos(\omega t)+B \sin(\omega t)$$

Now I take the derivative of my guess. $$x_p'(t)=-A \sin(\omega t) \cdot \omega+B \cos(\omega t) \cdot \omega$$ $$x_p''(t)= -A \cos(\omega t) \cdot \omega^2-B \sin(\omega t) \cdot \omega^2$$

The I have replace it in the equation $$-A \cos(\omega t) \cdot \omega^2-B \sin(\omega t) \cdot \omega^2 + A \cos(\omega t)+B \sin(\omega t) = 3 \cos(\omega t)$$

Since we have no $\sin(\omega t)$ on the RHS the B must be $0$ on the LHS. Then $$-A \cos(\omega t) \cdot \omega^2 - A \cos(\omega t) = 3 \cos(\omega t)$$

And isolate A $$A\big(- \cos(\omega t) \cdot \omega^2-\cos(\omega t)\big)=3 \cos(\omega t)$$ $$A=\frac{3 \cos(\omega t)}{- \cos(\omega t) \cdot \omega^2-\cos(\omega t)}$$ $$A=\frac{3 \cos(\omega t)}{\cos(\omega t)\big(-\omega^2-1 \big)}$$ $$A=\frac{3}{-\omega^2-1}$$

Then replace this into our guess $$x_p(t)=\frac{3}{-\omega^2-1} \cos(\omega t)$$ $$x_p(t)=\frac{3 \cos(\omega t)}{-\omega^2-1}$$

Last the general solution is $$x(t)=c_1 \cos(t)+c_2 \sin(t)-\frac{3 \cos(\omega t)}{\omega^2-1}$$

• Is your $x_p$ satisfies the differential equation? – user99914 Oct 21 '15 at 11:03
• To know that I should take the derivative twice and plug it into the equation I think... – Alim Teacher Oct 21 '15 at 11:06
• Yes, so is $x_p'' + x_p = 3\cos (\omega t)$? – user99914 Oct 21 '15 at 11:06
• No it doesn't satisfies – Alim Teacher Oct 21 '15 at 11:12
• Do you know in general how to guess a particular solution? There is something called variation of constant. – user99914 Oct 21 '15 at 11:19

The homogeneous solution is $$x_h(t) = c_1\cos t + c_2\sin t$$

There are two cases:

If $\omega \ne 1$, the particular solution is $$x_p(t) = A\cos(\omega t) + B\sin(\omega t)$$

where $A$ and $B$ are constants (not $3$, you don't know what they are yet).

If $\omega = 1$, our previous guess becomes $x_p(t) = A\cos t + B\sin t$, which is the same as the homogeneous solution. When you plug in this guess, you will get $0$ on the RHS. In order to fix it, we have to add a factor of $t$ $$x_p(t) = At\cos t + Bt\sin t$$

• So what do you think, should I choose $\omega \ne 1$ or $\omega =1$? – Alim Teacher Oct 21 '15 at 20:31
• That depends on the problem. If it doesn't tell you what $\omega$ is, you have to do both – Dylan Oct 22 '15 at 0:10
• I edited my calculations. please take a look. – Alim Teacher Oct 22 '15 at 10:05
• Wait I got it I just solved it. – Alim Teacher Oct 22 '15 at 10:11
• You're not done. What you have is the solution for $\omega \ne 1$. When $\omega = 1$, that solution is undefined. You need a different solution for that specific case (using the other guess). – Dylan Oct 22 '15 at 20:33

In general a second order equation of the type \begin{equation*} \partial _{t}^{2}x(t)+a\partial _{t}x(t)+bx(t)=f(t) \end{equation*} can be handled by rewriting it as a coupled set of first order equations by setting \begin{equation*} x_{1}=x,\;x_{2}=\partial _{t}x \end{equation*} Then, denoting \begin{equation*} \mathbf{x}(t)=\left( \begin{array}{c} x_{1}(t) \\ x_{2}(t) \end{array} \right) \end{equation*} one obtains the equation \begin{equation*} \partial _{t}\mathbf{x}(t)=\mathsf{A}\cdot \mathbf{x}(t)+\mathbf{y}(t) \end{equation*} where $\mathsf{A}$ is a $t$-independent $2\times 2$ matrix. In your case \begin{equation*} \partial _{t}^{2}x(t)+x(t)=3\cos (\omega t) \end{equation*} we have \begin{equation*} \mathsf{A}=\left( \begin{array}{cc} 0 & 1 \\ -1 & 0 \end{array} \right) ,\;\mathbf{y}(t)=\left( \begin{array}{c} 0 \\ 3\cos (\omega t) \end{array} \right) \end{equation*} and the solution is \begin{equation*} \mathbf{x}(t)=\exp [\mathsf{A}t]\cdot \mathbf{x}(0)+\int_{0}^{t}ds\exp [% \mathsf{A}(t-s)]\cdot \mathbf{y}(s) \end{equation*} Since \begin{equation*} \mathsf{A}^{2}=-\left( \begin{array}{cc} 1 & 0 \\ 0 & 1 \end{array} \right) =-\mathsf{I} \end{equation*} you have \begin{equation*} \exp [\mathsf{A}t]=\mathsf{I}\cos t+\mathsf{A}\sin t \end{equation*} Given \begin{equation*} \mathbf{y}(s)=\left( \begin{array}{c} 0 \\ 3\cos (\omega s) \end{array} \right) \end{equation*} you can do the $s$-integral and obtain the required result.