2.11.4 Problem 30

2.11.4.1 Solved using first_order_ode_riccati
2.11.4.2 Maple
2.11.4.3 Mathematica
2.11.4.4 Sympy

Internal problem ID [13392]
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.6-3. Equations with tangent.
Problem number : 30
Date solved : Wednesday, December 31, 2025 at 02:20:07 PM
CAS classification : [[_1st_order, `_with_symmetry_[F(x),G(x)]`], _Riccati]

2.11.4.1 Solved using first_order_ode_riccati

5.046 (sec)

Entering first order ode riccati solver

\begin{align*} y^{\prime }&=a y^{2}+2 a b \tan \left (x \right ) y+b \left (a b -1\right ) \tan \left (x \right )^{2} \\ \end{align*}
In canonical form the ODE is
\begin{align*} y' &= F(x,y)\\ &= \tan \left (x \right )^{2} a \,b^{2}+2 a b \tan \left (x \right ) y-\tan \left (x \right )^{2} b +a y^{2} \end{align*}

This is a Riccati ODE. Comparing the ODE to solve

\[ y' = \textit {the\_rhs} \]
With Riccati ODE standard form
\[ y' = f_0(x)+ f_1(x)y+f_2(x)y^{2} \]
Shows that \(f_0(x)=\tan \left (x \right )^{2} a \,b^{2}-\tan \left (x \right )^{2} b\), \(f_1(x)=2 b \tan \left (x \right ) a\) and \(f_2(x)=a\). Let
\begin{align*} y &= \frac {-u'}{f_2 u} \\ &= \frac {-u'}{u a} \tag {1} \end{align*}

Using the above substitution in the given ODE results (after some simplification) in a second order ODE to solve for \(u(x)\) which is

\begin{align*} f_2 u''(x) -\left ( f_2' + f_1 f_2 \right ) u'(x) + f_2^2 f_0 u(x) &= 0 \tag {2} \end{align*}

But

\begin{align*} f_2' &=0\\ f_1 f_2 &=2 b \tan \left (x \right ) a^{2}\\ f_2^2 f_0 &=a^{2} \left (\tan \left (x \right )^{2} a \,b^{2}-\tan \left (x \right )^{2} b \right ) \end{align*}

Substituting the above terms back in equation (2) gives

\[ a u^{\prime \prime }\left (x \right )-2 b \tan \left (x \right ) a^{2} u^{\prime }\left (x \right )+a^{2} \left (\tan \left (x \right )^{2} a \,b^{2}-\tan \left (x \right )^{2} b \right ) u \left (x \right ) = 0 \]
Entering second order change of variable on \(y\) method 1 solverIn normal form the given ode is written as
\begin{align*} \frac {d^{2}u}{d x^{2}}+p \left (x \right ) \left (\frac {d u}{d x}\right )+q \left (x \right ) u&=0 \tag {2} \end{align*}

Where

\begin{align*} p \left (x \right )&=-2 b \tan \left (x \right ) a\\ q \left (x \right )&=\tan \left (x \right )^{2} a b \left (a b -1\right ) \end{align*}

Calculating the Liouville ode invariant \(Q\) given by

\begin{align*} Q &= q - \frac {p'}{2}- \frac {p^2}{4} \\ &= \tan \left (x \right )^{2} a b \left (a b -1\right ) - \frac {\left (-2 b \tan \left (x \right ) a\right )'}{2}- \frac {\left (-2 b \tan \left (x \right ) a\right )^2}{4} \\ &= \tan \left (x \right )^{2} a b \left (a b -1\right ) - \frac {\left (-2 b \left (1+\tan \left (x \right )^{2}\right ) a\right )}{2}- \frac {\left (4 a^{2} \tan \left (x \right )^{2} b^{2}\right )}{4} \\ &= \tan \left (x \right )^{2} a b \left (a b -1\right ) - \left (-b \left (1+\tan \left (x \right )^{2}\right ) a\right )-a^{2} \tan \left (x \right )^{2} b^{2}\\ &= a b \end{align*}

Since the Liouville ode invariant does not depend on the independent variable \(x\) then the transformation

\begin{align*} u = v \left (x \right ) z \left (x \right )\tag {3} \end{align*}

is used to change the original ode to a constant coefficients ode in \(v\). In (3) the term \(z \left (x \right )\) is given by

\begin{align*} z \left (x \right )&={\mathrm e}^{-\int \frac {p \left (x \right )}{2}d x}\\ &= e^{-\int \frac {-2 b \tan \left (x \right ) a}{2} }\\ &= \cos \left (x \right )^{-a b}\tag {5} \end{align*}

Hence (3) becomes

\begin{align*} u = v \left (x \right ) \cos \left (x \right )^{-a b}\tag {4} \end{align*}

Applying this change of variable to the original ode results in

\begin{align*} \cos \left (x \right )^{-a b} a \left (a b v \left (x \right )+\frac {d^{2}}{d x^{2}}v \left (x \right )\right ) = 0 \end{align*}

Which is now solved for \(v \left (x \right )\).

The above ode simplifies to

\begin{align*} a \left (a b v \left (x \right )+\frac {d^{2}}{d x^{2}}v \left (x \right )\right ) = 0 \end{align*}

Entering second order linear constant coefficient ode solver

This is second order with constant coefficients homogeneous ODE. In standard form the ODE is

\[ A v''(x) + B v'(x) + C v(x) = 0 \]
Where in the above \(A=a, B=0, C=a^{2} b\). Let the solution be \(v \left (x \right )=e^{\lambda x}\). Substituting this into the ODE gives
\[ a \,\lambda ^{2} {\mathrm e}^{x \lambda }+a^{2} b \,{\mathrm e}^{x \lambda } = 0 \tag {1} \]
Since exponential function is never zero, then dividing Eq(2) throughout by \(e^{\lambda x}\) gives
\[ a^{2} b +a \,\lambda ^{2} = 0 \tag {2} \]
Equation (2) is the characteristic equation of the ODE. Its roots determine the general solution form.Using the quadratic formula
\[ \lambda _{1,2} = \frac {-B}{2 A} \pm \frac {1}{2 A} \sqrt {B^2 - 4 A C} \]
Substituting \(A=a, B=0, C=a^{2} b\) into the above gives
\begin{align*} \lambda _{1,2} &= \frac {0}{(2) \left (a\right )} \pm \frac {1}{(2) \left (a\right )} \sqrt {0^2 - (4) \left (a\right )\left (a^{2} b\right )}\\ &= \pm \frac {\sqrt {-b \,a^{3}}}{a} \end{align*}

Hence

\begin{align*} \lambda _1 &= + \frac {\sqrt {-b \,a^{3}}}{a} \\ \lambda _2 &= - \frac {\sqrt {-b \,a^{3}}}{a} \\ \end{align*}
Which simplifies to
\begin{align*} \lambda _1 &= \frac {\sqrt {-b \,a^{3}}}{a} \\ \lambda _2 &= -\frac {\sqrt {-b \,a^{3}}}{a} \\ \end{align*}
Since roots are distinct, then the solution is
\begin{align*} v \left (x \right ) &= c_1 e^{\lambda _1 x} + c_2 e^{\lambda _2 x} \\ v \left (x \right ) &= c_1 e^{\left (\frac {\sqrt {-b \,a^{3}}}{a}\right )x} +c_2 e^{\left (-\frac {\sqrt {-b \,a^{3}}}{a}\right )x} \\ \end{align*}
Or
\[ v \left (x \right ) =c_1 \,{\mathrm e}^{\frac {\sqrt {-b \,a^{3}}\, x}{a}}+c_2 \,{\mathrm e}^{-\frac {\sqrt {-b \,a^{3}}\, x}{a}} \]
Now that \(v \left (x \right )\) is known, then
\begin{align*} u&= v \left (x \right ) z \left (x \right )\\ &= \left (c_1 \,{\mathrm e}^{\frac {\sqrt {-b \,a^{3}}\, x}{a}}+c_2 \,{\mathrm e}^{-\frac {\sqrt {-b \,a^{3}}\, x}{a}}\right ) \left (z \left (x \right )\right )\tag {7} \end{align*}

But from (5)

\begin{align*} z \left (x \right )&= \cos \left (x \right )^{-a b} \end{align*}

Hence (7) becomes

\begin{align*} u = \left (c_1 \,{\mathrm e}^{\frac {\sqrt {-b \,a^{3}}\, x}{a}}+c_2 \,{\mathrm e}^{-\frac {\sqrt {-b \,a^{3}}\, x}{a}}\right ) \cos \left (x \right )^{-a b} \end{align*}

Taking derivative gives

\begin{equation} \tag{4} u^{\prime }\left (x \right ) = \left (\frac {c_1 \sqrt {-b \,a^{3}}\, {\mathrm e}^{\frac {\sqrt {-b \,a^{3}}\, x}{a}}}{a}-\frac {c_2 \sqrt {-b \,a^{3}}\, {\mathrm e}^{-\frac {\sqrt {-b \,a^{3}}\, x}{a}}}{a}\right ) \cos \left (x \right )^{-a b}+\frac {\left (c_1 \,{\mathrm e}^{\frac {\sqrt {-b \,a^{3}}\, x}{a}}+c_2 \,{\mathrm e}^{-\frac {\sqrt {-b \,a^{3}}\, x}{a}}\right ) \cos \left (x \right )^{-a b} a b \sin \left (x \right )}{\cos \left (x \right )} \end{equation}
Substituting equations (3,4) into (1) results in
\begin{align*} y &= \frac {-u'}{f_2 u} \\ y &= \frac {-u'}{u a} \\ y &= -\frac {\left (\left (\frac {c_1 \sqrt {-b \,a^{3}}\, {\mathrm e}^{\frac {\sqrt {-b \,a^{3}}\, x}{a}}}{a}-\frac {c_2 \sqrt {-b \,a^{3}}\, {\mathrm e}^{-\frac {\sqrt {-b \,a^{3}}\, x}{a}}}{a}\right ) \cos \left (x \right )^{-a b}+\frac {\left (c_1 \,{\mathrm e}^{\frac {\sqrt {-b \,a^{3}}\, x}{a}}+c_2 \,{\mathrm e}^{-\frac {\sqrt {-b \,a^{3}}\, x}{a}}\right ) \cos \left (x \right )^{-a b} a b \sin \left (x \right )}{\cos \left (x \right )}\right ) \cos \left (x \right )^{a b}}{a \left (c_1 \,{\mathrm e}^{\frac {\sqrt {-b \,a^{3}}\, x}{a}}+c_2 \,{\mathrm e}^{-\frac {\sqrt {-b \,a^{3}}\, x}{a}}\right )} \\ \end{align*}
Doing change of constants, the above solution becomes
\[ y = -\frac {\left (\left (\frac {\sqrt {-b \,a^{3}}\, {\mathrm e}^{\frac {\sqrt {-b \,a^{3}}\, x}{a}}}{a}-\frac {c_3 \sqrt {-b \,a^{3}}\, {\mathrm e}^{-\frac {\sqrt {-b \,a^{3}}\, x}{a}}}{a}\right ) \cos \left (x \right )^{-a b}+\frac {\left ({\mathrm e}^{\frac {\sqrt {-b \,a^{3}}\, x}{a}}+c_3 \,{\mathrm e}^{-\frac {\sqrt {-b \,a^{3}}\, x}{a}}\right ) \cos \left (x \right )^{-a b} a b \sin \left (x \right )}{\cos \left (x \right )}\right ) \cos \left (x \right )^{a b}}{a \left ({\mathrm e}^{\frac {\sqrt {-b \,a^{3}}\, x}{a}}+c_3 \,{\mathrm e}^{-\frac {\sqrt {-b \,a^{3}}\, x}{a}}\right )} \]
Simplifying the above gives
\begin{align*} y &= \frac {-\left ({\mathrm e}^{\frac {2 \sqrt {-b \,a^{3}}\, x}{a}}+c_3 \right ) b \,a^{2} \tan \left (x \right )-\sqrt {-b \,a^{3}}\, \left ({\mathrm e}^{\frac {2 \sqrt {-b \,a^{3}}\, x}{a}}-c_3 \right )}{a^{2} \left ({\mathrm e}^{\frac {2 \sqrt {-b \,a^{3}}\, x}{a}}+c_3 \right )} \\ \end{align*}

Summary of solutions found

\begin{align*} y &= \frac {-\left ({\mathrm e}^{\frac {2 \sqrt {-b \,a^{3}}\, x}{a}}+c_3 \right ) b \,a^{2} \tan \left (x \right )-\sqrt {-b \,a^{3}}\, \left ({\mathrm e}^{\frac {2 \sqrt {-b \,a^{3}}\, x}{a}}-c_3 \right )}{a^{2} \left ({\mathrm e}^{\frac {2 \sqrt {-b \,a^{3}}\, x}{a}}+c_3 \right )} \\ \end{align*}
2.11.4.2 Maple. Time used: 0.003 (sec). Leaf size: 89
ode:=diff(y(x),x) = a*y(x)^2+2*a*b*tan(x)*y(x)+b*(a*b-1)*tan(x)^2; 
dsolve(ode,y(x), singsol=all);
 
\[ y = \frac {2 \tan \left (x \right ) a^{{3}/{2}} b^{{3}/{2}} c_1 +2 i a b c_1 -i \tan \left (x \right ) {\mathrm e}^{-2 i \sqrt {a}\, \sqrt {b}\, x} a b -\sqrt {a}\, \sqrt {b}\, {\mathrm e}^{-2 i \sqrt {a}\, \sqrt {b}\, x}}{a \left (-2 c_1 \sqrt {a}\, \sqrt {b}+i {\mathrm e}^{-2 i \sqrt {a}\, \sqrt {b}\, x}\right )} \]

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 polynomial solution successful
 

Maple step by step

\[ \begin {array}{lll} & {} & \textrm {Let's solve}\hspace {3pt} \\ {} & {} & \frac {d}{d x}y \left (x \right )=a y \left (x \right )^{2}+2 a b \tan \left (x \right ) y \left (x \right )+b \left (a b -1\right ) \tan \left (x \right )^{2} \\ \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 )=a y \left (x \right )^{2}+2 a b \tan \left (x \right ) y \left (x \right )+b \left (a b -1\right ) \tan \left (x \right )^{2} \end {array} \]
2.11.4.3 Mathematica. Time used: 5.235 (sec). Leaf size: 37
ode=D[y[x],x]==a*y[x]^2+2*a*b*Tan[x]*y[x]+b*(a*b-1)*Tan[x]^2; 
ic={}; 
DSolve[{ode,ic},y[x],x,IncludeSingularSolutions->True]
 
\begin{align*} y(x)&\to -b \tan (x)+\sqrt {\frac {b}{a}} \tan \left (a x \sqrt {\frac {b}{a}}+c_1\right ) \end{align*}
2.11.4.4 Sympy. Time used: 19.630 (sec). Leaf size: 71
from sympy import * 
x = symbols("x") 
a = symbols("a") 
b = symbols("b") 
y = Function("y") 
ode = Eq(-2*a*b*y(x)*tan(x) - a*y(x)**2 - b*(a*b - 1)*tan(x)**2 + Derivative(y(x), x),0) 
ics = {} 
dsolve(ode,func=y(x),ics=ics)
 
\[ C_{1} + x + \frac {\sqrt {- \frac {1}{a b}} \log {\left (- b \sqrt {- \frac {1}{a b}} + b \tan {\left (x \right )} + y{\left (x \right )} \right )}}{2} - \frac {\sqrt {- \frac {1}{a b}} \log {\left (b \sqrt {- \frac {1}{a b}} + b \tan {\left (x \right )} + y{\left (x \right )} \right )}}{2} = 0 \]