90.26.5 problem 27

Internal problem ID [25406]
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 : 27
Date solved : Friday, October 03, 2025 at 12:01:12 AM
CAS classification : [[_linear, `class A`]]

\begin{align*} -y+y^{\prime }&=\left \{\begin {array}{cc} 0 & 0\le t <1 \\ t -1 & 1\le t <2 \\ 3-t & 2\le t <3 \\ 0 & 3\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.097 (sec). Leaf size: 68
ode:=diff(y(t),t)-y(t) = piecewise(0 <= t and t < 1,0,1 <= t and t < 2,t-1,2 <= t and t < 3,3-t,3 <= t and t < infinity,0); 
ic:=[y(0) = 0]; 
dsolve([ode,op(ic)],y(t),method='laplace');
 
\[ y = \left \{\begin {array}{cc} 0 & t <1 \\ -1 & t =1 \\ -t +{\mathrm e}^{t -1} & t <2 \\ {\mathrm e} & t =2 \\ t -2 \,{\mathrm e}^{t -2}+{\mathrm e}^{t -1}-2 & t <3 \\ -2 \,{\mathrm e}+{\mathrm e}^{2} & t =3 \\ 4 \sinh \left (\frac {1}{2}\right )^{2} {\mathrm e}^{t -2} & 3<t \end {array}\right . \]
Mathematica. Time used: 0.087 (sec). Leaf size: 72
ode=D[y[t],{t,1}]-y[t]==Piecewise[{ {1,0<=t<1}, {t-1,1<=t<2},{3-t,2<=t<3}, {0,3<=t<Infinity}}]; 
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 1 \\ e^t-t & 1<t\leq 2 \\ t-2 e^{t-2}+e^t-2 & 2<t\leq 3 \\ e^{t-3} \left (1-2 e+e^3\right ) & \text {True} \\ \end {array} \\ \end {array} \end{align*}
Sympy
from sympy import * 
t = symbols("t") 
y = Function("y") 
ode = Eq(-Piecewise((0, (t >= 0) & (t < 1)), (t - 1, (t >= 1) & (t < 2)), (3 - t, (t >= 2) & (t < 3)), (0, (t >= 3) & (t < oo))) + 3*y(t) + Derivative(y(t), t),0) 
ics = {y(0): 0} 
dsolve(ode,func=y(t),ics=ics)