74.5.39 problem 43

Internal problem ID [15924]
Book : INTRODUCTORY DIFFERENTIAL EQUATIONS. Martha L. Abell, James P. Braselton. Fourth edition 2014. ElScAe. 2014
Section : Chapter 2. First Order Equations. Exercises 2.3, page 49
Problem number : 43
Date solved : Thursday, March 13, 2025 at 06:57:36 AM
CAS classification : [[_linear, `class A`]]

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

With initial conditions

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

Maple. Time used: 0.686 (sec). Leaf size: 33
ode:=diff(y(t),t)+y(t) = piecewise(0 <= t and t < 1,t,1 <= t,0); 
ic:=y(0) = 1; 
dsolve([ode,ic],y(t), singsol=all);
 
\[ y = \left \{\begin {array}{cc} {\mathrm e}^{-t} & t <0 \\ 2 \,{\mathrm e}^{-t}+t -1 & t <1 \\ 2 \,{\mathrm e}^{-t} & 1\le t \end {array}\right . \]
Mathematica. Time used: 0.066 (sec). Leaf size: 37
ode=D[y[t],t]+y[t]==Piecewise[{{t,0<=t<1},{0,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 e^{-t} & t>1 \\ t+2 e^{-t}-1 & \text {True} \\ \end {array} \\ \end {array} \]
Sympy
from sympy import * 
t = symbols("t") 
y = Function("y") 
ode = Eq(-Piecewise((t, (t >= 0) & (t < 1)), (0, t >= 1)) + Derivative(y(t), t),0) 
ics = {y(0): 1} 
dsolve(ode,func=y(t),ics=ics)
 
ValueError : Couldnt solve for initial conditions