Now let us consider a harmonic oscillator with discontinuous forcing,
\begin{gather*}
y'' + 2 y' + 5y = h(t)\\
y(0) = y'(0) = 0,
\end{gather*}
where \(h(t)\) is given by
\begin{equation*}
h(t)
=
\begin{cases}
5 & t \lt 7 \\
0 & t \geq 7.
\end{cases}
\end{equation*}
That is, \(h(t) = 5 (1 - u_7(t))\text{.}\) We may consider this to be a mass-spring system sliding on a table, where the mass is one unit, the spring constant is 5, and the damping coefficient is 2. When \(t \lt 7\) the table is tilted so that gravity provides a force of 5 units when stretching the spring. At time \(t = 7\text{,}\) the table is suddenly returned to the level position.
Taking the Laplace transform of both sides of \(y'' + 2 y' + 5y = h(t)\text{,}\) we obtain
\begin{equation*}
[s^2 Y(s) -sy(0) - y'(0)] + 2 [sY(s) - y(0)] + 5Y(s) = {\mathcal L}(h),
\end{equation*}
where \({\mathcal L}(y)(s) = Y(s)\text{.}\) Substituting the initial conditions and evaluating the Laplace transform on the right, we have
\begin{equation*}
(s^2 + 2s + 5)Y(s) = 5 \left( \frac{1}{s} - \frac{e^{-7s}}{s} \right).
\end{equation*}
Solving for \(Y(s)\text{,}\) we have
\begin{equation*}
Y(s) = \frac{5}{s(s^2 + 2s + 5)} - \frac{5e^{-7s}}{s(s^2 + 2s + 5)}
\end{equation*}
and
\begin{equation*}
y = {\mathcal L}^{-1} \left( \frac{5}{s(s^2 + 2s + 5)} - \frac{5e^{-7s}}{s(s^2 + 2s + 5)} \right).
\end{equation*}
Using partial fractions, we can rewrite the first term as
\begin{equation*}
\frac{5}{s(s^2 + 2s + 5)} = \frac{1}{s} - \frac{s + 2}{s^2 + 2s + 5}.
\end{equation*}
The inverse Laplace transform of \(1/s\) is 1. To find the inverse Laplace transform of the second term, we complete the square of the denominator,
\begin{align*}
\frac{s + 2}{s^2 + 2s + 5} & = \frac{s + 2}{(s+ 1)^2 + 4}\\
& = \frac{s + 1}{(s+ 1)^2 + 4} + \frac{1}{(s+ 1)^2 + 4}\\
& = \frac{s + 1}{(s+ 1)^2 + 4} + \frac{1}{2} \frac{2}{(s+ 1)^2 + 4}.
\end{align*}
Consequently,
\begin{equation*}
{\mathcal L}^{-1} \left( \frac{s + 2}{s^2 + 2s + 5} \right) = e^{-t} \cos 2t + \frac{1}{2} e^{-t} \sin 2t = e^{-t} \left( \cos 2t + \frac{1}{2} \sin 2t \right).
\end{equation*}
and
\begin{equation*}
{\mathcal L}^{-1} \left( \frac{5}{s(s^2 + 2s + 5)} \right) = {\mathcal L}^{-1} \left( \frac{1}{s} - \frac{s + 2}{s^2 + 2s + 5} \right) = 1 - e^{-t} \left( \cos 2t + \frac{1}{2} \sin 2t \right).
\end{equation*}
We can compute the inverse Laplace transform of
\begin{equation*}
\frac{5e^{-7s}}{s(s^2 + 2s + 5)}
\end{equation*}
using the Heaviside function \(u_7(t)\) and the inverse Laplace transform that we just calculated to obtain
\begin{equation*}
{\mathcal L}^{-1} \left( \frac{5e^{-7s}}{s(s^2 + 2s + 5)} \right) = u_7(t) \left( 1 - e^{-(t-7)} \left( \cos 2(t - 7) + \frac{1}{2} \sin 2(t - 7) \right) \right).
\end{equation*}
Therefore, the solution to our original initial value problem is
\begin{equation*}
y(t) = 1 - e^{-t} \left( \cos 2t + \frac{1}{2} \sin 2t \right) - u_7(t) \left( 1 - e^{-(t-7)} \left( \cos 2(t - 7) + \frac{1}{2} \sin 2(t - 7) \right) \right).
\end{equation*}