8.6: Inhomogenous ODEs
We now consider the general inhomogeneous linear second-order ode Equation \ref{8.1}:
\[\ddot{x}+p(t) \dot{x}+q(t) x=g(t), \nonumber \]
with initial conditions \(x\left(t_{0}\right)=x_{0}\) and \(\dot{x}\left(t_{0}\right)=u_{0}\) . There is a three-step solution method when the inhomogeneous term \(g(t) \neq 0\) . (i) Find the general solution of the homogeneous equation
\[\ddot{x}+p(t) \dot{x}+q(t) x=0 . \nonumber \]
Let us denote the homogeneous solution by
\[x_{h}(t)=c_{1} X_{1}(t)+c_{2} X_{2}(t), \nonumber \]
where \(X_{1}\) and \(X_{2}\) are linearly independent solutions of \(Equation \ref{8.22}\) , and \(c_{1}\) and \(c_{2}\) are as yet undetermined constants. (ii) Find a particular solution \(x_{p}\) of the inhomogeneous equation Equation \ref{8.21}. A particular solution is readily found when \(p(t)\) and \(q(t)\) are constants, and when \(g(t)\) is a combination of polynomials, exponentials, sines and cosines. (iii) Write the general solution of Equation \ref{8.21} as the sum of the homogeneous and particular solutions,
\[x(t)=x_{h}(t)+x_{p}(t), \nonumber \]
and apply the initial conditions to determine the constants \(c_{1}\) and \(c_{2}\) . Note that because of the linearity of \(Equation \ref{8.21}\) ,
\[\begin{aligned} \ddot{x}+p \dot{x}+q x &=\frac{d^{2}}{d t^{2}}\left(x_{h}+x_{p}\right)+p \frac{d}{d t}\left(x_{h}+x_{p}\right)+q\left(x_{h}+x_{p}\right) \\ &=\left(\ddot{x}_{h}+p \dot{x}_{h}+q x_{h}\right)+\left(\ddot{x}_{p}+p \dot{x}_{p}+q x_{p}\right) \\ &=0+g \\ &=g \end{aligned} \nonumber \]
so that Equation \ref{8.23} solves \(Equation \ref{8.21}\) , and the two free constants in \(x_{h}\) can be used to satisfy the initial conditions.
We will consider here only the constant coefficient case. We now illustrate the solution method by an example.
Solve \(\ddot{x}-3 \dot{x}-4 x=3 e^{2 t}\) with \(x(0)=1\) and \(\dot{x}(0)=0\).
Solution
First, we solve the homogeneous equation. The characteristic equation is
\[\begin{aligned} r^{2}-3 r-4 &=(r-4)(r+1) \\ &=0, \end{aligned} \nonumber \]
so that
\[x_{h}(t)=c_{1} e^{4 t}+c_{2} e^{-t} . \nonumber \]
Second, we find a particular solution of the inhomogeneous equation. The form of the particular solution is chosen such that the exponential will cancel out of both sides of the ode. The ansatz we choose is
\[x(t)=A e^{2 t} \nonumber \]
where \(A\) is a yet undetermined coefficient. Upon substituting \(x\) into the ode, differentiating using the chain rule, and canceling the exponential, we obtain
\[4 A-6 A-4 A=3 \nonumber \]
from which we determine \(A=-1 / 2\) . Obtaining a solution for \(A\) independent of \(t\) justifies the ansatz Equation \ref{8.24}. Third, we write the general solution to the ode as the sum of the homogeneous and particular solutions, and determine \(c_{1}\) and \(c_{2}\) that satisfy the initial conditions. We have
\[x(t)=c_{1} e^{4 t}+c_{2} e^{-t}-\frac{1}{2} e^{2 t} ; \nonumber \]
and taking the derivative,
\[\dot{x}(t)=4 c_{1} e^{4 t}-c_{2} e^{-t}-e^{2 t} . \nonumber \]
Applying the initial conditions,
\[\begin{aligned} &c_{1}+c_{2}-\frac{1}{2}=1 \\ &4 c_{1}-c_{2}-1=0 \end{aligned} \nonumber \]
\[\begin{aligned} c_{1}+c_{2} &=\frac{3}{2} \\ 4 c_{1}-c_{2} &=1 \end{aligned} \nonumber \]
This system of linear equations can be solved for \(c_{1}\) by adding the equations to obtain \(c_{1}=1 / 2\) , after which \(c_{2}=1\) can be determined from the first equation. Therefore, the solution for \(x(t)\) that satisfies both the ode and the initial conditions is given by
\[\begin{aligned} x(t) &=\frac{1}{2} e^{4 t}-\frac{1}{2} e^{2 t}+e^{-t} \\ &=\frac{1}{2} e^{4 t}\left(1-e^{-2 t}+2 e^{-5 t}\right) \end{aligned} \nonumber \]
where we have grouped the terms in the solution to better display the asymptotic behavior for large \(t\) .
We now find particular solutions for some relatively simple inhomogeneous terms using this method of undetermined coefficients.
Find a particular solution of \(\ddot{x}-3 \dot{x}-4 x=2 \sin t\).
Solution
We show two methods for finding a particular solution. The first more direct method tries the ansatz
\[x(t)=A \cos t+B \sin t \nonumber \]
where the argument of cosine and sine must agree with the argument of sine in the inhomogeneous term. The cosine term is required because the derivative of sine is cosine. Upon substitution into the differential equation, we obtain
\[(-A \cos t-B \sin t)-3(-A \sin t+B \cos t)-4(A \cos t+B \sin t)=2 \sin t \nonumber \]
or regrouping terms,
\[-(5 A+3 B) \cos t+(3 A-5 B) \sin t=2 \sin t \nonumber \]
This equation is valid for all \(t\) , and in particular for \(t=0\) and \(\pi / 2\) , for which the sine and cosine functions vanish. For these two values of \(t\) , we find
\[5 A+3 B=0, \quad 3 A-5 B=2 ; \nonumber \]
and solving for \(A\) and \(B\) , we obtain
\[A=\frac{3}{17}, \quad B=-\frac{5}{17} \nonumber \]
The particular solution is therefore given by
\[x_{p}=\frac{1}{17}(3 \cos t-5 \sin t) . \nonumber \]
The second solution method makes use of the relation \(e^{i t}=\cos t+i \sin t\) to convert the sine inhomogeneous term to an exponential function. We introduce the complex function \(z(t)\) by letting
\[z(t)=x(t)+i y(t) \nonumber \]
and rewrite the differential equation in complex form. We can rewrite the equation in one of two ways. On the one hand, if we use \(\sin t=\operatorname{Re}\left\{-i e^{i t}\right\}\) , then the differential equation is written as
\[\ddot{z}-3 \dot{z}-4 z=-2 i e^{i t} ; \nonumber \]
and by equating the real and imaginary parts, this equation becomes the two real differential equations
\[\ddot{x}-3 \dot{x}-4 x=2 \sin t, \quad \ddot{y}-3 \dot{y}-4 y=-2 \cos t . \nonumber \]
The solution we are looking for, then, is \(x_{p}(t)=\operatorname{Re}\left\{z_{p}(t)\right\}\) .
On the other hand, if we write \(\sin t=\operatorname{Im}\left\{e^{i t}\right\}\) , then the complex differential equation becomes
\[\ddot{z}-3 \dot{z}-4 z=2 e^{i t} \nonumber \]
which becomes the two real differential equations
\[\ddot{x}-3 \dot{x}-4 x=2 \cos t, \quad \ddot{y}-3 \dot{y}-4 y=2 \sin t . \nonumber \]
Here, the solution we are looking for is \(x_{p}(t)=\operatorname{Im}\left\{z_{p}(t)\right\}\) .
We will proceed here by solving Equation \ref{8.26}. As we now have an exponential function as the inhomogeneous term, we can make the ansatz
\[z(t)=C e^{i t}, \nonumber \]
where we now expect \(C\) to be a complex constant. Upon substitution into the ode Equation \ref{8.26} and using \(i^{2}=-1\) :
\[-C-3 i C-4 C=2 \nonumber \]
or solving for \(C\) :
\[\begin{aligned} C &=\frac{-2}{5+3 i} \\ &=\frac{-2(5-3 i)}{(5+3 i)(5-3 i)} \\ &=\frac{-10+6 i}{34} \\ &=\frac{-5+3 i}{17} \end{aligned} \nonumber \]
Therefore,
\[\begin{aligned} x_{p} &=\operatorname{Im}\left\{z_{p}\right\} \\ &=\operatorname{Im}\left\{\frac{1}{17}(-5+3 i)(\cos t+i \sin t)\right\} \\ &=\frac{1}{17}(3 \cos t-5 \sin t) \end{aligned} \nonumber \]
Find a particular solution of \(\ddot{x}+\dot{x}-2 x=t^{2}\).
Solution
The correct ansatz here is the polynomial
\[x(t)=A t^{2}+B t+C . \nonumber \]
Upon substitution into the ode, we have
\[2 A+2 A t+B-2 A t^{2}-2 B t-2 C=t^{2} \nonumber \]
\[-2 A t^{2}+2(A-B) t+(2 A+B-2 C) t^{0}=t^{2} . \nonumber \]
Equating powers of \(t\)
\[-2 A=1, \quad 2(A-B)=0, \quad 2 A+B-2 C=0 ; \nonumber \]
and solving,
\[A=-\frac{1}{2}, \quad B=-\frac{1}{2}, \quad C=-\frac{3}{4} \nonumber \]
The particular solution is therefore
\[x_{p}(t)=-\frac{1}{2} t^{2}-\frac{1}{2} t-\frac{3}{4} . \nonumber \]