65.2.2 problem 2

Internal problem ID [15621]
Book : Ordinary Differential Equations by Charles E. Roberts, Jr. CRC Press. 2010
Section : Chapter 1. Introduction. Exercises 1.3, page 27
Problem number : 2
Date solved : Thursday, October 02, 2025 at 10:21:14 AM
CAS classification : [[_linear, `class A`]]

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