71.15.6 problem 4 (g)

Internal problem ID [14477]
Book : Ordinary Differential Equations by Charles E. Roberts, Jr. CRC Press. 2010
Section : Chapter 5. The Laplace Transform Method. Exercises 5.4, page 265
Problem number : 4 (g)
Date solved : Monday, March 31, 2025 at 12:28:08 PM
CAS classification : [[_2nd_order, _linear, _nonhomogeneous]]

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

Using Laplace method With initial conditions

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

Maple. Time used: 0.258 (sec). Leaf size: 42
ode:=diff(diff(y(x),x),x)-4*y(x) = piecewise(0 <= x and x < 1,x,1 <= x,1); 
ic:=y(0) = 0, D(y)(0) = 0; 
dsolve([ode,ic],y(x),method='laplace');
 
\[ y = \frac {\left (\left \{\begin {array}{cc} \sinh \left (2 x \right )-2 x & x <1 \\ \sinh \left (2\right )-4 & x =1 \\ \sinh \left (2 x \right )-\sinh \left (-2+2 x \right )-2 & 1<x \end {array}\right .\right )}{8} \]
Mathematica. Time used: 0.025 (sec). Leaf size: 36
ode=D[y[x],{x,2}]-4*y[x]==Piecewise[{ {x,0<=x<1},{x,x>=1}}]; 
ic={y[0]==0,Derivative[1][y][0] ==0}; 
DSolve[{ode,ic},y[x],x,IncludeSingularSolutions->True]
 
\[ y(x)\to \begin {array}{cc} \{ & \begin {array}{cc} 0 & x\leq 0 \\ \frac {1}{16} e^{-2 x} \left (-4 e^{2 x} x+e^{4 x}-1\right ) & \text {True} \\ \end {array} \\ \end {array} \]
Sympy. Time used: 0.322 (sec). Leaf size: 24
from sympy import * 
x = symbols("x") 
y = Function("y") 
ode = Eq(-Piecewise((x, (x >= 0) | (x >= 1))) - 4*y(x) + Derivative(y(x), (x, 2)),0) 
ics = {y(0): 0, Subs(Derivative(y(x), x), x, 0): 0} 
dsolve(ode,func=y(x),ics=ics)
 
\[ y{\left (x \right )} = \begin {cases} - \frac {x}{4} & \text {for}\: x \geq 0 \\\text {NaN} & \text {otherwise} \end {cases} + \frac {e^{2 x}}{16} - \frac {e^{- 2 x}}{16} \]