14.18.9 problem 9

Internal problem ID [2693]
Book : Differential equations and their applications, 4th ed., M. Braun
Section : Chapter 2. Second order differential equations. Section 2.11, Differential equations with discontinuous right-hand sides. Excercises page 243
Problem number : 9
Date solved : Tuesday, March 04, 2025 at 02:37:18 PM
CAS classification : [[_2nd_order, _linear, _nonhomogeneous]]

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

Using Laplace method With initial conditions

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

Maple. Time used: 1.398 (sec). Leaf size: 80
ode:=diff(diff(y(t),t),t)-2*diff(y(t),t)+y(t) = piecewise(0 <= t and t < 1,0,1 <= t and t < 2,t,2 <= t,0); 
ic:=y(0) = 0, D(y)(0) = 1; 
dsolve([ode,ic],y(t),method='laplace');
 
\[ y = \left \{\begin {array}{cc} t \,{\mathrm e}^{t} & t <1 \\ {\mathrm e}+1 & t =1 \\ \left (2 t -5\right ) {\mathrm e}^{-1+t}+t \,{\mathrm e}^{t}+t +2 & t <2 \\ -{\mathrm e}+2+2 \,{\mathrm e}^{2} & t =2 \\ \left (2 t -5\right ) {\mathrm e}^{-1+t}+\left (-3 t +10\right ) {\mathrm e}^{t -2}+t \,{\mathrm e}^{t} & 2<t \end {array}\right . \]
Mathematica. Time used: 0.045 (sec). Leaf size: 62
ode=D[y[t],{t,2}]-2*D[y[t],t]+y[t]==Piecewise[{{0,0<=t<1},{t,1<=t<2},{0,t>=2}}]; 
ic={y[0]==0,Derivative[1][y][0] ==1}; 
DSolve[{ode,ic},y[t],t,IncludeSingularSolutions->True]
 
\[ y(t)\to \begin {array}{cc} \{ & \begin {array}{cc} e^t t & t\leq 1 \\ e^{t-2} \left (e^2 t-3 t+e (2 t-5)+10\right ) & t>2 \\ e^t t+t+e^{t-1} (2 t-5)+2 & \text {True} \\ \end {array} \\ \end {array} \]
Sympy
from sympy import * 
t = symbols("t") 
y = Function("y") 
ode = Eq(-Piecewise((0, (t >= 0) & (t < 1)), (t, (t >= 1) & (t < 2)), (0, t >= 2)) + y(t) - 2*Derivative(y(t), t) + Derivative(y(t), (t, 2)),0) 
ics = {y(0): 0, Subs(Derivative(y(t), t), t, 0): 1} 
dsolve(ode,func=y(t),ics=ics)