12.7.20 problem 21

Internal problem ID [1730]
Book : Elementary differential equations with boundary value problems. William F. Trench. Brooks/Cole 2001
Section : Chapter 2, First order equations. Exact equations. Integrating factors. Section 2.6 Page 91
Problem number : 21
Date solved : Tuesday, March 04, 2025 at 01:40:51 PM
CAS classification : [_linear]

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

Maple. Time used: 0.002 (sec). Leaf size: 71
ode:=a*cos(x)*y(x)-y(x)^2*sin(x)+(b*cos(x)*y(x)-x*sin(x)*y(x))*diff(y(x),x) = 0; 
dsolve(ode,y(x), singsol=all);
 
\begin{align*} y &= 0 \\ y &= -\left (a \left (\int \frac {\cos \left (x \right ) {\mathrm e}^{-\int \frac {\sin \left (x \right )}{\cos \left (x \right ) b -x \sin \left (x \right )}d x}}{\cos \left (x \right ) b -x \sin \left (x \right )}d x \right )-c_1 \right ) {\mathrm e}^{\int \frac {\sin \left (x \right )}{\cos \left (x \right ) b -x \sin \left (x \right )}d x} \\ \end{align*}
Mathematica. Time used: 3.355 (sec). Leaf size: 106
ode=(a*Cos[x]*y[x]-y[x]*Sin[x]*y[x])+(b*Cos[x]*y[x]-x*Sin[x]*y[x])*D[y[x],x]==0; 
ic={}; 
DSolve[{ode,ic},y[x],x,IncludeSingularSolutions->True]
 
\begin{align*} y(x)\to 0 \\ y(x)\to \exp \left (\int _1^x\frac {\sin (K[1])}{b \cos (K[1])-K[1] \sin (K[1])}dK[1]\right ) \left (\int _1^x-\frac {a \exp \left (-\int _1^{K[2]}\frac {\sin (K[1])}{b \cos (K[1])-K[1] \sin (K[1])}dK[1]\right ) \cos (K[2])}{b \cos (K[2])-K[2] \sin (K[2])}dK[2]+c_1\right ) \\ y(x)\to 0 \\ \end{align*}
Sympy
from sympy import * 
x = symbols("x") 
a = symbols("a") 
b = symbols("b") 
y = Function("y") 
ode = Eq(a*y(x)*cos(x) + (b*y(x)*cos(x) - x*y(x)*sin(x))*Derivative(y(x), x) - y(x)**2*sin(x),0) 
ics = {} 
dsolve(ode,func=y(x),ics=ics)
 
TypeError : < not supported between instances of NoneType and Zero