2.6.4 Problem 21

2.6.4.1 Solved using first_order_ode_riccati_by_guessing_particular_solution
2.6.4.2 Maple
2.6.4.3 Mathematica
2.6.4.4 Sympy

Internal problem ID [13339]
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, January 18, 2026 at 07:23:00 PM
CAS classification : [_Riccati]

2.6.4.1 Solved using first_order_ode_riccati_by_guessing_particular_solution

1.339 (sec)

Entering first order ode riccati guess solver

\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*}
This is a Riccati ODE. Comparing the above ODE to solve with the Riccati standard form
\[ y' = f_0(x)+ f_1(x)y+f_2(x)y^{2} \]
Shows that
\begin{align*} f_0(x) & =\frac {c d \tanh \left (\mu x \right )}{a \tanh \left (\lambda x \right )+b}-\frac {d^{2}}{a \tanh \left (\lambda x \right )+b}\\ f_1(x) & =\frac {c \tanh \left (\mu x \right )}{a \tanh \left (\lambda x \right )+b}\\ f_2(x) &=\frac {1}{a \tanh \left (\lambda x \right )+b} \end{align*}

Using trial and error, the following particular solution was found

\[ y_p = -d \]
Since a particular solution is known, then the general solution is given by
\begin{align*} y &= y_p + \frac { \phi (x) }{ c_1 - \int { \phi (x) f_2 \,dx} } \end{align*}

Where

\begin{align*} \phi (x) &= e^{ \int 2 f_2 y_p + f_1 \,dx } \end{align*}

Evaluating the above gives the general solution as

\[ y = -d +\frac {{\mathrm e}^{\frac {\left (c -2 d \right ) x}{a +b}-\frac {2 c x}{a +b}+\frac {c \ln \left ({\mathrm e}^{2 \mu x}+1\right )}{\mu \left (a +b \right )}+\int \frac {2 \left (c \,{\mathrm e}^{2 \mu x}-2 d \,{\mathrm e}^{2 \mu x}-c -2 d \right ) a}{\left ({\mathrm e}^{2 \lambda x} a +b \,{\mathrm e}^{2 \lambda x}-a +b \right ) \left (a +b \right ) \left ({\mathrm e}^{2 \mu x}+1\right )}d x}}{c_1 -\int \frac {{\mathrm e}^{\frac {\left (c -2 d \right ) x}{a +b}-\frac {2 c x}{a +b}+\frac {c \ln \left ({\mathrm e}^{2 \mu x}+1\right )}{\mu \left (a +b \right )}+\int \frac {2 \left (c \,{\mathrm e}^{2 \mu x}-2 d \,{\mathrm e}^{2 \mu x}-c -2 d \right ) a}{\left ({\mathrm e}^{2 \lambda x} a +b \,{\mathrm e}^{2 \lambda x}-a +b \right ) \left (a +b \right ) \left ({\mathrm e}^{2 \mu x}+1\right )}d x}}{a \tanh \left (\lambda x \right )+b}d x} \]

Summary of solutions found

\begin{align*} y &= -d +\frac {{\mathrm e}^{\frac {\left (c -2 d \right ) x}{a +b}-\frac {2 c x}{a +b}+\frac {c \ln \left ({\mathrm e}^{2 \mu x}+1\right )}{\mu \left (a +b \right )}+\int \frac {2 \left (c \,{\mathrm e}^{2 \mu x}-2 d \,{\mathrm e}^{2 \mu x}-c -2 d \right ) a}{\left ({\mathrm e}^{2 \lambda x} a +b \,{\mathrm e}^{2 \lambda x}-a +b \right ) \left (a +b \right ) \left ({\mathrm e}^{2 \mu x}+1\right )}d x}}{c_1 -\int \frac {{\mathrm e}^{\frac {\left (c -2 d \right ) x}{a +b}-\frac {2 c x}{a +b}+\frac {c \ln \left ({\mathrm e}^{2 \mu x}+1\right )}{\mu \left (a +b \right )}+\int \frac {2 \left (c \,{\mathrm e}^{2 \mu x}-2 d \,{\mathrm e}^{2 \mu x}-c -2 d \right ) a}{\left ({\mathrm e}^{2 \lambda x} a +b \,{\mathrm e}^{2 \lambda x}-a +b \right ) \left (a +b \right ) \left ({\mathrm e}^{2 \mu x}+1\right )}d x}}{a \tanh \left (\lambda x \right )+b}d x} \\ \end{align*}
2.6.4.2 Maple. Time used: 0.011 (sec). Leaf size: 198
ode:=(a*tanh(lambda*x)+b)*diff(y(x),x) = y(x)^2+c*tanh(mu*x)*y(x)-d^2+c*d*tanh(mu*x); 
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 d a}{\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} \]

Maple trace

Methods for first order ODEs: 
--- Trying classification methods --- 
trying a quadrature 
trying 1st order linear 
trying Bernoulli 
trying separable 
trying inverse linear 
trying homogeneous types: 
trying Chini 
differential order: 1; looking for linear symmetries 
trying exact 
Looking for potential symmetries 
trying Riccati 
trying Riccati sub-methods: 
   <- Riccati particular case Kamke (b) successful
 

Maple step by step

\[ \begin {array}{lll} & {} & \textrm {Let's solve}\hspace {3pt} \\ {} & {} & \left (a \tanh \left (\lambda x \right )+b \right ) \left (\frac {d}{d x}y \left (x \right )\right )=y \left (x \right )^{2}+c \tanh \left (\mu x \right ) y \left (x \right )-d^{2}+c d \tanh \left (\mu x \right ) \\ \bullet & {} & \textrm {Highest derivative means the order of the ODE is}\hspace {3pt} 1 \\ {} & {} & \frac {d}{d x}y \left (x \right ) \\ \bullet & {} & \textrm {Solve for the highest derivative}\hspace {3pt} \\ {} & {} & \frac {d}{d x}y \left (x \right )=\frac {y \left (x \right )^{2}+c \tanh \left (\mu x \right ) y \left (x \right )-d^{2}+c d \tanh \left (\mu x \right )}{a \tanh \left (\lambda x \right )+b} \end {array} \]
2.6.4.3 Mathematica. Time used: 23.34 (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*}
2.6.4.4 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)
 
Timed Out
 
Python version: 3.12.3 (main, Aug 14 2025, 17:47:21) [GCC 13.3.0] 
Sympy version 1.14.0