71.7.2 problem 2

Internal problem ID [14352]
Book : Ordinary Differential Equations by Charles E. Roberts, Jr. CRC Press. 2010
Section : Chapter 2. The Initial Value Problem. Exercises 2.3.3, page 71
Problem number : 2
Date solved : Monday, March 31, 2025 at 12:18:59 PM
CAS classification : [_linear]

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

With initial conditions

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

Maple. Time used: 0.056 (sec). Leaf size: 27
ode:=diff(y(x),x) = x*y(x)+2; 
ic:=y(0) = 1; 
dsolve([ode,ic],y(x), singsol=all);
 
\[ y = \left (\sqrt {\pi }\, \sqrt {2}\, \operatorname {erf}\left (\frac {\sqrt {2}\, x}{2}\right )+1\right ) {\mathrm e}^{\frac {x^{2}}{2}} \]
Mathematica. Time used: 0.058 (sec). Leaf size: 33
ode=D[y[x],x]==x*y[x]+2; 
ic={y[0]==1}; 
DSolve[{ode,ic},y[x],x,IncludeSingularSolutions->True]
 
\[ y(x)\to e^{\frac {x^2}{2}} \left (\sqrt {2 \pi } \text {erf}\left (\frac {x}{\sqrt {2}}\right )+1\right ) \]
Sympy. Time used: 0.370 (sec). Leaf size: 31
from sympy import * 
x = symbols("x") 
y = Function("y") 
ode = Eq(-x*y(x) + Derivative(y(x), x) - 2,0) 
ics = {y(0): 1} 
dsolve(ode,func=y(x),ics=ics)
 
\[ y{\left (x \right )} = \left (\sqrt {2} \sqrt {\pi } \operatorname {erf}{\left (\frac {\sqrt {2} x}{2} \right )} + 1\right ) e^{\frac {x^{2}}{2}} \]