8.2.8 problem 9

Internal problem ID [668]
Book : Differential equations and linear algebra, 3rd ed., Edwards and Penney
Section : Section 1.3. Slope fields and solution curves. Page 26
Problem number : 9
Date solved : Saturday, March 29, 2025 at 10:11:59 PM
CAS classification : [[_linear, `class A`]]

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

Maple. Time used: 0.002 (sec). Leaf size: 17
ode:=diff(y(x),x) = -2+x^2-y(x); 
dsolve(ode,y(x), singsol=all);
 
\[ y = x^{2}-2 x +{\mathrm e}^{-x} c_1 \]
Mathematica. Time used: 0.026 (sec). Leaf size: 19
ode=D[y[x],x]== -2+x^2-y[x]; 
ic={}; 
DSolve[{ode,ic},y[x],x,IncludeSingularSolutions->True]
 
\[ y(x)\to (x-2) x+c_1 e^{-x} \]
Sympy. Time used: 0.122 (sec). Leaf size: 14
from sympy import * 
x = symbols("x") 
y = Function("y") 
ode = Eq(-x**2 + y(x) + Derivative(y(x), x) + 2,0) 
ics = {} 
dsolve(ode,func=y(x),ics=ics)
 
\[ y{\left (x \right )} = C_{1} e^{- x} + x^{2} - 2 x \]