63.15.12 problem 12

Internal problem ID [13116]
Book : A First Course in Differential Equations by J. David Logan. Third Edition. Springer-Verlag, NY. 2015.
Section : Chapter 3, Laplace transform. Section 3.2.1 Initial value problems. Exercises page 156
Problem number : 12
Date solved : Wednesday, March 05, 2025 at 09:17:39 PM
CAS classification : [[_linear, `class A`]]

\begin{align*} x^{\prime }&=x-2 \operatorname {Heaviside}\left (t -1\right ) \end{align*}

Using Laplace method With initial conditions

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

Maple. Time used: 8.857 (sec). Leaf size: 20
ode:=diff(x(t),t) = x(t)-2*Heaviside(t-1); 
ic:=x(0) = 1; 
dsolve([ode,ic],x(t),method='laplace');
 
\[ x \left (t \right ) = \left (-2 \,{\mathrm e}^{t -1}+2\right ) \operatorname {Heaviside}\left (t -1\right )+{\mathrm e}^{t} \]
Mathematica. Time used: 0.058 (sec). Leaf size: 26
ode=D[x[t],t]==x[t]-2*UnitStep[t-1]; 
ic={x[0]==1}; 
DSolve[{ode,ic},x[t],t,IncludeSingularSolutions->True]
 
\[ x(t)\to \begin {array}{cc} \{ & \begin {array}{cc} e^t & t\leq 1 \\ 2-2 e^{t-1}+e^t & \text {True} \\ \end {array} \\ \end {array} \]
Sympy. Time used: 0.440 (sec). Leaf size: 27
from sympy import * 
t = symbols("t") 
x = Function("x") 
ode = Eq(-x(t) + 2*Heaviside(t - 1) + Derivative(x(t), t),0) 
ics = {x(0): 1} 
dsolve(ode,func=x(t),ics=ics)
 
\[ x{\left (t \right )} = e^{t} - 2 e^{t - 1} \theta \left (t - 1\right ) + 2 \theta \left (t - 1\right ) \]