2.2.29 Problem 29

Solved as second order ode using change of variable on y method 1
Maple step by step solution
Maple trace
Maple dsolve solution
Mathematica DSolve solution
Sympy solution

Internal problem ID [9152]
Book : Second order enumerated odes
Section : section 2
Problem number : 29
Date solved : Friday, February 21, 2025 at 09:21:44 PM
CAS classification : [_Lienard]

Solve

\begin{align*} \cos \left (x \right )^{2} y^{\prime \prime }-2 \cos \left (x \right ) \sin \left (x \right ) y^{\prime }+y \cos \left (x \right )^{2}&=0 \end{align*}

Solved as second order ode using change of variable on y method 1

Time used: 0.458 (sec)

In normal form the given ode is written as

\begin{align*} y^{\prime \prime }+p \left (x \right ) y^{\prime }+q \left (x \right ) y&=0 \tag {2} \end{align*}

Where

\begin{align*} p \left (x \right )&=-\frac {\sin \left (2 x \right )}{\cos \left (x \right )^{2}}\\ q \left (x \right )&=1 \end{align*}

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

\begin{align*} Q &= q - \frac {p'}{2}- \frac {p^2}{4} \\ &= 1 - \frac {\left (-\frac {\sin \left (2 x \right )}{\cos \left (x \right )^{2}}\right )'}{2}- \frac {\left (-\frac {\sin \left (2 x \right )}{\cos \left (x \right )^{2}}\right )^2}{4} \\ &= 1 - \frac {\left (-\frac {2 \cos \left (2 x \right )}{\cos \left (x \right )^{2}}-\frac {2 \sin \left (2 x \right ) \sin \left (x \right )}{\cos \left (x \right )^{3}}\right )}{2}- \frac {\left (\frac {\sin \left (2 x \right )^{2}}{\cos \left (x \right )^{4}}\right )}{4} \\ &= 1 - \left (-\frac {\cos \left (2 x \right )}{\cos \left (x \right )^{2}}-\frac {\sin \left (2 x \right ) \sin \left (x \right )}{\cos \left (x \right )^{3}}\right )-\frac {\sin \left (2 x \right )^{2}}{4 \cos \left (x \right )^{4}}\\ &= 2 \end{align*}

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

\begin{align*} y = 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 {-\frac {\sin \left (2 x \right )}{\cos \left (x \right )^{2}}}{2} }\\ &= \sec \left (x \right )\tag {5} \end{align*}

Hence (3) becomes

\begin{align*} y = v \left (x \right ) \sec \left (x \right )\tag {4} \end{align*}

Applying this change of variable to the original ode results in

\begin{align*} \cos \left (x \right ) \left (2 v \left (x \right )+v^{\prime \prime }\left (x \right )\right ) = 0 \end{align*}

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

The above ode can be simplified to

\begin{align*} 2 v \left (x \right )+v^{\prime \prime }\left (x \right ) = 0 \end{align*}

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=1, B=0, C=2\). Let the solution be \(v \left (x \right )=e^{\lambda x}\). Substituting this into the ODE gives

\[ \lambda ^{2} {\mathrm e}^{x \lambda }+2 \,{\mathrm e}^{x \lambda } = 0 \tag {1} \]

Since exponential function is never zero, then dividing Eq(2) throughout by \(e^{\lambda x}\) gives

\[ \lambda ^{2}+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=1, B=0, C=2\) into the above gives

\begin{align*} \lambda _{1,2} &= \frac {0}{(2) \left (1\right )} \pm \frac {1}{(2) \left (1\right )} \sqrt {0^2 - (4) \left (1\right )\left (2\right )}\\ &= \pm i \sqrt {2} \end{align*}

Hence

\begin{align*} \lambda _1 &= + i \sqrt {2}\\ \lambda _2 &= - i \sqrt {2} \end{align*}

Which simplifies to

\begin{align*} \lambda _1 &= i \sqrt {2} \\ \lambda _2 &= -i \sqrt {2} \\ \end{align*}

Since roots are complex conjugate of each others, then let the roots be

\[ \lambda _{1,2} = \alpha \pm i \beta \]

Where \(\alpha =0\) and \(\beta =\sqrt {2}\). Therefore the final solution, when using Euler relation, can be written as

\[ v \left (x \right ) = e^{\alpha x} \left ( c_1 \cos (\beta x) + c_2 \sin (\beta x) \right ) \]

Which becomes

\[ v \left (x \right ) = e^{0}\left (c_1 \cos \left (\sqrt {2}\, x \right )+c_2 \sin \left (\sqrt {2}\, x \right )\right ) \]

Or

\[ v \left (x \right ) = c_1 \cos \left (\sqrt {2}\, x \right )+c_2 \sin \left (\sqrt {2}\, x \right ) \]

Will add steps showing solving for IC soon.

Now that \(v \left (x \right )\) is known, then

\begin{align*} y&= v \left (x \right ) z \left (x \right )\\ &= \left (c_1 \cos \left (\sqrt {2}\, x \right )+c_2 \sin \left (\sqrt {2}\, x \right )\right ) \left (z \left (x \right )\right )\tag {7} \end{align*}

But from (5)

\begin{align*} z \left (x \right )&= \sec \left (x \right ) \end{align*}

Hence (7) becomes

\begin{align*} y = \left (c_1 \cos \left (\sqrt {2}\, x \right )+c_2 \sin \left (\sqrt {2}\, x \right )\right ) \sec \left (x \right ) \end{align*}

Will add steps showing solving for IC soon.

Summary of solutions found

\begin{align*} y &= \left (c_1 \cos \left (\sqrt {2}\, x \right )+c_2 \sin \left (\sqrt {2}\, x \right )\right ) \sec \left (x \right ) \\ \end{align*}

Maple step by step solution

Maple trace
`Methods for second order ODEs: 
--- Trying classification methods --- 
trying a symmetry of the form [xi=0, eta=F(x)] 
checking if the LODE is missing y 
-> Trying a Liouvillian solution using Kovacics algorithm 
   A Liouvillian solution exists 
   Group is reducible or imprimitive 
<- Kovacics algorithm successful`
 
Maple dsolve solution

Solving time : 0.004 (sec)
Leaf size : 24

dsolve(cos(x)^2*diff(diff(y(x),x),x)-2*cos(x)*sin(x)*diff(y(x),x)+cos(x)^2*y(x) = 0,y(x),singsol=all)
 
\[ y = \sec \left (x \right ) \left (c_{1} \sin \left (\sqrt {2}\, x \right )+c_{2} \cos \left (\sqrt {2}\, x \right )\right ) \]
Mathematica DSolve solution

Solving time : 0.062 (sec)
Leaf size : 51

DSolve[{Cos[x]^2*D[y[x],{x,2}]-2*Cos[x]*Sin[x]*D[y[x],x]+y[x]*Cos[x]^2==0,{}},y[x],x,IncludeSingularSolutions->True]
 
\[ y(x)\to \frac {1}{4} e^{-i \sqrt {2} x} \left (4 c_1-i \sqrt {2} c_2 e^{2 i \sqrt {2} x}\right ) \sec (x) \]
Sympy solution

Solving time : 2.140 (sec)
Leaf size : 83

Python version: 3.13.1 (main, Dec  4 2024, 18:05:56) [GCC 14.2.1 20240910] 
Sympy version 1.13.3
 
from sympy import * 
x = symbols("x") 
y = Function("y") 
ode = Eq(y(x)*cos(x)**2 - 2*sin(x)*cos(x)*Derivative(y(x), x) + cos(x)**2*Derivative(y(x), (x, 2)),0) 
ics = {} 
dsolve(ode,func=y(x),ics=ics)
 
Eq(y(x), C2*(-x**4*tan(x)**2/6 + x**4/24 - x**3*tan(x)/3 - x**2/2 + 1) 
+ C1*x*(x**3*tan(x)**3/3 - x**3*tan(x)/6 + 2*x**2*tan(x)**2/3 - x**2/6 
+ x*tan(x) + 1) + O(x**6))
 
\[ y{\left (x \right )} = C_{2} \left (- \frac {x^{4} \tan ^{2}{\left (x \right )}}{6} + \frac {x^{4}}{24} - \frac {x^{3} \tan {\left (x \right )}}{3} - \frac {x^{2}}{2} + 1\right ) + C_{1} x \left (\frac {x^{3} \tan ^{3}{\left (x \right )}}{3} - \frac {x^{3} \tan {\left (x \right )}}{6} + \frac {2 x^{2} \tan ^{2}{\left (x \right )}}{3} - \frac {x^{2}}{6} + x \tan {\left (x \right )} + 1\right ) + O\left (x^{6}\right ) \]