37.2.2 problem 10.3.3

Internal problem ID [6399]
Book : Basic Training in Mathematics. By R. Shankar. Plenum Press. NY. 1995
Section : Chapter 10, Differential equations. Section 10.3, ODEs with variable Coefficients. First order. page 315
Problem number : 10.3.3
Date solved : Wednesday, March 05, 2025 at 12:39:03 AM
CAS classification : [_linear]

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

With initial conditions

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

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