51.1.4 problem 2. direct method

Internal problem ID [8215]
Book : A course in Ordinary Differential Equations. by Stephen A. Wirkus, Randall J. Swift. CRC Press NY. 2015. 2nd Edition
Section : Chapter 8. Series Methods. section 8.2. The Power Series Method. Problems Page 603
Problem number : 2. direct method
Date solved : Sunday, March 30, 2025 at 12:48:47 PM
CAS classification : [[_linear, `class A`]]

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

With initial conditions

\begin{align*} y \left (1\right )&=1 \end{align*}

Maple. Time used: 0.028 (sec). Leaf size: 22
ode:=diff(y(x),x)-2*y(x) = x^2; 
ic:=y(1) = 1; 
dsolve([ode,ic],y(x), singsol=all);
 
\[ y = -\frac {x^{2}}{2}-\frac {x}{2}-\frac {1}{4}+\frac {9 \,{\mathrm e}^{-2+2 x}}{4} \]
Mathematica. Time used: 0.038 (sec). Leaf size: 28
ode=D[y[x],x]-2*y[x]==x^2; 
ic={y[1]==1}; 
DSolve[{ode,ic},y[x],x,IncludeSingularSolutions->True]
 
\[ y(x)\to \frac {1}{4} \left (-2 x^2-2 x+9 e^{2 x-2}-1\right ) \]
Sympy. Time used: 0.146 (sec). Leaf size: 26
from sympy import * 
x = symbols("x") 
y = Function("y") 
ode = Eq(-x**2 - 2*y(x) + Derivative(y(x), x),0) 
ics = {y(1): 1} 
dsolve(ode,func=y(x),ics=ics)
 
\[ y{\left (x \right )} = - \frac {x^{2}}{2} - \frac {x}{2} + \frac {9 e^{2 x}}{4 e^{2}} - \frac {1}{4} \]