Nonhomogeneous Linear Equations

Learning Objectives

  • Write the general solution to a nonhomogeneous differential equation.
  • Solve a nonhomogeneous differential equation by the method of undetermined coefficients.
  • Solve a nonhomogeneous differential equation by the method of variation of parameters.

General Solution to a Nonhomogeneous Linear Equation

Consider the nonhomogeneous linear differential equation

[latex]\large{a_2(x)y^{\prime\prime}+a_1(x)y^\prime+a_0(x)y=r(x)}[/latex].

The associated homogeneous equation

[latex]\large{a_2(x)y^{\prime\prime}+a_1(x)y^\prime+a_0(x)y=0}[/latex]

is called the complementary equation. We will see that solving the complementary equation is an important step in solving a nonhomogeneous differential equation.

definition


A solution [latex]y_p(x)[/latex] of a differential equation that contains no arbitrary constants is called a particular solution to the equation.

Theorem: general solution to a nonhomogeneous equation


Let [latex]y_p(x)[/latex] be any particular solution to the nonhomogeneous linear differential equation

[latex]\large{a_2(x)y^{\prime\prime}+a_1(x)y^\prime+a_0(x)y=r(x)}[/latex].

Also, let [latex]c_1y_1(x)+c_2y_2(x)[/latex] denote the general solution to the complementary equation. Then, the general solution to the nonhomogeneous equation is given by

[latex]\large{y(x)=c_1y_1(x)+c_2y_2(x)+y_p(x)}[/latex].

Proof

To prove [latex]y(x)[/latex] is the general solution, we must first show that it solves the differential equation and, second, that any solution to the differential equation can be written in that form. Substituting [latex]y(x)[/latex] into the differential equation, we have

[latex]\begin{aligned} a_2(x)y^{\prime\prime}+a_1(x)y^\prime+a_0(x)y&=a_2(x)(c_1y_1+c_2y_2+y_p)^{\prime\prime}+a_1(x)(c_1y_1+c_2y_2+y_p)^\prime+a_0(x)(c_1y_1+c_2y_2+y_p) \\ &=[a_2(x)(c_1y_1+c_2y_2)^{\prime\prime}+a_1(x)(c_1y_1+c_2y_2)^\prime+a_0(x)(c_1y_1+c_2y_2)]+a_2(x)y_p^{\prime\prime}+a_1(x)y_p^\prime+a_0(x)y_p \\ &=0+r(x) \\ &=r(x) \end{aligned}[/latex].

So [latex]y(x)[/latex] is a solution.

Now, let [latex]z(x)[/latex] be any solution to [latex]a_2(x)y^{\prime\prime}+a_1(x)y^\prime+a_0(x)y=r(x)[/latex]. Then

[latex]\begin{aligned} a_2(x)(z-y_p)^{\prime\prime}+a_1(x)(z-y_p)^\prime+a_0(x)(z-y_p)&=(a_2(x)z^{\prime\prime}+a_1(x)z^\prime+a_0(x)z)-(a_2(x)y_p^{\prime\prime}+a_1(x)y_p^\prime+a_0(x)y_p) \\ &=r(x)-r(x) \\ &=0 \end{aligned}[/latex],

so [latex]z(x)=y_p(x)[/latex] is a solution to the complementary equation. But, [latex]c_1y_1(x)+c_2y_2(x)[/latex] is the general solution to the complementary equation, so there are constants [latex]c_1[/latex] and [latex]c_2[/latex] such that

[latex]\large{z(x)=y_p(x)=c_1y_1(x)+c_2y_2(x)}[/latex].

Hence, we see that [latex]z(x)=c_1y_1(x)+c_2y_2(x)y_p(x)[/latex].

[latex]_\blacksquare[/latex]

Example: verifying the general solution

Given that [latex]y_p(x)=x[/latex] is a particular solution to the differential equation [latex]y^{\prime\prime}+y=x[/latex], write the general solution and check by verifying that the solution satisfies the equation.

try it

Given that [latex]y_p(x)=-2[/latex] is a particular solution to [latex]y^{\prime\prime}-3y^\prime-4y=8[/latex], write the general solution and verify that the general solution satisfies the equation.

In the preceding section, we learned how to solve homogeneous equations with constant coefficients. Therefore, for nonhomogeneous equations of the form [latex]ay^{\prime\prime}+by^\prime+cy=r(x)[/latex], we already know how to solve the complementary equation, and the problem boils down to finding a particular solution for the nonhomogeneous equation. We now examine two techniques for this: the method of undetermined coefficients and the method of variation of parameters.

Undetermined Coefficients

The method of undetermined coefficients involves making educated guesses about the form of the particular solution based on the form of [latex]r(x)[/latex]. When we take derivatives of polynomials, exponential functions, sines, and cosines, we get polynomials, exponential functions, sines, and cosines. So when [latex]r(x)[/latex] has one of these forms, it is possible that the solution to the nonhomogeneous differential equation might take that same form. Let’s look at some examples to see how this works.

Example: undetermined coefficients when [latex]r(x)[/latex] is a polynomial

Find the general solution to [latex]y^{\prime\prime}+4y^\prime+3y=3x[/latex].

In Example “Undetermined Coefficients When [latex]𝑟(𝑥)[/latex] Is a Polynomial”, notice that even though [latex]r(x)[/latex] did not include a constant term, it was necessary for us to include the constant term in our guess. If we had assumed a solution of the form [latex]y_p=Ax[/latex] (with no constant term), we would not have been able to find a solution. (Verify this!) If the function [latex]r(x)[/latex] is a polynomial, our guess for the particular solution should be a polynomial of the same degree, and it must include all lower-order terms, regardless of whether they are present in [latex]r(x)[/latex].

Example: undetermined coefficients when [latex]r(x)[/latex] is an exponential

Find the general solution to [latex]y^{\prime\prime}-y^\prime-2y=2e^{3x}[/latex].

try it

Find the general solution to [latex]y^{\prime\prime}-4y^\prime+4y=7\sin t-\cos t[/latex].

Watch the following video to see the worked solution to the above Try It

You can view the transcript for “CP 7.11” here (opens in new window).
In the previous checkpoint, [latex]r(x)[/latex] included both sine and cosine terms. However, even if [latex]r(x)[/latex] included a sine term only or a cosine term only, both terms must be present in the guess. The method of undetermined coefficients also works with products of polynomials, exponentials, sines, and cosines. Some of the key forms of [latex]r(x)[/latex] and the associated guesses for [latex]y_p(x)[/latex] are summarized in Table 7.2 Key Forms for the Method of Undetermined Coefficients below.

[latex]r(x)[/latex] Initial guess for [latex]y_p(x)[/latex]
[latex]k[/latex] (a constant) [latex]A[/latex] (a constant)
[latex]ax+b[/latex] [latex]Ax+B[/latex] (Note: The guess must include both terms even if [latex]b=0[/latex].)
[latex]ax^{2}+bx+c[/latex] [latex]Ax^{2}+Bx+C[/latex] (Note: The guess must include all three terms even if [latex]b[/latex] or [latex]c[/latex] are zero.)
Higher-order polynomials Polynomial of the same order as [latex]r(x)[/latex]
[latex]ae^{\lambda x}[/latex] [latex]Ae^{\lambda x}[/latex]
[latex]a\cos\beta x+b\sin\beta x[/latex] [latex]A\cos\beta x+B\sin\beta x[/latex] (Note: The guess must include both terms even if either [latex]a=0[/latex] or [latex]b=0[/latex].)
[latex]ae^{\alpha x}\cos\beta x+be^{\alpha x}\sin\beta x[/latex] [latex]Ae^{\alpha x}\cos\beta x+Be^{\alpha x}\sin\beta x[/latex]
[latex](ax^2+bx+c)e^{\lambda x}[/latex] [latex](Ax^2+Bx+C)e^{\lambda x}[/latex]
[latex](a_2x^2+a_1x+a_0)\cos\beta x+(b_2x^2+b_1x+b_0)\sin\beta x[/latex] [latex](A_2x^2+A_1x+A_0)\cos\beta x+(B_2x^2+B_1x+B_0)\sin\beta x[/latex]
[latex](a_2x^2+a_1x+a_0)e^{\alpha x}\cos\beta x+(b_2x^2+b_1x+b_0)e^{\alpha x}\sin\beta x[/latex] [latex](A_2x^2+A_1x+A_0)e^{\alpha x}\cos\beta x+(B_2x^2+B_1x+B_0)e^{\alpha x}\sin\beta x[/latex]
Table 7.2 Key Forms for the Method of Undetermined Coefficients

Keep in mind that there is a key pitfall to this method. Consider the differential equation [latex]y^{\prime\prime}+5y^\prime+6y=3e^{-2x}[/latex]. Based on the form of [latex]r(x)[/latex], we guess a particular solution of the form [latex]y_p(x)=Ae^{-2x}[/latex]. But when we substitute this expression into the differential equation to find a value for [latex]A[/latex], we run into a problem. We have

[latex]\large{y_p^\prime(x)=-2Ae^{-2x}}[/latex]

and

[latex]\large{y_p^{\prime\prime}=4Ae^{-2x}}[/latex],

so we want

[latex]\begin{aligned} y^{\prime\prime}+5y^\prime+6y&=3e^{-2x} \\ 4Ae^{-2x}+\left(-2Ae^{-2x}\right)+6Ae^{-2x}&=3e^{-2x} \\ 4Ae^{-2x}-10Ae^{-2x}+6Ae^{-2x}&=3e^{-2x} \\ 0&=3e^{-2x} \end{aligned}[/latex],

which is not possible.

Looking closely, we see that, in this case, the general solution to the complementary equation is [latex]c_1e^{-2x}+c_2e^{-2x}[/latex]. The exponential function in [latex]r(x)[/latex] is actually a solution to the complementary equation, so, as we just saw, all the terms on the left side of the equation cancel out. We can still use the method of undetermined coefficients in this case, but we have to alter our guess by multiplying it by [latex]x[/latex]. Using the new guess, [latex]y_p(x)=Ae^{-2x}[/latex], we have

[latex]\large{y_p^\prime(x)=A\left(e^{-2x}-2xe^{-2x}\right)}[/latex]

and

[latex]\large{y_p^{\prime\prime}(x)=-4Ae^{-2x}+4Axe^{-2x}}[/latex].

Substitution gives

[latex]\begin{aligned} y^{\prime\prime}+5y^\prime+6y&=3e^{-2x} \\ \left(-4Ae^{-2x}+4Axe^{-2x}\right)+5\left(Ae^{-2x}-2Axe^{-2x}\right)+6Axe^{-2x}&=3e^{-2x} \\ -4Ae^{-2x}+4Axe^{-2x}-10Axe^{-2x}+6Axe^{-2x}&=3e^{-2x} \\ Ae^{-2x}&=3e^{-2x} \end{aligned}[/latex],

So, [latex]A=3[/latex] and [latex]y_p(x)=3xe^{-2x}[/latex]. This gives us the following general solution

[latex]\large{y(x)=c_1e^{-2x}+c_2e^{-2x}+3xe^{-2x}}[/latex].

Note that if [latex]xe^{-2x}[/latex] were also a solution to the complementary equation, we would have to multiply by [latex]x[/latex] again, and we would try [latex]y_p(x)=Ax^2e^{-2x}[/latex].

problem-solving strategy: method of undetermined coefficients

  1. Solve the complementary equation and write down the general solution.
  2. Based on the form of [latex]r(x)[/latex], make an initial guess for [latex]y_p(x)[/latex].
  3. Check whether any term in the guess for [latex]y_p(x)[/latex] is a solution to the complementary equation. If so, multiply the guess by [latex]x[/latex]. Repeat this step until there are no terms in [latex]y_p(x)[/latex] that solve the complementary equation.
  4. Substitute [latex]y_p(x)[/latex] into the differential equation and equate like terms to find values for the unknown coefficients in [latex]y_p(x)[/latex]
  5. Add the general solution to the complementary equation and the particular solution you just found to obtain the general solution to the nonhomogeneous equation.

example: solving nonhomogeneous equations

Find the general solutions to the following differential equations.

  1. [latex]y^{\prime\prime}-9y=-6\cos 3x[/latex]
  2. [latex]x^{\prime\prime}+2x'+x=4e^{-t}[/latex]
  3. [latex]y^{\prime\prime}-2y^\prime+5y=10^{2}-3x-3[/latex]
  4. [latex]y^{\prime\prime}-3y^\prime=-12t[/latex]

try it

Find the general solution to the following differential equations.

  1. [latex]y^{\prime\prime}-5y^\prime+4y=3e^x[/latex]
  2. [latex]y^{\prime\prime}+y^\prime-6y=52\cos2t[/latex]

Variation of Parameters

Sometimes, [latex]r(x)[/latex] is not a combination of polynomials, exponentials, or sines and cosines. When this is the case, the method of undetermined coefficients does not work, and we have to use another approach to find a particular solution to the differential equation. We use an approach called the method of variation of parameters.

To simplify our calculations a little, we are going to divide the differential equation through by [latex]a[/latex], so we have a leading coefficient of 1. Then the differential equation has the form

[latex]y^{\prime\prime}+py^\prime+qy=r(x)[/latex],

where [latex]p[/latex] and [latex]q[/latex] are constants.

If the general solution to the complementary equation is given by [latex]c_1y_1(x)+c_2y_2(x)[/latex], we are going to look for a particular solution of the form [latex]y_p(x)=u(x)y_1(x)+v(x)y_2(x)[/latex]. In this case, we use the two linearly independent solutions to the complementary equation to form our particular solution. However, we are assuming the coefficients are functions of [latex]x[/latex], rather than constants. We want to find functions [latex]u(x)[/latex] and [latex]v(x)[/latex] such that [latex]y_p(x)[/latex] satisfies the differential equation. We have

[latex]\begin{aligned} y_p&=uy_1+vy_2 \\ y_p^\prime&=u^\prime+uy_1^\prime+v^\prime y_2+vy_2^\prime \\ y_p^{\prime\prime}&=(u^\prime y_1+v^\prime y_2)^\prime+u^\prime y_1^\prime+uy_1^{\prime\prime}+v^\prime y_2^\prime+vy_2^{\prime\prime} \end{aligned}[/latex].

Substituting into the differential equation, we obtain

[latex]\begin{aligned} y_p^{\prime\prime}+py_p^\prime+qy_p&=[(u^\prime y_1+v^\prime y_2)+u^\prime y_1^\prime+uy_1^{\prime\prime}+v^\prime y_2^\prime+vy_2^{\prime\prime}]+p[u^\prime y_1+uy_1^\prime+v^\prime y_2+vy_2^\prime]+q[uy_1+vy_2] \\ &=u[y_1^{\prime\prime}+py_1^\prime+qy_1]+v[y_2^{\prime\prime}+py_2^\prime+qy_2]+(u^\prime y_1+v^\prime y_2)^\prime+p(u^\prime y_1+v^\prime y_2)+(u^\prime y_1^\prime+v^\prime y_2^\prime) \end{aligned}[/latex].

Note that [latex]y_1[/latex] and [latex]y_2[/latex] are solutions to the complementary equation, so the first two terms are zero. Thus, we have

[latex](u^\prime y_1+v^\prime y_2)^\prime+p(u^\prime y_1+v^\prime y_2)+(u^\prime y_1^\prime+v^\prime y_2^\prime)=r(x)[/latex].

If we simplify this equation by imposing the additional condition [latex]u^\prime y_1+v^\prime y_2=0[/latex], the first two terms are zero, and this reduces to [latex]u^\prime y_1^\prime+v^\prime y_2=r(x)[/latex]. So, with this additional condition, we have a system of two equations in two unknowns:

[latex]\begin{aligned} u^\prime y_1+v^\prime y_2&=0 \\ u^\prime y_1^\prime+v^\prime y_2^\prime&=r(x) \end{aligned}[/latex].

Solving this system gives us [latex]u'[/latex] and [latex]v'[/latex], which we can integrate to find [latex]u[/latex] and [latex]v[/latex].

Then, [latex]y_p(x)=u(x)y_1(x)+v(x)y_2(x)[/latex] is a particular solution to the differential equation. Solving this system of equations is sometimes challenging, so let’s take this opportunity to review Cramer’s rule, which allows us to solve the system of equations using determinants.

rule: cramer’s rule


The system of equations

[latex]\begin{aligned} a_1z_1+b_1z_2=r_1 \\ a_2z_1+b_2z_2&=r_2 \end{aligned}[/latex]

has a unique solution if and only if the determinant of the coefficients is not zero. In this case, the solution is given by

[latex]z_1=\frac{\begin{vmatrix}r_1&b_1 \\ r_2&b_2\end{vmatrix}}{\begin{vmatrix}a_1&b_1 \\ a_2&b_2\end{vmatrix}}[/latex] and [latex]z_2=\frac{\begin{vmatrix}a_1&r_1 \\ a_2&r_2\end{vmatrix}}{\begin{vmatrix}a_1&b_1 \\ a_2&b_2\end{vmatrix}}[/latex].

Example: using cramer’s rule

Use Cramer’s rule to solve the following system of equations.

[latex]\begin{aligned} x^2z_1+2xz_2&=0 \\ z_1-3x^2z_2&=2x \end{aligned}[/latex].

try it

Use Cramer’s rule to solve the following system of equations.

[latex]\begin{aligned} 2xz_1-3z_2&=0 \\ x^2z_1+4xz_2&=x+1 \end{aligned}[/latex].

problem-solving strategy: method of variation of parameters

  1. Solve the complementary equation and write down the general solution

    [latex]c_1y_1(x)+c_2y_2(x)[/latex].

  2. Use Cramer’s rule or another suitable technique to find functions [latex]u^\prime(x)[/latex] and [latex]v^\prime(x)[/latex] satisfying

    [latex]\begin{aligned} u^\prime y_1+v^\prime y_2&=0 \\ u^\prime y_1^\prime+v^\prime y_2^\prime&=r(x) \end{aligned}[/latex]

  3. Integrate [latex]u^\prime[/latex] and [latex]v^\prime[/latex] to find [latex]u(x)[/latex] and [latex]v(x)[/latex]. Then, [latex]y_p(x)=u(x)y_1(x)+v(x)y_2(x)[/latex] is a particular solution to the equation.
  4. Add the general solution to the complementary equation and the particular solution found in step 3 to obtain the general solution to the nonhomogeneous equation.

example: using the method of variation of parameters

Find the general solution to the following differential equations.

  1. [latex]y^{\prime\prime}-2y^\prime+y=\frac{e^t}{t^2}[/latex]
  2. [latex]y^{\prime\prime}+y=3\sin^2x[/latex]

try it

Find the general solution to the following differential equations.

  1. [latex]y^{\prime\prime}+y=\sec x[/latex]
  2. [latex]x^{\prime\prime}-2x^\prime+x=\frac{e^t}t[/latex]

Watch the following videos to see the worked solution to the above Try It

You can view the transcript for “CP 7.14a” here (opens in new window).
You can view the transcript for “CP 7.14b” here (opens in new window).