4.5: Inhomogeneous ODEs
We now consider the general inhomogeneous linear second-order ode (4.1) :
\[\label{eq:1}\overset{..}{x}+p(t)\overset{.}{x}+q(t)x=g(t),\] with initial conditions \(x(t_0) = x_0\) and \(\overset{.}{x}(t_0) = 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 \[\label{eq:2}\overset{..}{x}+p(t)\overset{.}{x}+q(t)x=0.\]
Let us denote the homogeneous solution by \[x_h(t)=c_1X_1(t)+c_2X_2(t),\nonumber\] where \(X_1\) and \(X_2\) are linearly independent solutions of \(\eqref{eq:2}\), and \(c_1\) and \(c_2\) are as yet undetermined constants. (ii) Find any particular solution \(x_p\) of the inhomogeneous equation \(\eqref{eq:1}\). 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 \(\eqref{eq:1}\) as the sum of the homogeneous and particular solutions, \[\label{eq:3}x(t)=x_h(t)+x_p(t),\] and apply the initial conditions to determine the constants \(c_1\) and \(c_2\). Note that because of the linearity of \(\eqref{eq:1}\), \[\begin{aligned}\overset{..}{x}+p\overset{.}{x}+qx&=\frac{d^2}{dt^2}(x_h+x_p)+p\frac{d}{dt}(x_h+x_p)+q(x_h+x_p) \\ &=(\overset{..}{x}_h+p\overset{.}{x}_h+qx_h)+(\overset{..}{x}_p+p\overset{.}{x}_p+qx_p) \\ &=0+g \\ &=g,\end{aligned}\] so that \(\eqref{eq:3}\) solves \(\eqref{eq:1}\), 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 \(\overset{..}{x}-3\overset{.}{x}-4x=3e^{2t}\) with \(x(0)=1\) and \(\overset{.}{x}(0)=0\).
Solution
First, we solve the homogeneous equation. The characteristic equation is \[\begin{aligned}r^2-3r-4&=(r-4)(r+1) \\ &=0,\end{aligned}\] so that \[x_h(t)=c_1e^{4t}+c_2e^{-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 \[\label{eq:4} x(t)=Ae^{2t},\] where \(A\) is a yet undetermined coefficient. Upon substituting \(x\) into the ode, differentiating using the chain rule, and canceling the exponential, we obtain \[4A-6A-4A=3,\nonumber\] from which we determine \(A = −1/2\). Obtaining a solution for \(A\) independent of \(t\) justifies the ansatz \(\eqref{eq:4}\). 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_1e^{4t}+c_2e^{-t}-\frac{1}{2}e^{2t};\nonumber\] and taking the derivative, \[\overset{.}{x}(t)=4c_1e^{4t}-c_2e^{-t}-e^{2t}.\nonumber\]
Applying the initial conditions, \[\begin{aligned}c_1+c_2-\frac{1}{2}&=1, \\ 4c_1-c_2-1&=0;\end{aligned}\] or \[\begin{aligned}c_1+c_2&=\frac{3}{2}, \\ 4c_1-c_2&=1.\end{aligned}\]
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^{4t}-\frac{1}{2}e^{2t}+e^{-t} \\ &=\frac{1}{2}e^{4t}\left(1-e^{-2t}+2e^{-5t}\right),\end{aligned}\] 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 \(\overset{..}{x}-3\overset{.}{x}-4x=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, \[-(5A+3B)\cos t+(3A-5B)\sin t=2\sin t.\nonumber\]
This equation is valid for all \(t\), and in particular for \(t = 0\) and \(π/2\), for which the sine and cosine functions vanish. For these two values of \(t\), we find \[5A+3b=0,\quad 3A-5B=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^{it} = \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)+iy(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 = \text{Re}\{−ie^{it}\}\), then the differential equation is written as \[\label{eq:5}\overset{..}{z}-3\overset{.}{z}-4z=-2ie^{it};\] and by equating the real and imaginary parts, this equation becomes the two real differential equations \[\overset{..}{x}-3\overset{.}{x}-4x=2\sin t,\quad\overset{..}{y}-3\overset{.}{y}-4y=-2\cos t.\nonumber\]
The solution we are looking for, then, is \(x_p(t) = \text{Re}\{z_p(t)\}\).
On the other hand, if we write \(\sin t = \text{Im}\{e^{it}\}\), then the complex differential equation becomes \[\label{eq:6}\overset{..}{z}-3\overset{.}{z}-4z=2e^{it},\] which becomes the two real differential equations \[\overset{..}{x}-3\overset{.}{x}-4x=2\cos t,\quad\overset{..}{y}-3\overset{.}{y}-4y=2\sin t.\nonumber\]
Here, the solution we are looking for is \(x_p(t) = \text{Im}\{z_p(t)\}\).
We will proceed here by solving \(\eqref{eq:6}\). As we now have an exponential function as the inhomogeneous term, we can make the ansatz \[z(t)=Ce^{it},\nonumber\] where we now expect \(C\) to be a complex constant. Upon substitution into the ode \(\eqref{eq:6}\) and using \(i^{2} = −1\):
\[-C-3iC-4C=2;\nonumber\] or solving for \(C\):
\[\begin{aligned}C&=\frac{-2}{5+3i} \\ &=\frac{-2(5-3i)}{(5+3i)(5-3i)} \\ &=\frac{-10+6i}{34} \\ &=\frac{-5+3i}{17}.\end{aligned}\]
Therefore, \[\begin{aligned}x_p&=\text{Im}\{z_p\} \\ &=\text{Im}\left\{\frac{1}{17}(-5+3i)(\cos t+i\sin t)\right\} \\ &=\frac{1}{17}(3\cos t-5\sin t).\end{aligned}\]
Find a particular solution of \(\overset{..}{x}+\overset{.}{x}-2x=t^2\).
Solution
The correct ansatz here is the polynomial \[x(t)=At^2+Bt+C.\nonumber\]
Upon substitution into the ode, we have \[2A+2At+B-2At^2-2Bt-2C=t^2,\nonumber\] or \[-2At^2+2(A-B)t+(2A+B-2C)t^0=t^2.\nonumber\]
Equating powers of \(t\), \[-2A=1,\quad 2(A-B)=0,\quad 2A+B-2C=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\]