\documentclass[12pt]{amsart}
\setlength{\textheight}{9in}
\setlength{\textwidth}{6.5in}
\setlength{\oddsidemargin}{0in}
\setlength{\evensidemargin}{0in}

\setlength{\topmargin}{-0.5in}
\usepackage{amssymb,amsmath,amsfonts,graphicx,psfrag}

%\pagestyle{empty}
\newcommand{\dis}{\displaystyle}
\newcommand{\bd}{\partial}
\begin{document}
{\Large

\begin{center}
{\bf Nonhomogeneous Second Order Equations with Constant Coefficients
}\end{center}


We will be studying equations of the form
\[
ay''(x) + by'(x) + cy(x) = g(x),
\]
where $g(x)$ is continuous on some open interval of interest and $a$, $b$
and $c$ are real constants, $a \neq 0$. We may refer to $g(x)$ as a forcing
term for reasons that will become clear when we study applications
to mass-spring systems.

\begin{itemize}

\item In Section 3.5 we develop the method of {\bf Undetermined Coefficients.}
  It is relatively easy, but does not always apply.

\item In Section 3.6 we develop the method of {\bf Variation of Parameters.}
  It is harder, but always works.

\end{itemize}

First we make some general remarks about solutions to nonhomogeneous second order
equations with constant coefficients. For the homogeneous equations of this type we
had the useful fact that linear combinations of solutions were solutions. That is,
if $y_1(x)$ and $y_2(x)$ both solved 
\[
ay'' + by' + cy = 0,
\]
then $y=C_1y_1 + C_2 y_2$ was also a solution. This does not hold for 
nonhomogeneous equations. For example, $f(x)= (x-1)/4$ is a solution to
\[
y'' + 4y' + 4y = x,      \hspace{2in}(*)
\]
as you can check. But, $4f(x)$ is not a solution. We know that $e^{-2x}$ and
$xe^{-2x}$ are solutions to the homogeneous problem
\[
y'' + 4y' + 4y = 0.
\]
Now consider $y(x) = C_1 e^{-2x} + C_2 xe^{-2x} + (x-1)/4$. If you plug this into
$(*)$ you will see that it is a solution. In fact, it is the general solution. 

\vspace{.2in}
{\bf Theorem 1.} {\em Any solution to 
\[
ay'' + by' + cy = g(x)
\]
can be written in the form
\[
C_1y_1 + C_2 y_2 + y_p
\]
where $\{ y_1, y_2 \}$ is a fundamental solution set for the corresponding homogeneous equation
\[
ay'' + by' + cy = 0
\]
and $y_p$ is any particular solution of the original equation.}

\vspace{.2in}

\begin{proof} It is easy to see why such functions are solutions. Let
  $y = C_1y_1 + C_2 y_2 + y_p$ and plug it into the original nonhomogeneous equation.


   \[
   ay'' + by' + cy = 
   \]
  
  \[
  a(C_1y_1 + C_2 y_2 + y_p)'' + b(C_1y_1 + C_2 y_2 + y_p)' + c(C_1y_1 + C_2 y_2 + y_p) =
  \]


\[
a(C_1y_1 + C_2 y_2)'' + ay_p'' + b(C_1y_1 + C_2 y_2) + by_p' + c(C_1y_1 + C_2 y_2) +c y_p =
\]

\[
\big[a(C_1y_1 + C_2 y_2)'' + b(C_1y_1 + C_2 y_2) + c(C_1y_1 + C_2 y_2)\big] + \big[ ay_p''+ by_p' + c y_p \big]
\]

\[
= 0 + g(x) = g(x).
\]

\vspace{.1in}

Now, suppose $f(x)$ is any other solution of the original equation. Consider $h(x) = f(x) - y_p(x)$. Then
\[
ah'' + bh' + ch = [af'' + bf' + cf] - [y_p'' + by_p' + cy_p] = g - g = 0.
\]


Therefore, the difference between any two solutions of the 
nonhomogeneous equation is a solution of the corresponding 
homogeneous equation. But we know any solution of the homogeneous
equation is of the form $C_1y_1 + C_2y_2$. Thus, 
\[
h(x) = C_1y_1 + C_2y_2,
\]
for some $C_1$ and $C_2$. Therefore, we can write
\[
f(x) =   C_1y_1(x) + C_2y_2(x) + y_p(x).
\] 
\end{proof}

\vspace{.2in}
{\bf Corollary.} Suppose $y = y_f$ is a solution to $ay'' + by' + cy = f$
and $y = y_g$ is a solution to $ay'' + by' + cy = g$. Then $y = y_f + y_g$ is
a solution to $ay'' + by' + cy = f(x) + g(x)$.

\vspace{.2in}
The proof is easy and left to you.

\vfill
\pagebreak

\section{The Method of Undermined Coefficients}

We start with some simple examples with first degree equations. 

\vspace{.2in}
{\bf Example 1.} Find the general solution to $y' = x e^x$. 

\vspace{.2in}
{\em Solution.}
Of course, this is the same as finding the indefinite integral $\int x e^x \, dx$. But,
let's suppose you are too lazy to look up integration by parts. You remember however that this integral
of the form $(Ax+B)e^x$ plus an arbitrary constant. If so then
\[
\big((Ax+B)e^x \big)' = x e^x.
\]
Hence,
\[
Ae^x + (Ax+B)e^x = Axe^x + (A+B)e^x = xe^x. 
\]
Since $e^x$ and $xe^x$ are linearly independent we know that $A=1$ and
$B=-1$ is the only solution. Hence,
\[
y = (x-1)e^x + C.
\]


\vspace{.2in}
{\bf Example 2.} Find the general solution to $y' = x^3e^x$. 

\vspace{.2in}
{\em Solution.}
You could do integration by parts three times, or you might make an educated guess that
\[
\int x^3 e^x \, dx = (Ax^3+Bx^2+Cx+D)e^x + \mbox{arbitrary constant}.
\]
Then
\[
(3Ax^2 + 2Bx+C)e^x +  (Ax^3+Bx^2+Cx+D)e^x = x^3e^x.
\]
Regrouping terms gives
\[
Ax^3e^x + (3A+B)x^2e^x + (2B+C)xe^x + (C+D)e^x = x^3e^x.
\]
Since $\{x^3e^x, x^2e^x, xe^x, e^x\}$ is linearly independent (see chapter 4 for how to check this claim), we know that
\[
A=1 \:\:\: B=-1/3 \:\:\: C= 2/3 \:\&\: D = -2/3.
\] 
Therefore,
\[
y = \int x^3 e^x \, dx = \left(x^3-\frac{1}{3}x^2+\frac{2}{3}xe^x - \frac{2}{3}\right)e^x + \mbox{arbitrary constant}.
\]

\hfill $\Box$



\vspace{.2in}
{\bf Student Exercise 1.} Find the general solution to 
\[y' = 2x^2e^x + 3xe^x + e^x.\] Check your answer
by computing its derivative.

\vspace{.2in}
\subsection{Exponential Forcing Terms.} Now we start looking at second degree equations.

\vspace{.2in}
{\bf Example 3.}
Find the general solution to $y'' + y = e^x$. 

\vspace{.2in}
{\em Solution.} We know that the solution to the corresponding homogeneous equation is 
\[
y_h = C_1\cos x + C_2 \sin x.
\]
Motivated by the first two examples we guess that something of the form
\[
y_p = Ae^x
\]
might be a particular solution to the original problem. Let's check.
\[
y_p'' + y_p = 2Ae^x. 
\] 
We need for this to equal $e^x$. Therefore, $A=1/2$. We conclude
that the general solution is
\[
y= C_1\cos x + C_2\sin x + \frac{1}{2}e^x.
\]
\hfill$\Box$

\vspace{.2in}
We might conjecture that given $ay''+by'+cy = de^{\alpha x}$ the general solution will be
$y = C_1y_1 + C_2y_2 + Ae^{\alpha x}$, where $\{y_1, y_2\}$ is a fundamental solution set for the corresponding homogeneous problem, $C_1$ and $C_2$ are arbitrary constants, and $A$ is to be determined. This almost works. It fails if $e^{\alpha x}$ happens to be a solution to the homogeneous problem as in the next example.

\vspace{.2in}
{\bf Example 4.} Find the general solution to $y'' - y' - 2y = 3e^{2x}$. 

{\em Wrong Solution.} We know that the solution to the corresponding homogeneous equation is 
\[
y_h = C_1e^{2x} + C_2 e^{-x}.
\]
Let $y_p = Ae^{2x}$. We plug in a solve for $A$. Thus, we need for
\[
4Ae^{2x}  - 2Ae^{2x} -  2Ae^{2x} = 3 e^{2x}.
\]
But then we get $0A=3$. Yikes! But, of course this had to happen since $e^{2x}$ is a solution to the homogeneous problems. What to do? 
\hfill $\Box$

{\em Right Solution.} We need something whose derivatives behave kind of 
like $e^{2x}$ but which is linearly independent from $e^{2x}$. When we encountered something like this before, in the repeated roots case, we ended up 
using $xe^{2x}$. Let's try $y_p = Axe^{2x}$ and see what happens. 
Now, $y_p' = Ae^{2x} + 2Axe^{2x}$ and $y''_p = 4Ae^{2x} + 4Axe^{2x}$. Thus, we need for
\[
 4Ae^{2x} + 4Axe^{2x} - Ae^{2x} - 2Axe^{2x} - 2Axe^{2x} = 3 e^{2x}.
\]
Simplifying  gives
\[
8Ae^{2x} = 3 e^{2x}.
\]
Hence $A=3/8$ and we conclude that the general solution is
\[
y = C_1e^{2x} + C_2 e^{-x} + \tfrac{3}{8} x e^{2x}.
\]
\hfill $\Box$

\vspace{.2in}
{\bf Example 5.} Find the general solution to $y'' - 4y' + 4y = e^{2x}$. 

{\em Solution.} We know that the solution to the corresponding homogeneous equation is 
\[
y_h = C_1x^{2x} + C_2 xe^{2x}.
\]
Now, both $e^{2x}$ and $xe^{2x}$ are solutions to the homogeneous problem and so $y_p$ cannot be multiples of these. Instead we try $y_p = Ax^2 e^{2x}$. It cannot 
hurt to try it. Now $y_p' = 2Ax^2e^{2x} + 2Ax e^{2x}$ and 
$y''_p = 4Ax^2 e^{2x} + 8Ax e^{2x} + 2Ae^{2x}$. Thus, we need to solve
\[
4Ax^2e^{2x} + 8Axe^{2x} + 2Ae^{2x} - 8Ax^2 e^{2x} - 8Axe^{2x} + 4Ax^2 e^{2x} = e^{2x}.
\]
Simplifying gives 
\[
2A = 1.
\]
Thus, the general solution is 
\[
y = C_1x^{2x} + C_2 xe^{2x} + \tfrac{1}{2}x^2 e^{2x}.
\]
\hfill $\Box$


It could be that I just picked examples where these tricks worked. But no, there is a general theorem that backs this up.

\vspace{.2in}
{\bf Theorem 2.} {\em Suppose, $ay'' + by' + cy = d e^{\alpha x}$. Then we have three
cases.
\begin{enumerate} 
\item If $e^{\alpha x}$ is not a solution of the corresponding homogeneous problem, then the general solution is 
\[
y = C_1 y_1 + C_2 y_2 + A e^{2x},
\]
where $\{ y_1 , y_2\}$ is a fundamental solution set of the homogeneous problem and $A$ is determined by substitution.

\item If $e^{\alpha x}$ is a solution of the corresponding homogeneous problem,
and $xe^{\alpha x}$ is not, then the general solution is 
\[
y = C_1 y_1 + C_2 y_2 + A xe^{2x},
\]
where $\{ y_1 , y_2\}$ is a fundamental solution set of the homogeneous problem and $A$ is determined by substitution.

\item If $e^{\alpha x}$ and $x e^{\alpha x}$ are solutions of the corresponding homogeneous problem, then the general solution is 
\[
y = C_1 y_1 + C_2 y_2 + A x^2e^{2x},
\]
where $\{ y_1 , y_2\}$ is a fundamental solution set of the homogeneous problem and $A$ is determined by substitution.
\end{enumerate}}


{\em Proof.}
(1) Let $y_p = Ae^x$. Then $y'_p = \alpha A e^{\alpha}x$ and
$y''_p  = \alpha^2Ae^{\alpha x}$.
We plug into the given differential equation to get
\[ (a\alpha^2 + b\alpha + c)Ae^{\alpha x} = de^{\alpha x}.\]
Since in case (1) $\alpha$ is not a root of the characteristic polynomial,
we know the expression in parenthesis above in not zero. Hence
\[
A = \frac{d}{a\alpha^2 + b\alpha +c}
\]
makes $y_p$ a solution.

(2) Let $y_p = Axe^{\alpha x}$. Then $y'_p = Ae^{\alpha x} + \alpha Axe^{\alpha x}$ and
$y''_p = 2\alpha Ae^{\alpha x} +\alpha^2Axe^{\alpha x}.$  We plug into the given differential
equation to get
\[
(a2\alpha  + a\alpha^2 x + b + b\alpha x + cx)Ae^{\alpha x} =
\]
\[
\left( (a2\alpha+b) + \overbrace{a\alpha^2 + b\alpha + c}^0 x\right) Ae^{\alpha x} = (a2\alpha+b)Ae^{\alpha x}.
\]
Now we need to solve
\[(2a\alpha + b)Ae^{\alpha x} = de^{\alpha x}.\] 
But since $\alpha$ is NOT a double root of the characteristic polynomial we
know that $\alpha \neq -b/2a$ and hence $2a\alpha + b \neq 0$. Thus,
\[A = \frac{d}{2a\alpha + b}.\]

(3) Let $y_p = Ax^2e^{\alpha x}$. The reader can and will check that substitution into the
original differential equation gives

\[
\left(2a + 2 \overbrace{(2a\alpha + b)}^0 x + \overbrace{(a\alpha^2+b\alpha + c)}^0 x^2\right) A e^{\alpha x} = d e^{\alpha x}.\]

Thus, $A = d/2a$.
\hfill $\Box$

\vspace{.2in}
{\bf Student Exercises 2.} Find the general solution to each of the following.
\begin{itemize}
\item [a.] $y''+ y'- 6y = 3e^{2x} - e^x$.
\item [b.] $y'' + 4y' + 4y = 2e^{3x} + e^{-2x}$.
\item [c.] $y'' - y' = e^x + 2$.
\end{itemize}
  
\subsection{Polynomial Forcing Terms.}
Next we look at another family of examples. These are of the form
$ay'' + by' + cy = P(x)$, where $P(x)$ is a polynomial.


\vspace{.2in}
{\bf Example 6.} Find the general solution to $y'' + y = 2x^2 + x$. 


{\em Solution.} We know that the solution to the corresponding homogeneous equation is 
\[
y_h = C_1\cos x + C_2 \sin x.
\]
Now, what to try for $y_p$? We might guess that since, in a sense, ``two integrations'' are involved,
we should try $y_p = Ax^4 + Bx^3 + Cx^2 + Dx + E$. That 
means we have to find five coefficients. But, we realize that terms involving 
$x^4$ and $x^3$ cannot play any role, because there will not be any such terms
in $y''_p$ to cancel them out. So, we try 
\[
y_p = Ax^2 + B x +C.
\]
Then, we get
\[
y_p'' + y_p = 2A + Ax^2 + Bx + C = 2x^2 + x.
\]
Thus, $A=2$, $B=1$ and $C = -2A = -4$. Therefore, the general solution
is
\[
y =  C_1\cos x + C_2 \sin x + 2x^2 + x - 4.
\]
\hfill$\Box$


\vspace{.2in}
{\bf Theorem 3.} {\em Suppose $ay'' +by' + cy = P(x)$, where $P(x)$ is a
  polynomial of degree $n$ and $c\neq 0$.
  Let
  \[
  y_p = A_nx^n + \cdots A_1x + A_0.
  \]
  Then we can find values for the $A_i$'s that give a solution.}

\begin{proof} Let $P(x) = P_nx^n + P_{n-1}x^{n-1}+\cdots+P_1 x + P_0$. Then substituting $y_p$ into
the given differential equation gives  
\[
a\big(n(n-1)A_nx^{n-2}+\cdots+6A_3x+2A_2\big)+b\big(nA_nx^{n-1}+\cdots+2A_2x+A_1\big)
\]
\[
+c(A_nx^n + \cdots+ A_1x + A_0) = P(x) = P_nx^n + P_{n-1}x^{n-1}+\cdots+P_1 x + P_0.
\]
Thus, we will have a solution if we can solve the following system of
linear equations.

\begin{eqnarray*}
  cA_n  &=& P_n \\
 bnA_n + cA_{n-1} &=& P_{n-1} \\
 an(n -1)A_n + b(n - 1)A_{n-1} + cA_{n-2} &=& P_{n-2} \\
 a(n - 1)(n - 2)A_{n-1} + b(n - 2)A_{n-2} + cA_{n-3} &=& P_{n-3} \\
 a(n - 2)(n -3)A_{n-2} + b(n - 3)A_{n-3} + cA_{n-4} &=& P_{n-4} \\
a(n - 3)(n - 4)A_{n-3} + b(n - 4)A_{n-4} + cA_{n-5}  &=& P_{n-5} \\
&\vdots& \\
a6A_3 + b2A_2 + cA_1  &=& P_1 \\
a2A_2 + bA_1 + cA_0 &=& P_0 
\end{eqnarray*}
These are $n + 1$ equations and $n + 1$ unknowns. Since, $c \neq 0$ we can
solve the first equation for $A_n$. Once we know $A_n$ we can solve
the second equation for $A_{n-1}$. And so on. 
\end{proof}

{\bf Corollary.} If $c = 0$ we have that $y = 1$ is a solution of
$ay''+ by' =0$. Assume $b \neq 0$. Then to find a particular solution to
$ay'' + by' = P(x)$ you can let $y_p(x) = A_nx^{n+1}+ \cdots +A_1x^2+A_0x$, plug this into the the
differential equation and solve for the $A_i$'s, or let $v = y_0$ and reduce
the problem to a first order differential equation.

If $c = 0$ and $b = 0$, then $\{ x, 1\}$ is a fundamental solution set of
$ay'' = 0$. To find a particular solution to $ay'' = P(x)$ you can let
$y_p(x) = A_nx^{n+2}+ \cdots +A_1x^3+A_0x^2$, plug this into the the differential
equation and solve for the $A_i$'s, or just integrate twice!

We leave the proofs to the reader.

\vspace{.2in}
{\bf Student Exercises 3.} Find the general solution to each of the
following.
\begin{itemize}
\item [a.] $y'' - y' - 6y = x^3$
\item [b.] $y''- 2y' = 3x^2 + 2e^{2x} + e^x$
\end{itemize}

\subsection{Forcing Terms in the form a polynomial times an exponential function.}
Next we consider equations of the form
$ay'' + by' + cy = P(x)e^{\alpha x}$. The prescription is basically the same.

\vspace{.2in}
{\bf Theorem 4.} {\em Consider $ay'' + by' + cy = P(x)e^{\alpha x}$, where $P(x)$ is a
polynomial of degree $n$. Let
\[
Q(x) = A_n x^x + \cdots A_1 x + A_0.
\]
Let
\[
y_p = \left\{ \begin{array}{cl}
    Q(x)e^{\alpha x} & \mbox{if $\alpha$ is not a root of $ar^2 + br + c$,} \\
    xQ(x)e^{\alpha x} & \mbox{if $\alpha$ is a non-repeated root of $ar^2 + br + c$,} \\
    x^2Q(x)e^{\alpha x} & \mbox{if $\alpha$ is a repeated root of $ar^2 + br + c$.} 
    \end{array}\right.
\]
Then, one can find values for the $A_i$'s such that $y_p$ is a solution
to the given differential equation.}


\begin{proof}
  Let $U(x) = x^s Q(x)$, where $s$ can be 0, 1, or 2. Then $y'_p =
  U'e^{\alpha x} + \alpha U e^{\alpha x}$ and $y''_p = U''e^{\alpha x} 2\alpha U' e^{\alpha x} + \alpha^2 e^{\alpha x}$.
  Plug these into the original differential equation to get
  \[
    [aU''+(2a\alpha+b)U' + (a\alpha^2 + b \alpha + c)U]e^{\alpha x} = P(x)e^{\alpha x}.
  \]
  Divide both sides by $ e^{\alpha x}$. For $s=0$ we now have the same system of equation we had in Theorem 3. For $s=1$ and
  $s=2$ we use the same methods as in the corollary to Theorem 3.
\end{proof}


\vspace{.2in}
{\bf Example 7.} Find the general solution to $y'' - y' -6y= (x^2+1)e^{3x}$.

\begin{proof}[Solution.]
  The general solution to the homogeneous problem $y'' - y' -6y=0$ is
  \[
    y_h = C_1 e^{-2x} + C_2 e^{3x}.
  \]
  Therefore, we let
  \[
  y_p = x(Ax^2 + Bx + C) e^{3x}.
  \]
  Thus,
  \[
  y'_p = (3Ax^2 + 2Bx + C)e^{3x} + 3(Ax^3 + Bx^2 + Cx)e^{3x}
  \]
  and
  \[
  y''_p = (6Ax+2B)e^{3x}+6(3Ax^2+2Bx+C)e^{3x}+9(Ax^3+Bx^2+Cx)e^{3x}.
  \]
  Thus,
  \[
  y''_p-y'_p-6y_p = (6Ax+2B)e^{3x}+6(3Ax^2+2Bx+C)e^{3x}+9(Ax^3+Bx^2+Cx)e^{3x}
-(3Ax^2+2Bx+C)e^{3x} -3(Ax^3+Bx^2+Cx)e^{3x} -6(Ax^3+Bx^2+Cx)e^{3x}.
  \]
We regroup the terms on the right hand side as follows
\[
[(9A - 3A - 6A)x^3 + (18A + 9B - 3A - 3B - 6B)x^2+
\]
\[
(6A + 12B + 9C - 2B - 3C - 6C)x + (2B + 6C - C)] e^{3x}.
\]
This simplifies to
\[
[15Ax^2 + (6A + 10B)x + (2B + 5C)]e^{3x}.
\]
Setting this equal to $(x^2 + 1)e^{3x}$ gives three equations and three
unknowns,
\[
15A = 1, \:\:\: 6A + 10B = 0, \:\:\: 2B + 5C = 1.
\]
Thus,
\[
A = 1/15, B = -6/150 = -1/25, C = 27/125.
\]
Therefore, the general solution is
\[
y = C_1e^{2x} + C_2e^{3x} + \left( \frac{x^3}{15} - \frac{x^2}{25} + \frac{27x}{125}\right) e^{3x}. 
\]
\end{proof}


{\bf  Student Exercises 4.}      
\begin{itemize}
\item [a.] $y'' - y' - 6y = xe^x$
\item [b.] $y''- 2y' = x^2e^{2x}$
\end{itemize}

\subsection{Forcing Terms involving sine or cosine.} Now we are
going to up the ante once again. We shall consider equations of the
forms
\[
ay'' + by' + cy = P(x)e^{\alpha x}\sin \beta x
\]
and
\[
ay'' + by' + cy = P(x)e^{\alpha x}\cos \beta x
\]
where $P(x)$ is a polynomial. We will do some simple examples before stating the general result.


\vspace{.2in}
{\bf Example 8.} Find the general solution to $y'' - y' - 6y = \sin x$.

\begin{proof}[Solution.]
The solution to the corresponding homogeneous problem is
\[y_h = C_1e^{-2x} + C_2e^{3x}.\]
We guess that $y_p$ is of the form $A\sin x+B \cos x$. Why is this a good
guess? Because, $y''_p - y'_p - 6y_p$ will be a linear combination of sines
and cosines and then we might be able to choose A and B so that
the cosines cancel out and the coefficients of sines add to one. Let's
try.
\[
y_p = A \sin x + B \cos x
\]
\[
y'_p = A\cos x - B \sin x
\]
\[
y''_p = -  A\sin x - B \cos x
\]

Thus,
\[
y''_p - y'_p - 6y_p = (-A + B - 6A) \sin x + (-B - A - 6B) \cos x.
\]

Thus, we require that $-7A + B = 1$ and $-A - 7B = 0$. Therefore,
$A = -7/50$ and $B = 1/50$. The general solution is

\[
y = C_1e^{-2x} + C_2e^{3x} - \tfrac{ 7}{50} \sin x + \tfrac{1}{50}\cos x.
\]
\end{proof} 

{\bf Example 9.} Find the general solution to $y'' - y' - 6y = e^x \sin x$.

\begin{proof}[Solution.]
Only the details change. Again $y_h = C_1e^{-2x} + C_2e^{3x}$. Our
guess for a particular solution this time is
\[
y_p = Ae^x \sin x + Be^x \cos x.
\]
Think about why this is a reasonable guess. Plug it in to the original equation and solve for $A$ and $B$. You
should get $A = -7/50$ and $B = -1/50$. Thus, the general solution
is
\[
y = C_1e^{-2x} + C_2e^{3x} - \tfrac{ 7}{50} e^x \sin x - \tfrac{1}{50} e^x \cos x.
\]
\end{proof} 

One more example, then we will state the general result.

\vspace{.2in}
{\bf Example 10.} Find the general solution to $y''- 2y' + 2y = e^x \sin x$. 

\begin{proof}[Solution.]
Now, $y_h = C_1e^x \sin x + C_2e^x \cos x$. Thus, we cannot use $y_p = Ae^x \sin x + Be^x \cos x$, because the terms are
solutions to the homogeneous problem. Let's try it, in case you are
skeptical - as you should be.
\[
y''_p + 2y'_p + 2y_p = (2Be^x \sin x + 2Ae^x \cos x) -
\]
\[
2((A - B)e^x \sin x + (A + B)e^x \cos x) + 2(Ae^x \sin x + Be^x \cos x)
\]
\[
= (2B +2(A-B)+2A)e^x \sin x+(2A-2(A+B)+2B)e^x \cos x =
\]
\[
0 e^x \sin x + 0 e^x \cos x = 0 \neq e^x \sin x.
\]
Thus, there are no values of $A$ and $B$ that would work.
By now you should realize what needs to be done. We let
\[
y_p = Axe^x \sin x + Bxe^x \cos x.
\]
We leave it for you work out that the general solution is
\[
y = C_1e^x \sin x + C_2e^x \cos x - \tfrac{x}{2}e^x \cos x.
\]
\end{proof} 

\vspace{.2in}
{\bf Theorem 5.} {\em Consider an equation of the form
\[ay'' + by' + cy = P(x)e^{\alpha x} \sin \beta x\]
or
\[ay'' + by' + cy = P(x)e^{\alpha x} \cos \beta x,\]
where $P(x)$ is a polynomial of degree $n$.
If $\alpha + \beta i$ is not a root of the characteristic polynomial, then let
\[y_p = A(x)e^{\alpha x} \sin \beta x + B(x)e^{\alpha x} \cos \beta x,
\]
where
\[
A(x) = A_nx^n + A_{n-1}x^{n-1} + \cdots + A_1x + A_0,
\]
and
\[
B(x) = B_nx^n + B_{n-1}x^{n-1} + \cdots + B_1x + B_0.
\]
Then there exists a solution for the coefficients, $A_n,\dots,A_0, B_n,\dots,B_0$, that gives a solution to the
original equation.

If $\alpha + \beta i$ is a root of the characteristic polynomial, then let
\[
y_p = xA(x)e^{\alpha x} \sin \beta x + xB(x)e^{\alpha x} \cos \beta x,
\]
where A(x) and B(x) are as before. Then there exists a solution
for the coefficients, $A_n,\dots,A_0, B_n,\dots,B_0$, that gives a solution
to the original equation.
As usual, the general solution is of the form $y = y_h+y_p$ where $y_h$
is the general solution to the corresponding homogeneous problem
\[ay'' + by' + cy = 0.\]}

\begin{proof}[Outline of Proof.]
In both cases you use substitution, compute the
derivatives and simplify. You end up with $2n$ equations and $2n$
unknowns. Then you solve for the unknowns, that is the coefficients
$A_n,\dots,A_0$, and $B_n,\dots,B_0.$
\end{proof}

These types of problems are too tedious to put on a test. Most people
would do them by computer. However, you may be asked to just give $y_h$ and
$y_p$ without solving for the coefficients.

\vspace{.2in}
{\bf Example 11.} Find the general solution to $2y'' - 7y' + 6y = (x^2 + 1)e^{2x} \sin 3x.$

\begin{proof}[Solution.]
The characteristic polynomial is $2r^2-2r+6 = (r-2)(2r-3)$.
The roots are real and distinct. Thus,
\[
y_h(x) = C_1e^{2x} + C_2e^{\frac{3x}{2}}.
\]
Since $2 + 3i$ is not a root of the characteristic polynomial we
have that $y_p$ will take the following form.
\[
y_p(x) = (A_2x^2+A_1x+A_0)e^{2x} \sin 3x+(B_2x^2+B_1x+B_0)e^{2x} \cos 3x.
\]
Substitution into the given differential equation gives six equations in six unknowns. Solving for
the coefficients gives
\[
A_2 = -\tfrac{2}{37}, \:\: A_1 = \tfrac{218}{12,321}, \:\: A_0 = -\tfrac{1026}{50,653},
\]
\[
B_2 = -\tfrac{12,321}{1,367,631},  \:\: B_1= -\tfrac{95,904}{1,367,631}, \:\:
B_0 = \tfrac{3,449}{1,367,631}.
\]
(If you think I did that by hand, you probably still believe
Mexico is paying for ``The Wall".)
\end{proof}  


{\bf Example 12.} Find the general solution to $y'' + y = x \cos x$.

\begin{proof}[Solution.]
  The roots of the characteristic polynomial are $\pm i$. Hence,
  \[
  y_h = C_1 \sin x + C_2 \cos x.
  \]
  Notice we can write the forcing term as $xe^{0x} \cos 1x$. Since $0+i$
is a root of the characteristic polynomial, the form of $y_p$ is the
following.
\[
y_p  = x(A_1x + A_0) \sin x + x(B_1x + B_0) \cos x.
\]
Substitution gives four equations in four unknowns. Solving for
these give
\[
A_1 = B_0 = 1/4 \:\:\&\:\: A_0 = B_1 = 0.
\]
Therefore the general solution is
\[
y = C_1 \sin x + C_2 \cos x + \tfrac{x^2}{4}\sin x + \frac{x}{4} \cos x.
\]

Note: When I did this on a computer using Maple I got the
general solution to be
\begin{center}\tt\small
y(x) = sin(x)*\_C2+ cos(x)*\_C1+1/4*x*cos(x)+1/4*sin(x)*x$\wedge$2-1/4*sin(x).
\end{center}
The {\tt -1/4*sin(x)} at the end does not seem to be right. But,
notice it can be combined with {\tt sin(x)*\_C2}. It was just a quirk
of the algorithm Maple used.
\end{proof}  



{\bf Student Exercises 5.}
\begin{itemize}
\item [a.] $y'' - y' - 6y = e^x \sin x$
\item [b.] $y''- 2y'+2y = e^x \sin x$
\end{itemize}




\subsection{Summary.} Table 3.5.1 in your textbook is a summary. I have
made an expanded form of it on the course website. For the 
problems below use it to find a suitable $y_p$.
}

...

\end{document}




