61.6.4 problem 21

Internal problem ID [12066]
Book : Handbook of exact solutions for ordinary differential equations. By Polyanin and Zaitsev. Second edition
Section : Chapter 1, section 1.2. Riccati Equation. subsection 1.2.4-2. Equations with hyperbolic tangent and cotangent.
Problem number : 21
Date solved : Sunday, March 30, 2025 at 10:30:23 PM
CAS classification : [_Riccati]

\begin{align*} \left (a \tanh \left (\lambda x \right )+b \right ) y^{\prime }&=y^{2}+c \tanh \left (\mu x \right ) y-d^{2}+c d \tanh \left (\mu x \right ) \end{align*}

Maple. Time used: 0.014 (sec). Leaf size: 198
ode:=(a*tanh(lambda*x)+b)*diff(y(x),x) = y(x)^2+c*tanh(x*mu)*y(x)-d^2+c*d*tanh(x*mu); 
dsolve(ode,y(x), singsol=all);
 
\[ y = -d +\frac {{\mathrm e}^{c \int \frac {\tanh \left (\mu x \right )}{a \tanh \left (\lambda x \right )+b}d x} \left (\tanh \left (\lambda x \right )-1\right )^{\frac {d}{\lambda \left (a +b \right )}} \left (\tanh \left (\lambda x \right )+1\right )^{\frac {d}{\lambda \left (a -b \right )}} \left (a \tanh \left (\lambda x \right )+b \right )^{-\frac {2 a d}{\lambda \left (a^{2}-b^{2}\right )}}}{-\int \left (a \tanh \left (\lambda x \right )+b \right )^{-\frac {a^{2} \lambda -b^{2} \lambda +2 a d}{\lambda \left (a^{2}-b^{2}\right )}} \left (\tanh \left (\lambda x \right )-1\right )^{\frac {d}{\lambda \left (a +b \right )}} \left (\tanh \left (\lambda x \right )+1\right )^{\frac {d}{\lambda \left (a -b \right )}} {\mathrm e}^{c \int \frac {\tanh \left (\mu x \right )}{a \tanh \left (\lambda x \right )+b}d x}d x +c_1} \]
Mathematica. Time used: 32.336 (sec). Leaf size: 800
ode=(a*Tanh[\[Lambda]*x]+b)*D[y[x],x]==y[x]^2+c*Tanh[\[Mu]*x]*y[x]-d^2+c*d*Tanh[\[Mu]*x]; 
ic={}; 
DSolve[{ode,ic},y[x],x,IncludeSingularSolutions->True]
 
\begin{align*} \text {Solution too large to show}\end{align*}

Sympy
from sympy import * 
x = symbols("x") 
a = symbols("a") 
b = symbols("b") 
c = symbols("c") 
d = symbols("d") 
lambda_ = symbols("lambda_") 
mu = symbols("mu") 
y = Function("y") 
ode = Eq(-c*d*tanh(mu*x) - c*y(x)*tanh(mu*x) + d**2 + (a*tanh(lambda_*x) + b)*Derivative(y(x), x) - y(x)**2,0) 
ics = {} 
dsolve(ode,func=y(x),ics=ics)
 
PolynomialDivisionFailed : couldnt reduce degree in a polynomial division algorithm when dividing [[], [ANP([mpq(-1,1), mpq(0,1)], [mpq(1,1), mpq(0,1), mpq(1,1)], QQ), ANP([mpq(1,1)], [mpq(1,1), mpq(0,1), mpq(1,1)], QQ)]] by [[ANP([mpq(1,1)], [mpq(1,1), mpq(0,1), mpq(1,1)], QQ)]]. This can happen when its not possible to detect zero in the coefficient domain. The domain of computation is QQ<I>. Zero detection is guaranteed in this coefficient domain. This may indicate a bug in SymPy or the domain is user defined and doesnt implement zero detection properly.