71.2.2 problem 2

Internal problem ID [14255]
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 : Wednesday, March 05, 2025 at 10:41:31 PM
CAS classification : [[_linear, `class A`]]

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

Maple. Time used: 0.001 (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+c_{1} {\mathrm e}^{-x} \]
Mathematica. Time used: 0.074 (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]
 
\[ y(x)\to x^2+c_1 e^{-x}-1 \]
Sympy. Time used: 0.127 (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 \]