61.1.5 problem 1.1.5

Internal problem ID [11926]
Book : Handbook of exact solutions for ordinary differential equations. By Polyanin and Zaitsev. Second edition
Section : Chapter 1, First-Order differential equations
Problem number : 1.1.5
Date solved : Wednesday, March 05, 2025 at 03:10:36 PM
CAS classification : [_Bernoulli]

\begin{align*} g \left (x \right ) y^{\prime }&=f_{1} \left (x \right ) y+f_{n} \left (x \right ) y^{n} \end{align*}

Maple. Time used: 0.140 (sec). Leaf size: 74
ode:=g(x)*diff(y(x),x) = f__1(x)*y(x)+f__n(x)*y(x)^n; 
dsolve(ode,y(x), singsol=all);
 
\[ y = {\mathrm e}^{\int \frac {f_{1} \left (x \right )}{g \left (x \right )}d x} {\left (-n \left (\int \frac {f_{n} \left (x \right ) {\mathrm e}^{\left (n -1\right ) \left (\int \frac {f_{1} \left (x \right )}{g \left (x \right )}d x \right )}}{g \left (x \right )}d x \right )+c_{1} +\int \frac {f_{n} \left (x \right ) {\mathrm e}^{\left (n -1\right ) \left (\int \frac {f_{1} \left (x \right )}{g \left (x \right )}d x \right )}}{g \left (x \right )}d x \right )}^{-\frac {1}{n -1}} \]
Mathematica. Time used: 11.701 (sec). Leaf size: 84
ode=g[x]*D[y[x],x]==f1[x]*y[x]+fn[x]*y[x]^n; 
ic={}; 
DSolve[{ode,ic},y[x],x,IncludeSingularSolutions->True]
 
\[ y(x)\to \left (\exp \left (-\left ((n-1) \int _1^x\frac {\text {f1}(K[1])}{g(K[1])}dK[1]\right )\right ) \left (-(n-1) \int _1^x\frac {\exp \left ((n-1) \int _1^{K[2]}\frac {\text {f1}(K[1])}{g(K[1])}dK[1]\right ) \text {fn}(K[2])}{g(K[2])}dK[2]+c_1\right )\right ){}^{\frac {1}{1-n}} \]
Sympy. Time used: 70.817 (sec). Leaf size: 87
from sympy import * 
x = symbols("x") 
n = symbols("n") 
y = Function("y") 
f1 = Function("f1") 
fn = Function("fn") 
g = Function("g") 
ode = Eq(-f1(x)*y(x) - fn(x)*y(x)**n + g(x)*Derivative(y(x), x),0) 
ics = {} 
dsolve(ode,func=y(x),ics=ics)
 
\[ y{\left (x \right )} = \left (\left (C_{1} - n \int \frac {\operatorname {fn}{\left (x \right )} \left (e^{n \int \frac {f_{1}{\left (x \right )}}{g{\left (x \right )}}\, dx}\right ) e^{- \int \frac {f_{1}{\left (x \right )}}{g{\left (x \right )}}\, dx}}{g{\left (x \right )}}\, dx + \int \frac {\operatorname {fn}{\left (x \right )} \left (e^{n \int \frac {f_{1}{\left (x \right )}}{g{\left (x \right )}}\, dx}\right ) e^{- \int \frac {f_{1}{\left (x \right )}}{g{\left (x \right )}}\, dx}}{g{\left (x \right )}}\, dx\right ) e^{- \left (n - 1\right ) \int \frac {f_{1}{\left (x \right )}}{g{\left (x \right )}}\, dx}\right )^{- \frac {1}{n - 1}} \]