65.5.7 problem 10.3 (ii)

Internal problem ID [13675]
Book : AN INTRODUCTION TO ORDINARY DIFFERENTIAL EQUATIONS by JAMES C. ROBINSON. Cambridge University Press 2004
Section : Chapter 10, Two tricks for nonlinear equations. Exercises page 97
Problem number : 10.3 (ii)
Date solved : Monday, March 31, 2025 at 08:08:03 AM
CAS classification : [_separable]

\begin{align*} \left (\frac {1}{y}-a \right ) y^{\prime }+\frac {2}{x}-b&=0 \end{align*}

Maple. Time used: 0.013 (sec). Leaf size: 22
ode:=(1/y(x)-a)*diff(y(x),x)+2/x-b = 0; 
dsolve(ode,y(x), singsol=all);
 
\[ y = -\frac {\operatorname {LambertW}\left (-\frac {a \,{\mathrm e}^{b x +c_1}}{x^{2}}\right )}{a} \]
Mathematica. Time used: 3.029 (sec). Leaf size: 32
ode=(1/y[x]-a)*D[y[x],x]+2/x-b==0; 
ic={}; 
DSolve[{ode,ic},y[x],x,IncludeSingularSolutions->True]
 
\begin{align*} y(x)\to -\frac {W\left (-\frac {a e^{b x-c_1}}{x^2}\right )}{a} \\ y(x)\to 0 \\ \end{align*}
Sympy. Time used: 0.372 (sec). Leaf size: 19
from sympy import * 
x = symbols("x") 
a = symbols("a") 
b = symbols("b") 
y = Function("y") 
ode = Eq(-b + (-a + 1/y(x))*Derivative(y(x), x) + 2/x,0) 
ics = {} 
dsolve(ode,func=y(x),ics=ics)
 
\[ y{\left (x \right )} = - \frac {W\left (\frac {C_{1} a e^{b x}}{x^{2}}\right )}{a} \]