67.1.45 problem 2.9 c

Internal problem ID [16310]
Book : Ordinary Differential Equations. An introduction to the fundamentals. Kenneth B. Howell. second edition. CRC Press. FL, USA. 2020
Section : Chapter 2. Integration and differential equations. Additional exercises. page 32
Problem number : 2.9 c
Date solved : Thursday, October 02, 2025 at 10:45:36 AM
CAS classification : [_quadrature]

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

With initial conditions

\begin{align*} y \left (0\right )&=0 \\ \end{align*}
Maple. Time used: 0.024 (sec). Leaf size: 19
ode:=diff(y(x),x) = piecewise(x < 1,0,1 <= x and x < 2,1,2 <= x,0); 
ic:=[y(0) = 0]; 
dsolve([ode,op(ic)],y(x), singsol=all);
 
\[ y = \left \{\begin {array}{cc} 0 & x <1 \\ x -1 & x <2 \\ 1 & 2\le x \end {array}\right . \]
Mathematica. Time used: 0.006 (sec). Leaf size: 23
ode=D[y[x],x]==Piecewise[{{0,x<1},{1,1<=x<2},{0,2<=x}}]; 
ic={y[0]==0}; 
DSolve[{ode,ic},y[x],x,IncludeSingularSolutions->True]
 
\begin{align*} y(x)&\to \begin {array}{cc} \{ & \begin {array}{cc} 0 & x\leq 1 \\ x-1 & 1<x\leq 2 \\ 1 & \text {True} \\ \end {array} \\ \end {array} \end{align*}
Sympy. Time used: 0.047 (sec). Leaf size: 7
from sympy import * 
x = symbols("x") 
y = Function("y") 
ode = Eq(-Piecewise((0, x < 1), (1, x < 2), (0, True)) + Derivative(y(x), x),0) 
ics = {y(0): 0} 
dsolve(ode,func=y(x),ics=ics)
 
\[ y{\left (x \right )} = \begin {cases} 0 & \text {for}\: x < 1 \\x - 1 & \text {for}\: x < 2 \\1 & \text {otherwise} \end {cases} \]