76.3.23 problem 28

Internal problem ID [17315]
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 : Thursday, March 13, 2025 at 09:25:43 AM
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.811 (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.033 (sec). Leaf size: 37
ode=D[y[t],t]+Piecewise[{{2,0<=t<=1},{1,t>1}}]*y[t]==0; 
ic={}; 
DSolve[{ode,ic},y[t],t,IncludeSingularSolutions->True]
 
\begin{align*} y(t)\to c_1 \exp \left ( \begin {array}{cc} \{ & \begin {array}{cc} 0 & t\leq 0 \\ -2 t & 0<t\leq 1 \\ -t-1 & \text {True} \\ \end {array} \\ \end {array} \right ) \\ y(t)\to 0 \\ \end{align*}
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 ] \]