90.26.3 problem 25

Internal problem ID [25404]
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 379
Problem number : 25
Date solved : Friday, October 03, 2025 at 12:01:11 AM
CAS classification : [[_linear, `class A`]]

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

Using Laplace method With initial conditions

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