58.2.2 problem 2(a)

Internal problem ID [14543]
Book : Differential Equations by Shepley L. Ross. Third edition. John Willey. New Delhi. 2004.
Section : Chapter 1, section 1.3. Exercises page 22
Problem number : 2(a)
Date solved : Thursday, October 02, 2025 at 09:38:27 AM
CAS classification : [[_linear, `class A`]]

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

With initial conditions

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