90.27.2 problem 2

Internal problem ID [25412]
Book : Ordinary Differential Equations. By William Adkins and Mark G Davidson. Springer. NY. 2010. ISBN 978-1-4614-3617-1
Section : Chapter 6. Discontinuous Functions and the Laplace Transform. Exercises at page 425
Problem number : 2
Date solved : Friday, October 03, 2025 at 12:01:16 AM
CAS classification : [[_linear, `class A`]]

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

Using Laplace method With initial conditions

\begin{align*} y \left (0\right )&=1 \\ \end{align*}
Maple. Time used: 0.068 (sec). Leaf size: 29
ode:=diff(y(t),t)+5*y(t) = piecewise(t < 1 and 0 <= t,-5,1 <= t,5); 
ic:=[y(0) = 1]; 
dsolve([ode,op(ic)],y(t),method='laplace');
 
\[ y = 2 \,{\mathrm e}^{-5 t}+\left (\left \{\begin {array}{cc} -1 & t <1 \\ 1-2 \,{\mathrm e}^{5-5 t} & 1\le t \end {array}\right .\right ) \]
Mathematica. Time used: 0.047 (sec). Leaf size: 50
ode=D[y[t],{t,1}]+5*y[t]==Piecewise[{ {-5, 0<=t<1}, {5,t>=1}}]; 
ic={y[0]==1}; 
DSolve[{ode,ic},y[t],t,IncludeSingularSolutions->True]
 
\begin{align*} y(t)&\to \begin {array}{cc} \{ & \begin {array}{cc} e^{-5 t} & t\leq 0 \\ -1+2 e^{-5 t} & 0<t\leq 1 \\ e^{-5 t} \left (2-2 e^5+e^{5 t}\right ) & \text {True} \\ \end {array} \\ \end {array} \end{align*}
Sympy
from sympy import * 
t = symbols("t") 
y = Function("y") 
ode = Eq(-Piecewise((-5, (t >= 0) & (t < 1)), (5, (t >= 1) & (t < oo))) + 5*y(t) + Derivative(y(t), t),0) 
ics = {y(0): 1} 
dsolve(ode,func=y(t),ics=ics)