76.20.2 problem 2

Internal problem ID [17679]
Book : Differential equations. An introduction to modern methods and applications. James Brannan, William E. Boyce. Third edition. Wiley 2015
Section : Chapter 5. The Laplace transform. Section 5.6 (Differential equations with Discontinuous Forcing Functions). Problems at page 342
Problem number : 2
Date solved : Monday, March 31, 2025 at 04:24:18 PM
CAS classification : [[_2nd_order, _linear, _nonhomogeneous]]

\begin{align*} y^{\prime \prime }+2 y^{\prime }+2 y&=\left \{\begin {array}{cc} 0 & 0\le t <\pi \\ 1 & \pi \le t \le 2 \pi \\ 0 & t \le 2 \pi \end {array}\right . \end{align*}

Using Laplace method With initial conditions

\begin{align*} y \left (0\right )&=5\\ y^{\prime }\left (0\right )&=4 \end{align*}

Maple. Time used: 0.324 (sec). Leaf size: 90
ode:=diff(diff(y(t),t),t)+2*diff(y(t),t)+2*y(t) = piecewise(0 <= t and t < Pi,0,Pi <= t and t <= 2*Pi,1,t <= 2*Pi,0); 
ic:=y(0) = 5, D(y)(0) = 4; 
dsolve([ode,ic],y(t),method='laplace');
 
\[ y = \left \{\begin {array}{cc} {\mathrm e}^{-t} \left (5 \cos \left (t \right )+9 \sin \left (t \right )\right ) & t <\pi \\ {\mathrm e}^{-t} \left (5 \cos \left (t \right )+9 \sin \left (t \right )\right )+\frac {1}{2}+\frac {{\mathrm e}^{\pi -t} \left (\sin \left (t \right )+\cos \left (t \right )\right )}{2} & t <2 \pi \\ \frac {{\mathrm e}^{-t} \left (\left ({\mathrm e}^{\pi }+{\mathrm e}^{2 \pi }+10\right ) \cos \left (t \right )+\sin \left (t \right ) \left ({\mathrm e}^{\pi }+{\mathrm e}^{2 \pi }+18\right )\right )}{2} & 2 \pi \le t \end {array}\right . \]
Mathematica. Time used: 0.046 (sec). Leaf size: 100
ode=D[y[t],{t,2}]+2*D[y[t],t]+2*y[t]==Piecewise[{  {0,0<= t <Pi}, {1,Pi<= t <=2*Pi}, {0, t>=2*Pi}}]; 
ic={y[0]==5,Derivative[1][y][0] ==4}; 
DSolve[{ode,ic},y[t],t,IncludeSingularSolutions->True]
 
\[ y(t)\to \begin {array}{cc} \{ & \begin {array}{cc} e^{-t} (5 \cos (t)+9 \sin (t)) & t\leq \pi \\ \frac {1}{2} e^{-t} \left (\left (10+e^{\pi }\right ) \cos (t)+e^t+\left (18+e^{\pi }\right ) \sin (t)\right ) & \pi <t\leq 2 \pi \\ \frac {1}{2} e^{-t} \left (\left (10+e^{\pi }+e^{2 \pi }\right ) \cos (t)+\left (18+e^{\pi }+e^{2 \pi }\right ) \sin (t)\right ) & \text {True} \\ \end {array} \\ \end {array} \]
Sympy
from sympy import * 
t = symbols("t") 
y = Function("y") 
ode = Eq(-Piecewise((0, (t >= 0) & (t < pi)), (1, (t >= pi) & (t <= 2*pi)), (0, t >= 2*pi)) + 2*y(t) + 2*Derivative(y(t), t) + Derivative(y(t), (t, 2)),0) 
ics = {y(0): 5, Subs(Derivative(y(t), t), t, 0): 4} 
dsolve(ode,func=y(t),ics=ics)