20.22.16 problem Problem 46 part a

Internal problem ID [3971]
Book : Differential equations and linear algebra, Stephen W. Goode and Scott A Annin. Fourth edition, 2015
Section : Chapter 10, The Laplace Transform and Some Elementary Applications. Exercises for 10.7. page 704
Problem number : Problem 46 part a
Date solved : Sunday, March 30, 2025 at 02:13:22 AM
CAS classification : [[_linear, `class A`]]

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