11.4.2 problem 2

Internal problem ID [1496]
Book : Elementary differential equations and boundary value problems, 11th ed., Boyce, DiPrima, Meade
Section : Chapter 6.4, The Laplace Transform. Differential equations with discontinuous forcing functions. page 268
Problem number : 2
Date solved : Saturday, March 29, 2025 at 10:56:31 PM
CAS classification : [[_2nd_order, _linear, _nonhomogeneous]]

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

Using Laplace method With initial conditions

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

Maple. Time used: 0.308 (sec). Leaf size: 76
ode:=diff(diff(y(t),t),t)+2*diff(y(t),t)+2*y(t) = piecewise(Pi <= t and t < 2*Pi,1,0); 
ic:=y(0) = 0, D(y)(0) = 1; 
dsolve([ode,ic],y(t),method='laplace');
 
\[ y = \left \{\begin {array}{cc} {\mathrm e}^{-t} \sin \left (t \right ) & t <\pi \\ {\mathrm e}^{-t} \sin \left (t \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 (2 \sin \left (t \right )+\left (\sin \left (t \right )+\cos \left (t \right )\right ) {\mathrm e}^{2 \pi }+{\mathrm e}^{\pi } \left (\sin \left (t \right )+\cos \left (t \right )\right )\right )}{2} & 2 \pi \le t \end {array}\right . \]
Mathematica. Time used: 0.048 (sec). Leaf size: 89
ode=D[y[t],{t,2}]+2*D[y[t],t]+2*y[t]==Piecewise[{{1,Pi<=t<2*Pi},{0,True}}]; 
ic={y[0]==0,Derivative[1][y][0] ==1}; 
DSolve[{ode,ic},y[t],t,IncludeSingularSolutions->True]
 
\[ y(t)\to \begin {array}{cc} \{ & \begin {array}{cc} e^{-t} \sin (t) & t\leq \pi \\ \frac {1}{2} e^{-t} \left (e^{\pi } \cos (t)+e^t+\left (2+e^{\pi }\right ) \sin (t)\right ) & \pi <t\leq 2 \pi \\ \frac {1}{2} e^{-t} \left (e^{\pi } \left (1+e^{\pi }\right ) \cos (t)+\left (2+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((1, (t >= pi) & (t < 2*pi)), (0, True)) + 2*y(t) + 2*Derivative(y(t), t) + Derivative(y(t), (t, 2)),0) 
ics = {y(0): 0, Subs(Derivative(y(t), t), t, 0): 1} 
dsolve(ode,func=y(t),ics=ics)