\documentclass[12pt]{article}
\newcommand{\ds}{\displaystyle}
\newcommand{\pl}{\partial}
\newcommand{\dy}{\frac{dy}{dx}}
\parindent=0pt
\begin{document}

{\bf Question}

Solve the following differential equations subject to the given
initial conditions:

\begin{enumerate}

\item $y'' +y' -2y=2e^x \quad y(0)=0 \quad y'(0)=1 $

\item $y'' -2y' +y=e^x+4 \quad y(0)=1 \quad y'(0)=1 \qquad(*)$

\item $y''+2y'+5y=4e^{-x}\cos 2x \quad y(0)=1 \quad y'(0)=0$

\end{enumerate}



\vspace{0.25in}

{\bf Answer}

\begin{enumerate}
\item
Auxiliary equation is:  $m^2+m-2=0$ \qquad giving $m=-2,1$ \\
Hence the complementary function is: $y_{cf}=Ae^{-2x}+Be^{x}$\\
Note that the right hand side of the equation contains a linear
combination of the complementary function so try the particular
integral: $y_p=axe^{2x}$\\ Equation becomes: $\left(2ae^x +axe^x
\right)+\left(ae^x +axe^x \right) -2\left(axe^x \right) =2e^{x}$\\
Hence $3ae^x=2e^{x}$\qquad so that \qquad a=2/3\\ The general
solution is: $\ds y=Ae^{-2x}+Be^{x}+\frac{2}{3}xe^{x}$\\ Imposing
$y(0)=1$ gives\qquad $A+B=0$\\ Imposing =$y'(0)=1$ gives\qquad
$-2A+B+2/3=1$\\ Hence $\ds A=\frac{-1}{9}$ and $\ds B=\frac{1}{9}$
Hence $\ds
y=\frac{1}{9}\left(e^{x}-e^{-2x}\right)+\frac{2}{3}xe^{x}$\\


\item
Auxiliary equation is:  $m^2-2m+1=0$ \qquad giving $m=1,1$ \\
Hence the complementary function is: $\ds y_{cf}=e^{x}(A+Bx)$\\
Note that the right hand side contains a term, $e^x$ which is in
the complementary function and that $xe^x$ is also on the
complementary function.\\ Hence try the particular integral: $\ds
y_p=ax^2e^{x}+ b$\\ (the $a$ term allows for the $e^x$ in the
right hand side and the $b$ term allows for the constant, $4$.)
Equation becomes:\\ $\ds \left(2ae^{x}+4axe^{x}+ax^2e^{x}\right)
-2\left(2axe^{x}+ax^2e^{x}\right)+\left(ax^2e^{x}+b\right)=e^{x}+4$\\
and simplifying gives: $2ae^{-x}+b=e^{-x}+4$ so that $a=1/2$ and
$b=4$\\ The general solution is: $\ds
y=e^{x}(A+Bx)+\frac{1}{2}x^2e^{x}+4$\\ Imposing $y(0)=1$
gives\qquad $A+4=1$\\ Imposing $y'(0)=1$ gives \qquad $A+B=1$\\ so
that $A=-3$ and $B=4$.\\
 Giving the solution
$\ds y=e^{x}(4x-3)+\frac{1}{2}x^2e^{x}+4$


\item
Auxiliary equation is:  $m^2+2m+5=0$ \qquad giving $m=-1\pm 2i$ \\
Hence the complementary function is: $\ds y_{cf}=e^{-x}(A\cos(2x)
+B\sin(2x))$\\ Note that the right hand side of the equation
contains a linear combination of the complementary function so:\\
try the particular integral: $\ds y_p=axe^{-x}\sin(2x) +
bxe^{-x}\cos(2x)$\\ Equation becomes:\\ $\ds \Big(
a(-2e^{-x}\sin(2x) + 4 e^{-x}\cos(2x) - 4xe^{-x}\cos(2x) -
3xe^{-x}\sin(2x))$\\ $\ds +b(-4e^{-x}\sin(2x) - 2 e^{-x}\cos(2x) -
3xe^{-x}\cos(2x) +4xe^{-x}\sin(2x)) \Big)$\\ $\ds
+2\Big(a(e^{-x}\sin(2x) + 2xe^{-x}\cos(2x) - xe^{-x}\sin(2x)) +
b(e^{-x}\cos(2x) - 2xe^{-x}\sin(2x) - xe^{-x}\cos(2x)) \Big)
+5\Big(axe^{-x}\sin(2x) + bxe^{-x}\cos(2x)\Big)
=4e^{-x}\cos(2x)$\\ Hence\\ $\ds \Big( a(-2e^{-x}\sin(2x) + 4
e^{-x}\cos(2x)) +b(-4e^{-x}\sin(2x) - 2 e^{-x}\cos(2x)) \Big)\\
+2\Big(a(e^{-x}\sin(2x)) + b(e^{-x}\cos(2x)) \Big)
=4e^{-x}\cos(2x)$\\ so that \qquad $a=1$ and $b=0$\\ The general
solution is: $\ds y=e^{-x}(A\cos(2x) +B\sin(2x))+xe^{-x}\sin 2x$\\
Imposing $y(0)=1$ gives\qquad $A=1$\\ Imposing $y'(0)=0$
gives\qquad $-A+2B=0$ or $B=1/2$\\ Hence $\ds y= e^{-x}(\cos(2x)
+\frac{1}{2}\sin(2x))+xe^{-x}\sin 2x$

(note that the particular integral for this last question can also
be found by writing the problem in the form $$
y''+2y'+5y=2\left(e^{(-1+2i)x}+e^{(-1-2i)x} \right) $$ and then
seeking a particular integral of the form
$y_p=axe^{(-1+2i)x}+bxe^{(-1-2i)x}$\\
 but care must be taken as both
$a$ and $b$ here will be complex and to get a real solution we
shall require $b=a^*$ (where * means complex conjugate).)

\end{enumerate}



\end{document}
