\documentclass[a4paper,12pt]{article}
\setlength\oddsidemargin{0pt} \setlength\evensidemargin{0pt}
\setlength\topmargin{0pt}
\begin{document}
\parindent=0pt
{\bf Exam Question

Topic: LaplaceODE}

Find the solution of the differential equation $$y''+y=r(x),$$
where

$$ r(x)=\left\{
\begin{array}{ll} 0 & \mbox{if\ \ $0< x< 2$};\\ 1 & \mbox{otherwise},\end{array} \right. $$
and where $y(0)=1;\ \ y'(0)=0.$ \vspace{0.5in}

{\bf Solution}

Using the Heaviside function gives $r(x)=H(x-2).$

Transforming the differential equation gives $\displaystyle
p^2\bar{y}-p+\bar{y}=\frac{\mathrm{e}^{-2p}}{p}.$
\begin{eqnarray*}
\bar{y}&=&\frac{\mathrm{e}^{-2p}}{p(p^2+1)}+\frac{p}{p^2+1}\\ &=&
\frac{\mathrm{e}^{-2p}}{p}-\frac{\mathrm{e}^{-2p}.p}{p^2+1}+\frac{p}{p^2+1}\\
y&=&H(x-2)-H(x-2)\cos(x-2)+\cos x.
\end{eqnarray*}



\end{document}
