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
We will write when the exact form of the operator is not important. We solve (Equation ) in the following manner. First, we find the general solution to the associated homogeneous equation
We call the complementary solution. Next, we find a single particular solution to in some way. Then
is the general solution to . We have and . As is a linear operator we verify that is a solution, . Let us see why we obtain the general solution.
Let and be two different particular solutions to . Write the difference as . Then plug into the left hand side of the equation to get
Using the operator notation the calculation becomes simpler. As is a linear operator we write
So is a solution to , that is . Any two solutions of differ by a solution to the homogeneous equation . The solution includes all solutions to , since is the general solution to the associated homogeneous equation.
Theorem
Let be a linear ODE (not necessarily constant coefficient). Let be the complementary solution (the general solution to the associated homogeneous equation ) andlet be any particular solution to . Then the general solution to is
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 is a polynomial, and the left hand side of the equation will be a polynomial if we let be a polynomial of the same degree. Let us try
We plug in to obtain
So . Therefore, and . That means . Solving the complementary problem (exercise!) we get
Hence the general solution to is
Now suppose we are further given some initial conditions. For example, and . First find . Then
We solve to get and . The particular solution we want is
Exercise
Check that really solves the equation and the given initial conditions.
Note
A common mistake is to solve for constants using the initial conditions with and only add the particular solution after that. That will not work. You need to first compute 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,
Let us find some . We start by guessing the solution includes some multiple of . We may have to also add a multiple of to our guess since derivatives of cosine are sines. We try
We plug into the equation and we get
The left hand side must equal to right hand side. We group terms and we get that and . So and and hence and . So
Similarly, if the right hand side contains exponentials we try exponentials. For example, for
we will try as our guess and try to solve for .
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 such that is of the same form, and has all the terms needed to for the right hand side. For example,
For this equation, we will guess
We will plug in and then hopefully get equations that we can solve for and . 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
We would love to guess , but if we plug this into the left hand side of the equation we get
There is no way we can choose to make the left hand side be . The trick in this case is to multiply our guess by to get rid of duplication with the complementary solution. That is first we compute (solution to )
and we note that the term is a duplicate with our desired guess. We modify our guess to and notice there is no duplication anymore. Let us try. Note that and . So
Thus is supposed to equal . Hence, and so . We can now write the general solution as
It is possible that multiplying by does not get rid of all duplication. For example,
The complementary solution is . Guessing would not get us anywhere. In this case we want to guess . Basically, we want to multiply our guess by 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
In this case we find that solves and that solves (that is, do each term separately). Then note that if , then . This is because is linear; we have .
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 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
Note that each new derivative of looks completely different and cannot be written as a linear combination of the previous derivatives. If we start differentiating , we get
This equation calls for a different method. We present the method of variation of parameters, which will handle any equation of the form , 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
First we find the complementary solution (solution to ). We get , where and . To find a particular solution to the nonhomogeneous equation we try
where and are functions and not constants. We are trying to satisfy . That gives us one condition on the functions and . Compute (note the product rule!)
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 . This makes computing the second derivative easier.
Since and are solutions to , we know that and . (Note: If the equation was instead we would have .) So
We have and so
and hence
For to satisfy we must have .
So what we need to solve are the two equations (conditions) we imposed on and
We can now solve for and in terms of and . We will always get these formulas for any , where . 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
Hence
And thus
Now we need to integrate and to get and .
So our particular solution is
The general solution to is, therefore,