Skip to main content
Logo image

Introduction to Differential Equations

Section 2.5 Nonhomogeneous equations

Subsection 2.5.1 Solving nonhomogeneous equations

Our study of constant coefficient ODEs thus far has always had them be homogeneous, that is no terms only in the independent variable. How can we deal with a non-homogeneity? In this video we learn the Method of Undetermined Coefficients. We first learn a bit of theory that lets us relate solutions to the non-homogeneous equation to solutions of the corresponding homogeneous equation, and then the methodology is basically a bit of intelligent guessing to find a solution that works.
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
\begin{equation} y'' + 5y'+ 6y = 2x+1 .\tag{2.7} \end{equation}
We will write \(Ly = 2x+1\) when the exact form of the operator is not important. We solve (2.7) in the following manner. First, we find the general solution \(y_c\) to the associated homogeneous equation
\begin{equation} y'' + 5y'+ 6y = 0 .\tag{2.8} \end{equation}
We call \(y_c\) the complementary solution. Next, we find a single particular solution \(y_p\) to (2.7) in some way. Then
\begin{equation*} y = y_c + y_p \end{equation*}
is the general solution to (2.7). We have \(L y_c = 0\) and \(L y_p = 2x+1\text{.}\) As \(L\) is a linear operator we verify that \(y\) is a solution, \(L y = L ( y_c + y_p) = L y_c + L y_p = 0 + (2x+1)\text{.}\) Let us see why we obtain the general solution.
Let \(y_p\) and \(\tilde{y}_p\) be two different particular solutions to (2.7). Write the difference as \(w = y_p - \tilde{y}_p\text{.}\) Then plug \(w\) into the left-hand side of the equation to get
\begin{equation*} w'' + 5w'+ 6w = (y_p'' + 5y_p'+ 6y_p) - (\tilde{y}_p'' + 5\tilde{y}_p'+ 6\tilde{y}_p) = (2x+1) - (2x+1) = 0 . \end{equation*}
Using the operator notation the calculation becomes simpler. As \(L\) is a linear operator we write
\begin{equation*} Lw = L(y_p - \tilde{y}_p) = Ly_p - L\tilde{y}_p = (2x+1)-(2x+1) = 0 . \end{equation*}
So \(w = y_p - \tilde{y}_p\) is a solution to (2.8), that is \(Lw = 0\text{.}\) Any two solutions of (2.7) differ by a solution to the homogeneous equation (2.8). The solution \(y = y_c + y_p\) includes all solutions to (2.7), since \(y_c\) is the general solution to the associated homogeneous equation.
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 have to choose to satisfy the initial conditions may be different, but it is the same solution.

Subsection 2.5.2 Undetermined coefficients

The trick is to somehow, in a smart way, guess one particular solution to (2.7). 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
\begin{equation*} y_p = Ax + B . \end{equation*}
We plug \(y_p\) into the left hand side to obtain
\begin{equation*} \begin{split} y_p'' + 5y_p'+ 6y_p & = (Ax+B)'' + 5(Ax+B)' + 6(Ax+B) \\ & = 0 + 5A + 6Ax + 6B = 6Ax+ (5A+6B) . \end{split} \end{equation*}
So \(6Ax+(5A+6B) = 2x+1\text{.}\) Therefore, \(A = \nicefrac{1}{3}\) and \(B = \nicefrac{-1}{9}\text{.}\) That means \(y_p = \frac{1}{3}\, x - \frac{1}{9} = \frac{3x-1}{9}\text{.}\) Solving the complementary problem (verify!) we get
\begin{equation*} y_c = C_1 e^{-2x} + C_2 e^{-3x}. \end{equation*}
Hence the general solution to (2.7) is
\begin{equation*} y = C_1 e^{-2x} + C_2 e^{-3x} + \frac{3x-1}{9} . \end{equation*}
Now suppose we are further given some initial conditions. For example, \(y(0) = 0\) and \(y'(0) = \nicefrac{1}{3}\text{.}\) First find \(y' = - 2C_1 e^{-2x} - 3C_2 e^{-3x} + \nicefrac{1}{3}\text{.}\) Then
\begin{equation*} 0 = y(0) = C_1 + C_2 -\frac{1}{9} , \qquad \frac{1}{3} = y'(0) = - 2C_1 - 3C_2 + \frac{1}{3} . \end{equation*}
We solve to get \(C_1 = \nicefrac{1}{3}\) and \(C_2 = \nicefrac{-2}{9}\text{.}\) The particular solution we want is
\begin{equation*} y(x) = \frac{1}{3} e^{-2x} - \frac{2}{9} e^{-3x} + \frac{3x-1}{9} = \frac{3 e^{-2x} - 2 e^{-3x} + 3x-1}{9} . \end{equation*}
Verify: check that \(y\) really solves the equation (2.7) and the given initial conditions.
Note: A common mistake is to solve for constants using the initial conditions with \(y_c\) and only add the particular solution \(y_p\) after that. That will not work. You need to first compute \(y = y_c + y_p\) 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,
\begin{equation*} y''+2y'+2y = \cos (2x) . \end{equation*}
Let us find some \(y_p\text{.}\) We start by guessing the solution includes some multiple of \(\cos(2x)\text{.}\) We may have to also add a multiple of \(\sin (2x)\) to our guess since derivatives of cosine are sines. We try
\begin{equation*} y_p = A \cos (2x) + B \sin (2x) . \end{equation*}
We plug \(y_p\) into the equation and we get
\begin{multline*} \underbrace{-4 A \cos (2x) - 4 B \sin (2x)}_{y_p''} +2 \underbrace{\bigl(-2A \sin (2x) + 2B \cos (2x)\bigr)}_{y_p'} \\ + 2 \underbrace{\bigl(A \cos (2x) + 2B \sin (2x)\bigr)}_{y_p} = \cos (2x) , \end{multline*}
\begin{equation*} (-4A+4B+2A) \cos(2x) + (-4B-4A+2B) \sin(2x) = \cos(2x) . \end{equation*}
The left-hand side must equal to right-hand side. Namely, \(-4A + 4B + 2A = 1\) and \(-4B - 4A + 2B = 0\text{.}\) So \(-2A+4B =1\) and \(2A+B=0\) and hence \(A=\nicefrac{-1}{10}\) and \(B=\nicefrac{1}{5}\text{.}\) So
\begin{equation*} y_p = A \cos (2x) + B \sin (2x) = \frac{-\cos (2x) + 2 \sin (2x)}{10} . \end{equation*}
Similarly, if the right-hand side contains exponentials we try exponentials. If
\begin{equation*} Ly = e^{3x}, \end{equation*}
we try \(y = A e^{3x}\) as our guess and try to solve for \(A\text{.}\)
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 \(y_p\) such that \(Ly_p\) is of the same form, and has all the terms needed to for the right-hand side. For example,
\begin{equation*} Ly = (1+3x^2)\,e^{-x}\cos (\pi x) . \end{equation*}
For this equation, we guess
\begin{equation*} y_p = (A + Bx + Cx^2)\,e^{-x} \cos (\pi x) + (D + Ex + Fx^2)\,e^{-x} \sin (\pi x) . \end{equation*}
We plug in and then hopefully get equations that we can solve for \(A\text{,}\) \(B\text{,}\) \(C\text{,}\) \(D\text{,}\) \(E\text{,}\) and \(F\text{.}\) As you can see this can make for a very long and tedious calculation very quickly. C’est la vie!
There is one hiccup in all this. It could be that our guess actually solves the associated homogeneous equation. That is, suppose we have
\begin{equation*} y'' - 9y = e^{3x} . \end{equation*}
We would love to guess \(y = Ae^{3x}\text{,}\) but if we plug this into the left-hand side of the equation we get
\begin{equation*} y''-9y = 9Ae^{3x} - 9Ae^{3x} = 0 \not= e^{3x} . \end{equation*}
There is no way we can choose \(A\) to make the left-hand side be \(e^{3x}\text{.}\) 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 \(y_c\) (solution to \(Ly = 0\))
\begin{equation*} y_c = C_1 e^{-3x} + C_2 e^{3x} , \end{equation*}
and we note that the \(e^{3x}\) term is a duplicate with our desired guess. We modify our guess to \(y = Axe^{3x}\) so that there is no duplication anymore. Let us try: \(y' = Ae^{3x} + 3Axe^{3x}\) and \(y'' = 6Ae^{3x} + 9Axe^{3x}\text{,}\) so
\begin{equation*} y'' -9y = 6Ae^{3x} + 9Axe^{3x} - 9Axe^{3x} = 6Ae^{3x} . \end{equation*}
Thus \(6Ae^{3x}\) is supposed to equal \(e^{3x}\text{.}\) Hence, \(6A = 1\) and so \(A=\nicefrac{1}{6}\text{.}\) We can now write the general solution as
\begin{equation*} y = y_c + y_p = C_1 e^{-3x} + C_2 e^{3x} + \frac{1}{6}\,xe^{3x} . \end{equation*}
It is possible that multiplying by \(x\) does not get rid of all duplication. For example,
\begin{equation*} y''-6y'+9y = e^{3x} . \end{equation*}
The complementary solution is \(y_c = C_1 e^{3x} + C_2 x e^{3x}\text{.}\) Guessing \(y=A xe^{3x}\) would not get us anywhere. In this case we want to guess \(y_p = Ax^2e^{3x}\text{.}\) 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
\begin{equation*} Ly = e^{2x} + \cos x . \end{equation*}
In this case we find \(u\) that solves \(Lu = e^{2x}\) and \(v\) that solves \(Lv = \cos x\) (that is, do each term separately). Then note that if \(y = u+ v\text{,}\) then \(Ly = e^{2x} + \cos x\text{.}\) This is because \(L\) is linear; we have \(Ly = L(u+v) = Lu + Lv = e^{2x} + \cos x\text{.}\)

Subsection 2.5.3 Variation of parameters

The method of undetermined coefficients works 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 finitely many linearly independent derivatives, so that we can write a guess that consists of them all. Some equations are a bit tougher. Consider
\begin{equation*} y''+y = \tan x . \end{equation*}
Each new derivative of \(\tan x\) looks completely different and cannot be written as a linear combination of the previous derivatives. If we start differentiating \(\tan x\text{,}\) we get:
\begin{multline*} \sec^2 x, \quad 2\sec^2 x \, \tan x, \quad 4 \sec^2 x \, \tan^2 x + 2 \sec^4 x, \\ 8 \sec^2 x \, \tan^3 x + 16 \sec^4 x \, \tan x, \quad 16\sec^2 x \, \tan^4 x + 88 \sec^4 x \tan^2 x + 16 \sec^6 x, \quad \ldots \end{multline*}
This equation calls for a different method. We present the method of variation of parameters, which handles any equation of the form \(Ly = f(x)\text{,}\) 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
\begin{equation*} Ly = y''+y = \tan x . \end{equation*}
First we find the complementary solution (solution to \(Ly_c = 0\)). We get \(y_c = C_1 y_1 + C_2 y_2\text{,}\) where \(y_1 = \cos x\) and \(y_2 = \sin x\text{.}\) To find a particular solution to the nonhomogeneous equation we try
\begin{equation*} y_p = y = u_1 y_1 + u_2 y_2 , \end{equation*}
where \(u_1\) and \(u_2\) are functions and not constants. We are trying to satisfy \(Ly = \tan x\text{.}\) That gives us one condition on the functions \(u_1\) and \(u_2\text{.}\) Compute (note the product rule!)
\begin{equation*} y' = (u_1' y_1 + u_2' y_2) + (u_1 y_1' + u_2 y_2'). \end{equation*}
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 \((u_1' y_1 + u_2' y_2) = 0\text{.}\) This makes computing the second derivative easier.
\begin{equation*} \begin{aligned} & y' = u_1 y_1' + u_2 y_2' , \\ & y'' = (u_1' y_1' + u_2' y_2') + (u_1 y_1'' + u_2 y_2'') . \end{aligned} \end{equation*}
Since \(y_1\) and \(y_2\) are solutions to \(y''+y = 0\text{,}\) we find \(y_1'' = - y_1\) and \(y_2'' = - y_2\text{.}\) (If the equation was a more general \(y''+p(x)y' +q(x)y = 0\text{,}\) we would have \(y_i'' = -p(x)y_i' -q(x)y_i\text{.}\)) So
\begin{equation*} y'' = (u_1' y_1' + u_2' y_2') - (u_1 y_1 + u_2 y_2) . \end{equation*}
We have \((u_1 y_1 + u_2 y_2) = y\) and so
\begin{equation*} y'' = (u_1' y_1' + u_2' y_2') - y , \end{equation*}
and hence
\begin{equation*} y'' + y = Ly = u_1' y_1' + u_2' y_2' . \end{equation*}
For \(y\) to satisfy \(Ly = f(x)\) we must have \(f(x) = u_1' y_1' + u_2' y_2'\text{.}\)
What we need to solve are the two equations (conditions) we imposed on \(u_1\) and \(u_2\text{:}\)
\begin{equation} \mybxbg{~~ \begin{aligned} & u_1' y_1 + u_2' y_2 = 0 ,\\ & u_1' y_1' + u_2' y_2' = f(x) . \end{aligned} ~~}\tag{2.9} \end{equation}
We always get these formulas for any \(Ly = f(x)\text{,}\) where \(Ly = y''+p(x)y'+q(x)y\text{.}\) Now we solve for \(u_1'\) and \(u_2'\) in terms of \(f(x)\text{,}\) \(y_1\) and \(y_2\) giving
\begin{equation*} u_1(t)=-\int_{t_0}^t\frac{y_2(s)f(s)}{W(y_1,y_2)(s)}ds, \end{equation*}
\begin{equation*} u_2(t)=\int_{t_0}^t\frac{y_1(s)f(s)}{W(y_1,y_2)(s)}ds, \end{equation*}
where \(W(y_1,y_2)(s)=y_1(s)y_2'(s)-y_2(s)y_1'(s)\) is the Wronskian of \(y_1\) and \(y_2\) at a point \(s\text{.}\) This gives us the general formula
\begin{equation} \mybxbg{~~ y=-y_1(t)\int_{t_0}^t\frac{y_2(s)f(s)}{W(y_1,y_2)(s)}ds+y_2(t)\int_{t_0}^t\frac{y_1(s)f(s)}{W(y_1,y_2)(s)}ds ~~}\tag{2.10} \end{equation}
We could just plug into this general formula, but memorizing this complicated formula is tedious and not instructive so and instead one can ignore the above formula and just go through the process to derive the formula in each specific case. Let’s do that now for our example with \(f(x)=\tan(x)\text{.}\)
In our case the two equations are
\begin{equation*} \begin{aligned} u_1' \cos (x) + u_2' \sin (x) &= 0 ,\\ -u_1' \sin (x) + u_2' \cos (x) &= \tan (x) . \end{aligned} \end{equation*}
\begin{equation*} \begin{aligned} u_1' \cos (x) \sin (x) + u_2' \sin^2 (x) & = 0 ,\\ -u_1' \sin (x) \cos (x) + u_2' \cos^2 (x) & = \tan (x) \cos (x) = \sin (x) . \end{aligned} \end{equation*}
And thus
\begin{equation*} \begin{aligned} & u_2' \bigl(\sin^2 (x) + \cos^2 (x)\bigr) = \sin (x) , \\ & u_2' = \sin (x) , \\ & u_1' = \frac{- \sin^2 (x)}{\cos (x)} = - \tan (x) \sin (x) . \end{aligned} \end{equation*}
We integrate \(u_1'\) and \(u_2'\) to get \(u_1\) and \(u_2\text{.}\)
\begin{equation*} \begin{aligned} & u_1 = \int u_1'\,dx = \int - \tan (x) \sin (x)\,dx = \frac{1}{2} \ln \left\lvert \frac{\sin (x)-1}{\sin (x) + 1} \right\rvert + \sin (x) , \\ & u_2 = \int u_2'\,dx = \int \sin (x)\,dx = -\cos (x) . \end{aligned} \end{equation*}
So our particular solution is
\begin{multline*} y_p = u_1 y_1 + u_2 y_2 = \frac{1}{2} \cos (x) \ln \left\lvert \frac{\sin (x)-1}{\sin (x) + 1} \right\rvert + \cos (x) \sin (x) -\cos (x) \sin (x) = \\ = \frac{1}{2} \cos (x) \ln \left\lvert \frac{\sin (x)-1}{\sin (x) + 1} \right\rvert . \end{multline*}
The general solution to \(y'' + y = \tan x\) is, therefore,
\begin{equation*} y = C_1 \cos (x) + C_2 \sin (x) + \frac{1}{2} \cos (x) \ln \left\lvert \frac{\sin (x)-1}{\sin (x) + 1} \right\rvert . \end{equation*}

Subsection 2.5.4 Exercises

Exercise 2.5.1.

Find a particular solution of \(y''-y' -6y = e^{2x}\text{.}\)
Finding the complementary solution \(y_c\)
\begin{equation*} \begin{aligned} y_c=C_1e^{3x}+C_2e^{-2x} \end{aligned} \end{equation*}
The right hand side of the ODE is an exponential, so the particular solution should look like \(y_p=Ae^{2x}\text{.}\) Differentiating
\begin{equation*} \begin{aligned} y_p'=2Ae^{2x},\quad y_p''=4Ae^{2x} \end{aligned} \end{equation*}
Plugging into the ODE, we find \(A=-1/4\text{.}\) Therefore, the particular solution is \(y_p=-\frac{e^{2x}}{4}\text{.}\)

Exercise 2.5.2.

Find a particular solution of \(y''-4y' +4y = e^{2x}\text{.}\)

Exercise 2.5.3.

Find a particular solution to \(y''-y'+y=2\sin(3x)\text{.}\)

Exercise 2.5.4.

Solve the initial value problem \(y''+9y = \cos (3x) + \sin (3x)\) for \(y(0) = 2\text{,}\) \(y'(0) = 1\text{.}\)
The complementary solution is \(y_c=C_1\cos(3x)+C_2\sin(3x)\text{.}\) Given the right hand side of the ODE, we expect the particular solution to be of the form \(y_p=A\cos(3x)+B\sin(3x)\text{.}\) This however is a duplicate of \(y_c\text{,}\) so we multiply by \(x\text{,}\) giving
\begin{equation*} \begin{aligned} y_p &=Ax\cos(3x)+Bx\sin(3x) \\ y_p' &=-3Ax\sin(3x)+A\cos(3x)+3Bx\cos(3x)+B\sin(3x) \\ y_p'' &= -9Ax\cos(3x)-6A\sin(3x)-9Bx\sin(3x)+6B\cos(3x) \end{aligned} \end{equation*}
Plugging into the ODE and cancelling terms, we end up with
\begin{equation*} \begin{aligned} -6A\sin(3x)+6B\cos(3x)=\cos(3x)+\sin(3x)\quad \rightarrow A=-1/6,\quad B=1/6 \end{aligned} \end{equation*}
So the general solution is
\begin{equation*} \begin{aligned} y=C_1\cos(3x)+C_2\sin(3x)+\frac{x}{6}(\sin(3x)-\cos(3x)) \end{aligned} \end{equation*}
Applying the initial conditions (to the full general solution including the particular solution), we find that \(C_1=2\) and \(C_2=7/18\text{,}\) so the solution to the initial value problem is
\begin{equation*} \begin{aligned} y=2\cos(3x)+\frac{7}{18}\sin(3x)+\frac{x}{6}\left(\sin(3x)-\cos(3x)\right) \end{aligned} \end{equation*}

Exercise 2.5.5.

  1. Find a particular solution to \(y''+2y=e^x + x^3\text{.}\)
  2. Find the general solution.
a) \(y=\frac{2e^x+3x^3-9x}{6}\)     b) \(y=C_1 \cos(\sqrt{2} x) + C_2 \sin(\sqrt{2} x) + \frac{2e^x+3x^3-9x}{6}\)

Exercise 2.5.6.

Solve \(y''+2y'+y = x^2\text{,}\) \(y(0)=1\text{,}\) \(y'(0)=2\text{.}\)
\(y(x) = x^2-4 x+6+e^{-x}(x-5)\)

Exercise 2.5.7.

Set up the form of the particular solution but do not solve for the coefficients for \(y^{(4)}-2y'''+y'' = e^x\text{.}\)
Finding the complementary solution
\begin{equation*} \begin{aligned} y_c=C_1+C_2x+C_3e^x+C_4xe^x \end{aligned} \end{equation*}
Given the right hand side of the ODE, we guess a particualr solution of the form \(y_p=Ae^x\text{,}\) but this is a duplicate of a term in \(y_c\) so we multiply by \(x^2\) giving
\begin{equation*} \begin{aligned} y_p=Ax^2e^x \end{aligned} \end{equation*}

Exercise 2.5.8.

Set up the form of the particular solution but do not solve for the coefficients for \(y^{(4)}-2y'''+y'' = e^x + x + \sin x\text{.}\)
\(y_p=Ax^2e^x+Bx^3+Cx^2+D\cos x+E\sin x\)

Exercise 2.5.9.

  1. Using variation of parameters find a particular solution of \(y''-2y'+y = e^x\text{.}\)
  2. Find a particular solution using undetermined coefficients.
  3. Are the two solutions you found the same? See also Exercise 2.5.14.
a) The complementary solution is \(y_c=C_1e^x+C_2xe^x\text{.}\) Using
\begin{equation*} \begin{aligned} u_1'y_1+u_2'y_2 &=0 \\ u_1'e^x+u_2'xe^x &=0 \rightarrow u_1'=-xu_2'\\ \end{aligned} \end{equation*}
And using
\begin{equation*} \begin{aligned} u_1'y_1'+u_2'y_2' &= f(x)\\ u_1'e^x+u_2'(xe^x+e^x)& = e^x \rightarrow u_2'=1 \\ \textrm{integrating}\ & \rightarrow u_2=x,\ u_1=-\frac{x^2}{2} \end{aligned} \end{equation*}
The particular solution is
\begin{equation*} \begin{aligned} y_p &=u_1y_1+u_2y_2 \\ &= -\frac{x^2}{2}e^x+x^2e^x=\frac{x^2e^x}{2} \end{aligned} \end{equation*}

b) We guess the particular solution has the form \(y_p=Ae^x\text{,}\) which is duplicated in \(y_c\text{,}\) so we multiply by \(x^2\) giving
\begin{equation*} \begin{aligned} y_p &=Ax^2e^x \\ y_p'&= Ax^2e^x+2Axe^x \\ y_p'' &= Ax^2e^x+4Axe^x+2Ae^x \end{aligned} \end{equation*}
Plugging into the ODE we find that \(A=1/2\text{,}\) so
\begin{equation*} \begin{aligned} y_p=\frac{x^2e^x}{2} \end{aligned} \end{equation*}
As found in (a).
c) Yes, the answers match!

Exercise 2.5.10.

Use variation of parameters to find a particular solution of \(y''-y = \frac{1}{e^x+e^{-x}}\text{.}\)
\(y = \frac{2xe^x-(e^x+e^{-x})\log(e^{2x}+1)}{4}\)

Exercise 2.5.11.

Find a particular solution of \(y''-2y' +y = \sin (x^2)\text{.}\) It is OK to leave the answer as a definite integral.
\(y_p=e^x\int \frac{\sin(x^2)}{e^x}dx-xe^x\int \frac{x\sin(x^2)}{e^x}dx\)

Exercise 2.5.12.

For an arbitrary constant \(c\) find a particular solution to \(y''-y=e^{cx}\text{.}\) Hint: Make sure to handle every possible real \(c\text{.}\)
The complementary solution is \(y_c=C_1e^x+C_2e^{-x}\text{.}\) So we guess a particular solution of the form \(y_p=Ae^{cx}\text{.}\) We look at the case where \(c=\pm1\) (case 1). Here we have
\begin{equation*} \begin{aligned} y_p &=Axe^{cx} \\ y_p' &=cAxe^{cx}+Ae^{cx} \\ y_p'' &=c^2Axe^{cx}+2cAe^{cx} \end{aligned} \end{equation*}
Plugging into the ODE
\begin{equation*} \begin{aligned} c^2Axe^{cx}+2cAe^{cx}-Axe^{cx}=e^{cx} \end{aligned} \end{equation*}
Since \(c=\pm 1\) this simplifies to
\begin{equation*} \begin{aligned} 2cA &=1 \rightarrow \\ A&=1/2,\ \textrm{for}\ c=1 \\ A&=-1/2,\ \textrm{for}\ c=-1 \end{aligned} \end{equation*}
In the case where \(c\neq \pm1\) (case 2), no modification is needed for our guess. Repeating the same process as above we find that
\begin{equation*} \begin{aligned} A=\frac{1}{c^2-1} \end{aligned} \end{equation*}
So finally the particular solution is
\begin{equation*} \begin{aligned} y_p= \begin{cases} \frac{xe^x}{2},\quad c=1 \\ -\frac{xe^{-x}}{2},\quad c=-1 \\ \frac{e^{cx}}{c^2-1},\quad \textrm{otherwise} \end{cases} \end{aligned} \end{equation*}

Exercise 2.5.13.

For an arbitrary constant \(c\) find the general solution to \(y''-2y=\sin(x+c)\text{.}\)
\(y=\frac{-\sin(x+c)}{3}+C_1 e^{\sqrt{2}\,x}+C_2 e^{-\sqrt{2}\,x}\)

Exercise 2.5.14.

  1. Using variation of parameters find a particular solution of \(y''-y = e^x\text{.}\)
  2. Find a particular solution using undetermined coefficients.
  3. Are the two solutions you found the same? What is going on?
a) Using variation of parameters, we find \(u_1=\frac{x}{2}\) and \(u_2=-\frac{e^{2x}}{4}\) giving \(y_p=\frac{x}{2}e^x-\frac{e^x}{4}\text{.}\)
b) Using undetermined coefficients we guess \(y_p=Axe^x\) where \(A=1/2\text{,}\) giving \(y_p=\frac{xe^x}{2}\text{.}\)
c) It is acceptable to get different \(y_p\) with different methods. What needs to remain the same is the general solution (or the solution to the initial value problem). Looking at the general solution from (b)
\begin{equation*} \begin{aligned} y=C_1e^x+C_2e^{-x}+\frac{xe^x}{2} \end{aligned} \end{equation*}
And the general solution from (a)
\begin{equation*} \begin{aligned} y &=C_1e^x+C_2e^{-x}+\frac{xe^x}{2}-\frac{e^x}{4} \\ &= (\underbrace{C_1-\frac{1}{4}}_{\textrm{call}\ C_3})e^x++C_2e^{-x}+\frac{xe^x}{2} \\ y &= C_3e^x+C_2e^{-x}+\frac{xe^x}{2} \end{aligned} \end{equation*}
So the general solution is the same in both cases, as it should be.

Exercise 2.5.15.

Find a polynomial \(P(x)\text{,}\) so that \(y = 2 x^2 + 3 x + 4\) solves \(y''+5 y'+ y = P(x)\text{.}\)
Finding \(y'\) and \(y''\)
\begin{equation*} \begin{aligned} y' &=4x+3 \\ y'' &= 4 \end{aligned} \end{equation*}
We plug this into the ODE, giving
\begin{equation*} \begin{aligned} P(x)=2x^2+23x+23 \end{aligned} \end{equation*}

Exercise 2.5.16.

Undetermined coefficients can sometimes be used to guess a particular solution to other equations than constant coefficients. Find a polynomial \(y(x)\) that solves \(y'+ x y = x^3+2x^2+5x+2\text{.}\)
Note: Not every right hand side will allow a polynomial solution, for example, \(y'+xy=1\) does not, but a technique based on undetermined coefficients does work, see Chapter 4.
For a higher quality printout use the PDF version: