Skip to main content

Chapter 13 DE5: Non-Homogeneous Second Order Linear DEs

Recall that a 2nd order linear DE is a differential equation of the form
\begin{equation*} P(x)y''+Q(x)y'+R(x)y=f(x) \end{equation*}
If the functions \(P\text{,}\) \(Q\) and \(R\) are all constant functions then the DE is said to have constant coefficients. If \(f(x)=0\) then the DE is said to be homogeneous. In the previous lecture (i.e. Chapter 12) we discussed how to find solutions to a second order linear homogeneous DE with constant coefficients, i.e. to a DE of the form
\begin{equation*} ay''+by'+c=0 \end{equation*}
In this lecture we are going to look at solving some non-homogeneous second order linear DEs with constant coefficients, i.e. DEs of the form
\begin{equation*} ay''+by'+c=f(x) \end{equation*}
Some insight into how we might solve such DEs can be gained by revisiting some relevant first order examples.

Section 13.1 Non-Homogeneous First Order Linear DEs

Non-homogeneous first order linear DEs with constant coefficients take the form
\begin{equation*} ay'+by=f(x) \end{equation*}
We know that we can solve these DEs via an integrating factor, (see section Chapter 11).

Example 13.1.

Find the general solution to the DE
\begin{equation*} y'-y=x \end{equation*}
Answer.
\(y(x)=Ae^x-x-1\)
Solution.
Multiplying both sides of this DE via the integrating factor \(I(x)=e^{\int -1\hspace{2mm}dx}=e^{-x}\) gives
\begin{equation*} \frac{d}{dx}(e^{-x}y)=xe^{-x} \end{equation*}
Using integration by parts gives the general solution as
\begin{equation*} y(x)=Ae^x-x-1 \end{equation*}
There are two interesting facts about this general solution. To discuss these facts write the solution as
\begin{equation*} y(x)=y_c(x)+y_p(x) \end{equation*}
where
\begin{equation*} y_c(x)=Ae^x \textrm{ and } y_p(x)=-x-1 \end{equation*}
The first fact to note is that \(y_c(x)\) is the general solution to the homogeneous equation
\begin{equation*} y'-y=0 \end{equation*}
and \(y_p(x)\) is one particular solution to the original non-homogeneous DE. The second fact to note is that the form of the particular solution \(y_p(x)=-x-1\) is the same as that of the non-homogeneous term \(f(x)=x\text{,}\) that is they are both polynomials of degree \(1\text{.}\)

Example 13.2.

Find the general solution to the DE
\begin{equation*} y'-y=\cos(x) \end{equation*}
Answer.
\(y(x)=Ae^x+\dfrac{1}{2}\sin(x)-\dfrac{1}{2}\cos(x)\)
Solution.
Solving via an integrating factor gives the general solution as
\begin{equation*} y(x)=Ae^x+\frac{1}{2}\sin(x)-\frac{1}{2}\cos(x) \end{equation*}
Once again writing this as
\begin{equation*} y(x)=y_c(x)+y_p(x) \end{equation*}
where
\begin{equation*} y_c(x)=Ae^x \textrm{ and } y_p(x)=\frac{1}{2}\sin(x)-\frac{1}{2}\cos(x) \end{equation*}
we see that \(y_c(x)\) is the general solution to the associated homogeneous DE and that \(y_p(x)\) and \(f(x)\) are both trigonometric functions. In this case it seems reasonable that \(y_c(x)\) contains both a \(\cos(x)\) term and a \(\sin(x)\) since to satisfy the DE we would expect the particular solution to contain terms like \(f(x)=\cos(x)\) and its derivative \(f'(x)=-\sin(x)\text{.}\)

Example 13.3.

Find the general solution to the DE
\begin{equation*} y'-y=e^x \end{equation*}
Answer.
\(y(x)=Ae^x+xe^x\)
Solution.
The general solution to this DE, found via an integrating factor, is
\begin{equation*} y(x)=Ae^x+xe^x \end{equation*}
Letting
\begin{equation*} y_c(x)=Ae^x \textrm{ and } y_p(x)=xe^x \end{equation*}
we see that, once again, \(y_c(x)\) is the general solution to the associated homogeneous DE but this time \(y_p(x)\) is not quite the same form as \(f(x)\text{.}\) The difference in this case from the previous two examples is that here \(f(x)\) is the same form as \(y_c(x)\text{,}\) the solution to the homogeneous DE and hence \(y_p(x)\) can’t also be of this form.
The above examples all illustrate the following more general result.

Definition 13.4.

The general solution to the non-homogeneous first order linear DE with constant coefficients
\begin{equation*} ay'+by=f(x) \end{equation*}
is
\begin{equation*} y(x)=y_c(x)+y_p(x) \end{equation*}
where \(y_c(x)\) is the general solution to the associated homogeneous DE
\begin{equation*} ay'+by=0 \end{equation*}
and \(y_p(x)\) is any particular solution to non-homogeneous DE.

Exercises Example Tasks

1.
If \(y_c(x)\) is the general solution to
\begin{equation*} ay'+by=0 \end{equation*}
and \(y_p(x)\) is any particular solution to
\begin{equation*} ay'+by=f(x) \end{equation*}
show that
\begin{equation*} y(x)=y_c(x)+y_p(x) \end{equation*}
is also a solution to
\begin{equation*} ay'+by=f(x) \end{equation*}

Section 13.2 The Method of Undetermined Coefficients

We return now to the problem of finding solutions to non-homogeneous second order linear DEs with constant coefficients, i.e. to DEs of the form
\begin{equation*} ay''+by'+cy=f(x) \end{equation*}
Since we don’t have any alternative method (such as using an integrating factor) for finding a solution to this class of DE we are forced to use the method suggested by the previous section.

Definition 13.5.

The general solution to the non-homogeneous second order linear DE with constant coefficients
\begin{equation*} ay''+by'+cy=f(x) \end{equation*}
is
\begin{equation*} y(x)=y_c(x)+y_p(x) \end{equation*}
where \(y_c(x)\text{,}\) the complementary solution, is the general solution to the associated homogeneous DE
\begin{equation*} ay''+by'+cy=0 \end{equation*}
and \(y_p(x)\) is any particular solution to non-homogeneous DE.
It is easy to show that \(y(x)=y_c(x)+y_p(x)\) is a solution to the non-homogeneous DE but how do we know that we have found all such solutions, i.e. that we have found the general solution? (After all, \(y_p(x)\) is just one particular solution.) Let \(\phi(x)\) be any solution to the DE
\begin{equation*} ay''+by'+cy=f(x) \end{equation*}
Then the function \(g(x)=\phi(x)-y_p(x)\) is a solution to the homogeneous DE
\begin{equation*} ay''+by'+cy=0 \end{equation*}
since
\begin{align*} ag''+bg'+cg \amp = a(\phi''-y_p'')+b(\phi'-y_p')+c(\phi-y_p)\\ \amp = (a\phi''+b\phi'+c\phi)-(ay_p''+by_p'+cy_p)\\ \amp = f(x)-f(x)\\ \amp =0 \end{align*}
Now since \(y_c(x)\) is the general solution to the homogeneous DE, \(g(x)\) must be one of the solutions in \(y_c(x)\text{.}\) Thus \(\phi(x)=g(x)+y_p(x)\) must be one of the solutions in \(y(x)=y_c(x)+y_p(x)\text{,}\) or to put it the other way, \(y(x)=y_c(x)+y_p(x)\) contains all solutions to the non-homogeneous DE.
Thus to solve a non-homogeneous second order DE with constant coefficients we have to first find the complementary solution, then find any particular solution and then add these solutions together. We already know how to find the complementary solution (see Chapter 12) so all that remains is to work out how to find a particular solution, \(y_p\text{.}\) The method of undetermined coefficients tries to find \(y_p\) by guessing that the form that \(y_p\) should take is a linear combination of the non-homogeneous term, \(f(x)\text{,}\) and its derivatives.

Example 13.6.

Find a particular solution to the DE
\begin{equation*} y''+2y'-3y=4x^2 \end{equation*}
Answer.
\(y_p(x)=-\dfrac{4}{3}x^2-\dfrac{16}{9}x-\dfrac{56}{27}\)
Solution.
Here the non-homogeneous term is \(f(x)=4x^2\text{.}\) This is a 2nd degree polynomial. The first and second derivatives of this will be a linear polynomial and a constant respectively. Thus we guess that a particular solution can found of the form
\begin{equation} y_p(x)=Ax^2+Bx+C\tag{13.1} \end{equation}
where \(A\text{,}\) \(B\) and \(C\) are coefficients to be determined by substituting into the DE. Now, from (13.1)
\begin{equation*} y_p'=2Ax+B \end{equation*}
\begin{equation*} y_p''=2A \end{equation*}
Substituting into the DE gives
\begin{align*} y_p''+2y_p'-3y_p \amp = 4x^2\\ (2A)+2(2Ax+B)-3(Ax^2+Bx+C)\amp = 4x^2\\ (-3A)x^2+(4A-3B)x+(2A+2B-3C)\amp = 4x^2 \end{align*}
Thus for \(y_p\) to be a solution
\begin{align*} -3A \amp = 4\\ 4A-3B \amp = 0\\ 2A+2B-3C \amp = 0 \end{align*}
Solving these equations gives
\begin{equation*} A=-\frac{4}{3}, \hspace{5mm} B=-\frac{16}{9}, \hspace{5mm} C=-\frac{56}{27} \end{equation*}
Thus a particular solution to the DE is
\begin{equation*} y_p(x)=-\frac{4}{3}x^2-\frac{16}{9}x-\frac{56}{27} \end{equation*}
The method of undetermined coefficients is only useful for finding the particular solution when the non-homogeneous term is fairly simple. Table 13.7 gives a guide to the form of the particular solution, \(y_p\text{,}\) to try for various non-homogeneous terms \(f\text{.}\)
Table 13.7.
Non-Homogenous Term Form of Particular Solution
\(f(x)=ae^{kx}\) \(y_p(x)=Ce^{kx}\)
\(f(x)=a\sin(kx)\) \(y_p(x)=C_1\sin(kx)+C_2\cos(kx)\)
\(f(x)=a\cos(kx)\) \(y_p(x)=C_1\sin(kx)+C_2\cos(kx)\)
\(f(x)=\sum_{i=0}^{n} a_{n-i}x^{n-i}\) \(y_p(x)=\sum_{i=0}^{n} C_{n-i}x^{n-i}\)
\(f(x)\) \(y_p(x)\) is a linear combination of \(f(x)\) and its derivatives, i.e. \(y_p(x)=\sum_{k=0} C_kf^{(k)}(x)\)

Example 13.8.

Find the general solution to
\begin{equation*} x''+6x'+8x=8\sin(2t) \end{equation*}
Answer.
\(x(t)=Ae^{-2t}+Be^{-4t}+\dfrac{1}{5}\sin(2t)-\dfrac{3}{5}\cos(2t)\)
Solution.
The first step is to find the general solution to the homogeneous DE
\begin{equation*} x''+6x'+8x=0 \end{equation*}
The characteristic equation for this DE is
\begin{equation*} r^2+6r+8=0 \end{equation*}
which has solutions
\begin{equation*} r=-2, -4 \end{equation*}
Thus the complementary solution is
\begin{equation*} x_c(t)=Ae^{-2t}+Be^{-4t} \end{equation*}
The next step is to find a particular solution to the non-homogeneous DE. Using the method of undetermined coefficients we try a particular solution of the form
\begin{equation*} x_p(t)=C_1\sin(2t)+C_2\cos(2t) \end{equation*}
where \(C_1\) and \(C_2\) are the coefficients to be determined. Now
\begin{align*} x_p'(t) \amp = 2C_1\cos(2t)-2C_2\sin(2t)\\ x_p''(t) \amp = -4C_1\sin(2t)-4C_2\cos(2t) \end{align*}
For \(x_p(t)\) to be a solution
\begin{equation*} x_p''+6x_p'+8x_p=8\sin(2t) \end{equation*}
and so, on substituting
\begin{equation*} (-4C_1\sin(2t)-4C_2\cos(2t))+6(2C_1\cos(2t)-2C_2\sin(2t))+8(C_1\sin(2t)+C_2\cos(2t)) = 8\sin(2t) \end{equation*}
which simplifies to
\begin{equation*} (4C_1-12C_2)\sin(2t)+(12C_1+4C_2)\cos(2t) = 8\sin(2t) \end{equation*}
Equating coefficients on each side of the equation gives
\begin{align*} 4C_1-12C_2 \amp = 8\\ 12C_1+4C_2 \amp = 0 \end{align*}
Solving these equations gives
\begin{equation*} C_1=\frac{1}{5}, \hspace{5mm} C_2=-\frac{3}{5} \end{equation*}
and so a particular solution is
\begin{equation*} x_p(t)=\frac{1}{5}\sin(2t)-\frac{3}{5}\cos(2t) \end{equation*}
Combining the particular solution with the complementary solution gives the general solution
\begin{equation*} x(t)=Ae^{-2t}+Be^{-4t}+\frac{1}{5}\sin(2t)-\frac{3}{5}\cos(2t) \end{equation*}

Example 13.9.

Solve the initial-value problem
\begin{equation*} y''+3y'=5e^{2x} \end{equation*}
\begin{equation*} y(0)=1,\hspace{5mm} y'(0)=-2 \end{equation*}
Answer.
\(y(x)=e^{-3x}+\dfrac{1}{2}e^{2x}-\dfrac{1}{2}\)
Solution.
To solve the initial-value problem we have to begin by finding the general solution to the DE. Since this DE is a non-homogeneous second order DE with constant coefficients we have to first find the general solution to the associated homogeneous DE
\begin{equation*} y''+3y'=0 \end{equation*}
The characteristic equation for this DE is
\begin{equation*} r^2+3r=0 \end{equation*}
which has solutions
\begin{equation*} r=0, -3 \end{equation*}
Thus the complementary solution is
\begin{equation*} y_c(x)=A+Be^{-3x} \end{equation*}
For the particular solution try a function of the form
\begin{equation*} y_p(x)=Ce^{2x} \end{equation*}
Then
\begin{align*} y_p'(x) \amp =2Ce^{2x}\\ y_p''(x) \amp=4Ce^{2x} \end{align*}
For this to be a solution
\begin{equation*} y_p''+3y_p'=5e^{2x} \end{equation*}
and so
\begin{align*} 4Ce^{2x}+3(2Ce^{2x}) \amp =5e^{2x}\\ 10Ce^{2x} \amp=5e^{2x} \end{align*}
On equating coefficients on both sides of this equation
\begin{equation*} 10C=5\Rightarrow C=\frac{1}{2} \end{equation*}
Combining the complementary solution and this particular solution gives the general solution as
\begin{equation*} y(x)=A+Be^{-3x}+\frac{1}{2}e^{2x} \end{equation*}
On using the initial condition \(y(0)=1\) we find
\begin{equation*} A+B=\frac{1}{2} \end{equation*}
Since
\begin{equation*} y'(x)=-3Be^{-3x}+e^{2x} \end{equation*}
on using the initial condition \(y'(0)=2\) we find
\begin{equation*} B=1 \end{equation*}
Thus \(A=-\frac{1}{2}, B=1\) and the solution to the initial-value problem is
\begin{equation*} y(x)=e^{-3x}+\frac{1}{2}e^{2x}-\frac{1}{2} \end{equation*}
If the non-homogeneous term \(f\) is itself a solution to the associated homogeneous DE then the form that we guess for the particular solution has to change. Guided by our experience from non-homogeneous first order constant coefficient DEs (see Example 13.3) what we try for the particular solution is to multiply the usual form by \(x\) (or \(x^2\text{,}\) \(x^3\) etc. if necessary) so that no term in the particular solution is itself a solution to the homogeneous DE.

Example 13.10.

Find the general solution to
\begin{equation*} \frac{d^2u}{dt^2}+\frac{du}{dt}-2u=e^t \end{equation*}
Answer.
\(u(t)=Ae^t+Be^{-2t}+\dfrac{1}{3}te^t\)
Solution.
The general solution to the associated homogeneous DE, i.e.
\begin{equation*} \frac{d^2u}{dt^2}+\frac{du}{dt}-2u=0 \end{equation*}
is the complementary solution to the given DE. Thus
\begin{equation*} u_c(t)=Ae^t+Be^{-2t} \end{equation*}
We can see here that the non-homogeneous term \(f(x)=e^x\) is a solution to the homogeneous DE (put \(A=1\) and \(B=0\) into \(u_c(t)\)). Obviously then, trying a particular solution of the form
\begin{equation*} u_p(t)=Ce^t \end{equation*}
will not work. Thus we try instead a solution of the form
\begin{equation*} u_p(t)=Cte^t \end{equation*}
For this function, using the product rule
\begin{equation*} \frac{du_p}{dt}=Cte^t+Ce^t \end{equation*}
and
\begin{equation*} \frac{d^2u_p}{dt^2}=Cte^t+2Ce^t \end{equation*}
Substituting into the DE gives
\begin{align*} (Cte^t+2Ce^t)+(Cte^t+Ce^t)-2(Cte^t) \amp =e^t\\ 3Ce^t \amp =e^t \end{align*}
Notice that the \(te^t\) terms will cancel out and so on equating the coefficients of the \(e^t\) terms gives
\begin{equation*} C=\frac{1}{3} \end{equation*}
Thus, a particular solution is
\begin{equation*} u_p(t)=\frac{1}{3}te^t \end{equation*}
and hence the general solution is
\begin{equation*} u(t)=Ae^t+Be^{-2t}+\frac{1}{3}te^t \end{equation*}

Example 13.11.

Solve the initial-value problem
\begin{equation*} y''+y'=x \end{equation*}
\begin{equation*} y(0)=1,\hspace{5mm} y'(0)=1 \end{equation*}
Answer.
\(y(x)=3-2e^{-x}+\dfrac{1}{2}x^2-x\)
Solution.
The associated homogeneous DE is
\begin{equation*} y''+y'=0 \end{equation*}
Thus the complementary solution is
\begin{equation*} y_c(x)=Ae^{-x}+B \end{equation*}
Since the non-homogeneous term is \(f(x)=x\) the usual form that we would try for the particular solution would be
\begin{equation*} y_p(x)=C_1x+C_2 \end{equation*}
However this contains a constant term and we can see from the complementary solution (put \(A=0\)) that a constant will satisfy the homogeneous DE. Thus the constant term in the particular solution will not work and we must modify the particular solution. So instead try a particular solution of the form
\begin{equation*} y_p(x)=C_1x^2+C_2x \end{equation*}
Thus
\begin{align*} y_p'(x) \amp=2C_1x+C_2\\ y_p''(x) \amp=2C_1 \end{align*}
Substituting into the DE gives
\begin{align*} (2C_1)+(2C_1x+C_2) \amp =x\\ (2C_1)x+(2C_1+C_2) \amp =x \end{align*}
Equating coefficients yields
\begin{align*} 2C_1 \amp =1\\ 2C_1+C_2 \amp =0 \end{align*}
and hence
\begin{equation*} C_1=\frac{1}{2},\hspace{5mm} C_2=-1 \end{equation*}
Thus, a particular solution is
\begin{equation*} y_p(x)=\frac{1}{2}x^2-x \end{equation*}
and hence the general solution is
\begin{equation*} y(x)=Ae^{-x}+B+\frac{1}{2}x^2-x \end{equation*}
To solve the initial-value problem we need the derivative of \(y\) which is
\begin{equation*} y'(x)=-Ae^{-x}+2x-1 \end{equation*}
Using \(y(0)=1\)
\begin{equation*} A+B=1 \end{equation*}
Using \(y'(0)=1\)
\begin{equation*} -A-1=1 \end{equation*}
Thus
\begin{equation*} A=-2,\hspace{5mm} B=3 \end{equation*}
and the solution is
\begin{equation*} y(x)=3-2e^{-x}+\frac{1}{2}x^2-x \end{equation*}

Exercises Example Tasks

1.
Find the general solution to the DE
\begin{equation*} y''+3y'-10y=10x^2+4x \end{equation*}
2.
Find the general solution to the DE
\begin{equation*} r''+r=\sin(x) \end{equation*}
3.
Solve the initial value problem
\begin{equation*} y''-y'-6y=\sinh(x),\hspace{5mm}y(0)=1,\hspace{5mm}y'(0)=0 \end{equation*}
4.
Find the general solution to the DE
\begin{equation*} u''+u'=xe^x+3\sin(x) \end{equation*}