72.6.4 problem 2 (d)

Internal problem ID [19458]
Book : DIFFERENTIAL EQUATIONS WITH APPLICATIONS AND HISTORICAL NOTES by George F. Simmons. 3rd edition. 2017. CRC press, Boca Raton FL.
Section : Chapter 2. First order equations. Section 10 (Linear equations). Problems at page 82
Problem number : 2 (d)
Date solved : Thursday, October 02, 2025 at 04:28:35 PM
CAS classification : [[_linear, `class A`]]

\begin{align*} y^{\prime }+y&=2 x \,{\mathrm e}^{-x}+x^{2} \end{align*}
Maple. Time used: 0.001 (sec). Leaf size: 22
ode:=diff(y(x),x)+y(x) = 2*x*exp(-x)+x^2; 
dsolve(ode,y(x), singsol=all);
 
\[ y = \left (x^{2}+c_1 \right ) {\mathrm e}^{-x}+x^{2}-2 x +2 \]
Mathematica. Time used: 0.096 (sec). Leaf size: 29
ode=D[y[x],x]+y[x]==2*x*Exp[-x]+x^2; 
ic={}; 
DSolve[{ode,ic},y[x],x,IncludeSingularSolutions->True]
 
\begin{align*} y(x)&\to e^{-x} \left (x^2+e^x \left (x^2-2 x+2\right )+c_1\right ) \end{align*}
Sympy. Time used: 0.097 (sec). Leaf size: 19
from sympy import * 
x = symbols("x") 
y = Function("y") 
ode = Eq(-x**2 - 2*x*exp(-x) + y(x) + Derivative(y(x), x),0) 
ics = {} 
dsolve(ode,func=y(x),ics=ics)
 
\[ y{\left (x \right )} = x^{2} - 2 x + \left (C_{1} + x^{2}\right ) e^{- x} + 2 \]