Loading [MathJax]/jax/output/HTML-CSS/jax.js
Skip to main content
Library homepage
 

Text Color

Text Size

 

Margin Size

 

Font Type

Enable Dyslexic Font
Mathematics LibreTexts

14.9: Nonhomogeneous Equations

( \newcommand{\kernel}{\mathrm{null}\,}\)

Solving Nonhomogeneous Equations

We have solved linear constant coefficient homogeneous equations. What about nonhomogeneous linear ODEs? For example, the equations for forced mechanical vibrations. That is, suppose we have an equation such as

y+5y+6y=2x+1

We will write Ly=2x+1 when the exact form of the operator is not important. We solve (Equation ???) in the following manner. First, we find the general solution yc to the associated homogeneous equation

y+5y+6y=0

We call yc the complementary solution. Next, we find a single particular solution yp to (???) in some way. Then

y=yc+yp

is the general solution to (???). We have Lyc=0 and Lyp=2x+1. As L is a linear operator we verify that y is a solution, Ly=L(yc+yp)=Lyc+Lyp=0+(2x+1). Let us see why we obtain the general solution.

Let yp and ˜yp be two different particular solutions to (???). Write the difference as w=yp˜yp. Then plug w into the left hand side of the equation to get

w+5w+6w=(yp+5yp+6yp)(˜yp+5˜yp+6˜yp)=(2x+1)(2x+1)=0

Using the operator notation the calculation becomes simpler. As L is a linear operator we write

Lw=L(yp˜yp)=LypL˜yp=(2x+1)(2x+1)=0

So w=yp˜yp is a solution to (???), that is Lw=0. Any two solutions of (???) differ by a solution to the homogeneous equation (???). The solution y=yc+yp includes all solutions to (???), since yc is the general solution to the associated homogeneous equation.

Theorem 14.9.1

Let Ly=f(x) be a linear ODE (not necessarily constant coefficient). Let yc be the complementary solution (the general solution to the associated homogeneous equation Ly=0) andlet yp be any particular solution to Ly=f(x). Then the general solution to Ly=f(x) is

y=yc+yp.

The moral of the story is that we can find the particular solution in any old way. If we find a different particular solution (by a different method, or simply by guessing), then we still get the same general solution. The formula may look different, and the constants we will have to choose to satisfy the initial conditions may be different, but it is the same solution.

Undetermined Coefficients

The trick is to somehow, in a smart way, guess one particular solution to (???). Note that 2x+1 is a polynomial, and the left hand side of the equation will be a polynomial if we let y be a polynomial of the same degree. Let us try

yp=Ax+B

We plug in to obtain

yp+5yp+6yp=(Ax+B)+5(Ax+B)+6(Ax+B)=0+5A+6Ax+6B=6Ax+(5A+6B)

So 6Ax+(5A+6B)=2x+1. Therefore, A=13 and B=19. That means yp=13x19=3x19. Solving the complementary problem (exercise!) we get

yc=C1e2x+C2e3x

Hence the general solution to (???) is

y=C1e2x+C2e3x+3x19

Now suppose we are further given some initial conditions. For example, y(0)=0 and y(0)=13. First find y=2C1e2x3C2e3x+13. Then

0=y(0)=C1+C219,13=y(0)=2C13C2+13

We solve to get C1=13 and C2=29. The particular solution we want is

y(x)=13e2x29e3x+3x19=3e2x2e3x+3x19

Exercise 14.9.1

Check that y really solves the equation (???)and the given initial conditions.

Note

A common mistake is to solve for constants using the initial conditions with yc and only add the particular solution yp after that. That will not work. You need to first compute y=yc+yp and only then solve for the constants using the initial conditions.

A right hand side consisting of exponentials, sines, and cosines can be handled similarly. For example,

y+2y+2y=cos(2x)

Let us find some yp. We start by guessing the solution includes some multiple of cos(2x). We may have to also add a multiple of sin(2x) to our guess since derivatives of cosine are sines. We try

yp=Acos(2x)+Bsin(2x)

We plug yp into the equation and we get

4Acos(2x)4Bsin(2x)yp+2(2Asin(2x)+2Bcos(2x))yp+2(Acos(2x)+2Bsin(2x))yp=cos(2x),

The left hand side must equal to right hand side. We group terms and we get that 4A+4B+2A=1 and 4B4A+2B=0. So 2A+4B=1 and 2A+B=0 and hence A=110 and B=15. So

yp=Acos(2x)+Bsin(2x)=cos(2x)+2sin(2x)10

Similarly, if the right hand side contains exponentials we try exponentials. For example, for

Ly=e3x

we will try y=Ae3x as our guess and try to solve for A.

When the right hand side is a multiple of sines, cosines, exponentials, and polynomials, we can use the product rule for differentiation to come up with a guess. We need to guess a form for yp such that Lyp is of the same form, and has all the terms needed to for the right hand side. For example,

Ly=(1+3x2)excos(πx)

For this equation, we will guess

yp=(A+Bx+Cx2)excos(πx)+(D+Ex+Fx2)exsin(πx)

We will plug in and then hopefully get equations that we can solve for A,B,C,D,Eand F. As you can see this can make for a very long and tedious calculation very quickly.

There is one hiccup in all this. It could be that our guess actually solves the associated homogeneous equation. That is, suppose we have

y9y=e3x

We would love to guess y=Ae3x, but if we plug this into the left hand side of the equation we get

y9y=9Ae3x9Ae3x=0e3x

There is no way we can choose A to make the left hand side be e3x. The trick in this case is to multiply our guess by x to get rid of duplication with the complementary solution. That is first we compute yc (solution to Ly=0)

yc=C1e3x+C2e3x

and we note that the e3x term is a duplicate with our desired guess. We modify our guess to y=Axe3x and notice there is no duplication anymore. Let us try. Note that y=Ae3x+3Axe3x and y=6Ae3x+9Axe3x. So

y9y=6Ae3x+9Axe3x9Axe3x=6Ae3x

Thus 6Ae3x is supposed to equal e3x. Hence, 6A=1 and so A=16. We can now write the general solution as

y=yc+yp=C1e3x+C2e3x+16xe3x

It is possible that multiplying by x does not get rid of all duplication. For example,

y6y+9y=e3x

The complementary solution is yc=C1e3x+C2xe3x. Guessing y=Axe3x would not get us anywhere. In this case we want to guess yp=Ax2e3x. Basically, we want to multiply our guess by x until all duplication is gone. But no more! Multiplying too many times will not work.

Finally, what if the right hand side has several terms, such as

Ly=e2x+cosx

In this case we find u that solves Lu=e2x and v that solves Lv=cosx (that is, do each term separately). Then note that if y=u+v, then Ly=e2x+cosx. This is because L is linear; we have Ly=L(u+v)=Lu+Lv=e2x+cosx.

Variation of Parameters

The method of undetermined coefficients will work for many basic problems that crop up. But it does not work all the time. It only works when the right hand side of the equation Ly=f(x) has only finitely many linearly independent derivatives, so that we can write a guess that consists of them all. Some equations are a bit tougher. Consider

y+y=tanx

Note that each new derivative of tanx looks completely different and cannot be written as a linear combination of the previous derivatives. If we start differentiating tanx, we get

sec2x,2sec2xtanx,4sec2xtan2x+2sec4x,8sec2xtan3x+16sec4xtanx,16sec2xtan4x+88sec4xtan2x+16sec6x,

This equation calls for a different method. We present the method of variation of parameters, which will handle any equation of the form Ly=f(x), provided we can solve certain integrals. For simplicity, we restrict ourselves to second order constant coefficient equations, but the method works for higher order equations just as well (the computations become more tedious). The method also works for equations with nonconstant coefficients, provided we can solve the associated homogeneous equation.

Perhaps it is best to explain this method by example. Let us try to solve the equation

Ly=y+y=tanx

First we find the complementary solution (solution to Lyc=0). We get yc=C1y1+C2y2, where y1=cosx and y2=sinx. To find a particular solution to the nonhomogeneous equation we try

yp=y=u1y1+u2y2

where u1 and u2 are functions and not constants. We are trying to satisfy Ly=tanx. That gives us one condition on the functions u1 and u2. Compute (note the product rule!)

y=(u1y1+u2y2)+(u1y1+u2y2)

We can still impose one more condition at our discretion to simplify computations (we have two unknown functions, so we should be allowed two conditions). We require that (u1y1+u2y2)=0. This makes computing the second derivative easier.

y=u1y1+u2y2y=(u1y1+u2y2)+(u1y1+u2y2)

Since y1 and y2 are solutions to y+y=0, we know that y1=y1 and y2=y2. (Note: If the equation was instead y+p(x)y+q(x)y=0 we would have yi=p(x)yiq(x)yi.) So y=(u1y1+u2y2)(u1y1+u2y2)

We have (u1y1+u2y2)=y and so

y=(u1y1+u2y2)y

and hence

y+y=Ly=u1y1+u2y2

For y to satisfy Ly=f(x) we must have f(x)=u1y1+u2y2.

So what we need to solve are the two equations (conditions) we imposed on u1 and u2

u1y1+u2y2=0u1y1+u2y2=f(x)

We can now solve for u1 and u2 in terms of f(x),y1 and y2. We will always get these formulas for any Ly=f(x), where Ly=y+p(x)y+q(x)y. There is a general formula for the solution we can just plug into, but it is better to just repeat what we do below. In our case the two equations become

u1cos(x)+u2sin(x)=0u1sin(x)+u2cos(x)=tan(x)

Hence

u1cos(x)sin(x)+u2sin2(x)=0u1sin(x)cos(x)+u2cos2(x)=tan(x)cos(x)=sin(x)

And thus

u2(sin2(x)+cos2(x))=sin(x)u2=sin(x)u1=sin2(x)cos(x)=tan(x)sin(x)

Now we need to integrate u1 and u2 to get u1 and u2.

u1=u1dx=tan(x)sin(x)dx=12lnsin(x)1sin(x)+1+sin(x)u2=u2dx=sin(x)dx=cos(x)

So our particular solution is

yp=u1y1+u2y2=12cos(x)lnsin(x)1sin(x)+1+cos(x)sin(x)cos(x)sin(x)=12cos(x)lnsin(x)1sin(x)+1

The general solution to y+y=tanx is, therefore,

y=C1cos(x)+C2sin(x)+12cos(x)lnsin(x)1sin(x)+1


This page titled 14.9: Nonhomogeneous Equations is shared under a CC BY-SA 4.0 license and was authored, remixed, and/or curated by Jiří Lebl.

Support Center

How can we help?