76.3.23 problem 28

Internal problem ID [17323]
Book : Differential equations. An introduction to modern methods and applications. James Brannan, William E. Boyce. Third edition. Wiley 2015
Section : Chapter 2. First order differential equations. Section 2.4 (Differences between linear and nonlinear equations). Problems at page 79
Problem number : 28
Date solved : Monday, March 31, 2025 at 03:52:41 PM
CAS classification : [_separable]

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

With initial conditions

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

Maple. Time used: 0.074 (sec). Leaf size: 25
ode:=diff(y(t),t)+piecewise(0 <= t and t <= 1,2,1 < t,1)*y(t) = 0; 
ic:=y(0) = 1; 
dsolve([ode,ic],y(t), singsol=all);
 
\[ y = \left \{\begin {array}{cc} 1 & t <0 \\ {\mathrm e}^{-2 t} & t <1 \\ {\mathrm e}^{-t -1} & 1\le t \end {array}\right . \]
Mathematica. Time used: 0.039 (sec). Leaf size: 28
ode=D[y[t],t]+Piecewise[{{2,0<=t<=1},{1,t>1}}]*y[t]==0; 
ic={y[0]==1}; 
DSolve[{ode,ic},y[t],t,IncludeSingularSolutions->True]
 
\[ y(t)\to \begin {array}{cc} \{ & \begin {array}{cc} 1 & t\leq 0 \\ e^{-t-1} & t>1 \\ e^{-2 t} & \text {True} \\ \end {array} \\ \end {array} \]
Sympy. Time used: 12.394 (sec). Leaf size: 37
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 = {} 
dsolve(ode,func=y(t),ics=ics)
 
\[ \left [ y{\left (t \right )} = \begin {cases} \frac {C_{1} e^{2 t}}{e^{2 t} + 1} & \text {for}\: t \leq 1 \wedge t > 0 \\\text {NaN} & \text {otherwise} \end {cases}, \ y{\left (t \right )} = \begin {cases} \frac {C_{1} e^{t + 1}}{e^{t + 1} + 1} & \text {for}\: t > 0 \wedge t > 1 \\\text {NaN} & \text {otherwise} \end {cases}\right ] \]