87.17.32 problem 33

Internal problem ID [23624]
Book : Ordinary differential equations with modern applications. Ladas, G. E. and Finizio, N. Wadsworth Publishing. California. 1978. ISBN 0-534-00552-7. QA372.F56
Section : Chapter 2. Linear differential equations. Exercise at page 127
Problem number : 33
Date solved : Thursday, October 02, 2025 at 09:43:35 PM
CAS classification : [[_2nd_order, _with_linear_symmetries]]

\begin{align*} y^{\prime \prime }+y&=x +2 \,{\mathrm e}^{-x} \end{align*}

With initial conditions

\begin{align*} y \left (0\right )&=1 \\ y^{\prime }\left (0\right )&=-2 \\ \end{align*}
Maple. Time used: 0.009 (sec). Leaf size: 14
ode:=diff(diff(y(x),x),x)+y(x) = x+2*exp(-x); 
ic:=[y(0) = 1, D(y)(0) = -2]; 
dsolve([ode,op(ic)],y(x), singsol=all);
 
\[ y = -2 \sin \left (x \right )+{\mathrm e}^{-x}+x \]
Mathematica. Time used: 0.071 (sec). Leaf size: 16
ode=D[y[x],{x,2}]+y[x]==x+2*Exp[-x]; 
ic={y[0]==1,Derivative[1][y][0] ==-2}; 
DSolve[{ode,ic},y[x],x,IncludeSingularSolutions->True]
 
\begin{align*} y(x)&\to x+e^{-x}-2 \sin (x) \end{align*}
Sympy. Time used: 0.058 (sec). Leaf size: 14
from sympy import * 
x = symbols("x") 
y = Function("y") 
ode = Eq(-x + y(x) + Derivative(y(x), (x, 2)) - 2*exp(-x),0) 
ics = {y(0): 1, Subs(Derivative(y(x), x), x, 0): -2} 
dsolve(ode,func=y(x),ics=ics)
 
\[ y{\left (x \right )} = x - 2 \sin {\left (x \right )} + e^{- x} \]