2.1.4 Problem 5

Maple step by step solution
Maple trace
Maple dsolve solution
Mathematica DSolve solution
Sympy solution

Internal problem ID [18525]
Book : Elementary Differential Equations. By Thornton C. Fry. D Van Nostrand. NY. First Edition (1929)
Section : Chapter 1. section 5. Problems at page 19
Problem number : 5
Date solved : Sunday, February 23, 2025 at 09:48:05 AM
CAS classification : [[_2nd_order, _with_linear_symmetries]]

Solve

\begin{align*} \cos \left (x \right ) y^{\prime }+\sin \left (x \right ) y^{\prime \prime }+n y \sin \left (x \right )&=0 \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 
-> Heun: Equivalence to the GHE or one of its 4 confluent cases under a power @ Moebius 
-> trying a solution of the form r0(x) * Y + r1(x) * Y where Y = exp(int(r(x), dx)) * 2F1([a1, a2], [b1], f) 
-> Trying changes of variables to rationalize or make the ODE simpler 
   trying a quadrature 
   checking if the LODE has constant coefficients 
   checking if the LODE is of Euler type 
   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 
   <- No Liouvillian solutions exists 
   -> Trying a solution in terms of special functions: 
      -> Bessel 
      -> elliptic 
      -> Legendre 
      <- Legendre successful 
   <- special function solution successful 
   Change of variables used: 
      [x = arccos(t)] 
   Linear ODE actually solved: 
      (-n*t^2+n)*u(t)+(2*t^3-2*t)*diff(u(t),t)+(t^4-2*t^2+1)*diff(diff(u(t),t),t) = 0 
<- change of variables successful`
 
Maple dsolve solution

Solving time : 0.048 (sec)
Leaf size : 37

dsolve(cos(x)*diff(y(x),x)+sin(x)*diff(diff(y(x),x),x)+n*y(x)*sin(x) = 0,y(x),singsol=all)
 
\[ y \left (x \right ) = c_{1} \operatorname {LegendreP}\left (\frac {\sqrt {4 n +1}}{2}-\frac {1}{2}, \cos \left (x \right )\right )+c_{2} \operatorname {LegendreQ}\left (\frac {\sqrt {4 n +1}}{2}-\frac {1}{2}, \cos \left (x \right )\right ) \]
Mathematica DSolve solution

Solving time : 0.112 (sec)
Leaf size : 48

DSolve[{D[Sin[x]*D[y[x],x],x]+n*y[x]*Sin[x]==0,{}},y[x],x,IncludeSingularSolutions->True]
 
\[ y(x)\to c_1 \operatorname {LegendreP}\left (\frac {1}{2} \left (\sqrt {4 n+1}-1\right ),\cos (x)\right )+c_2 \operatorname {LegendreQ}\left (\frac {1}{2} \left (\sqrt {4 n+1}-1\right ),\cos (x)\right ) \]
Sympy solution

Solving time : 0.000 (sec)
Leaf size : 0

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") 
n = symbols("n") 
y = Function("y") 
ode = Eq(n*y(x)*sin(x) + sin(x)*Derivative(y(x), (x, 2)) + cos(x)*Derivative(y(x), x),0) 
ics = {} 
dsolve(ode,func=y(x),ics=ics)
 
NotImplementedError : The given ODE -(-n*y(x) - Derivative(y(x), (x, 2)))*tan(x) + Derivative(y(x), x) cannot be solved by the factorable group method