29.7.9 problem 184

Internal problem ID [4784]
Book : Ordinary differential equations and their solutions. By George Moseley Murphy. 1960
Section : Various 7
Problem number : 184
Date solved : Sunday, March 30, 2025 at 03:54:28 AM
CAS classification : [[_1st_order, _with_linear_symmetries], _rational, _Riccati]

\begin{align*} x y^{\prime }&=2 x -y+a \,x^{n} \left (x -y\right )^{2} \end{align*}

Maple. Time used: 0.007 (sec). Leaf size: 34
ode:=x*diff(y(x),x) = 2*x-y(x)+a*x^n*(x-y(x))^2; 
dsolve(ode,y(x), singsol=all);
 
\[ y = \frac {x \,x^{n} a -c_1 \,x^{2}-n +1}{x^{n} a -c_1 x} \]
Mathematica. Time used: 1.122 (sec). Leaf size: 164
ode=x D[y[x],x]==2 x -y[x]+a x^n(x-y[x])^2; 
ic={}; 
DSolve[{ode,ic},y[x],x,IncludeSingularSolutions->True]
 
\begin{align*} y(x)\to \frac {x^{-n} \left (2 a x^{n+\sqrt {(n-1)^2}+1}+2 a c_1 \sqrt {(n-1)^2} x^{n+1}-\left (n+\sqrt {(n-1)^2}-1\right ) x^{\sqrt {(n-1)^2}}-c_1 \left (-n+\sqrt {(n-1)^2}+1\right ) (n-1)\right )}{2 a \left (x^{\sqrt {(n-1)^2}}+c_1 \sqrt {(n-1)^2}\right )} \\ y(x)\to \frac {x^{-n} \left (2 a x^{n+1}-n+\sqrt {(n-1)^2}+1\right )}{2 a} \\ \end{align*}
Sympy. Time used: 36.743 (sec). Leaf size: 54
from sympy import * 
x = symbols("x") 
a = symbols("a") 
n = symbols("n") 
y = Function("y") 
ode = Eq(-a*x**n*(x - y(x))**2 + x*Derivative(y(x), x) - 2*x + y(x),0) 
ics = {} 
dsolve(ode,func=y(x),ics=ics)
 
\[ y{\left (x \right )} = \frac {x^{- n} \left (- a x^{n + 1} + a x^{n + 2} e^{\frac {- C_{1} + n \left (C_{1} - n \log {\left (x \right )}\right )}{n}} + n - 1\right )}{a \left (x e^{\frac {- C_{1} + n \left (C_{1} - n \log {\left (x \right )}\right )}{n}} - 1\right )} \]