58.2.39 problem 39

Internal problem ID [9162]
Book : Second order enumerated odes
Section : section 2
Problem number : 39
Date solved : Sunday, March 30, 2025 at 02:24:27 PM
CAS classification : [_linear]

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

Maple. Time used: 0.002 (sec). Leaf size: 16
ode:=diff(y(x),x)+y(x)*cot(x) = 2*cos(x); 
dsolve(ode,y(x), singsol=all);
 
\[ y = \left (-\cos \left (x \right )^{2}+c_1 +\frac {1}{2}\right ) \csc \left (x \right ) \]
Mathematica. Time used: 0.04 (sec). Leaf size: 23
ode=D[y[x],x]+y[x]*Cot[x]==2*Cos[x]; 
ic={}; 
DSolve[{ode,ic},y[x],x,IncludeSingularSolutions->True]
 
\[ y(x)\to \csc (x) \left (\int _1^x\sin (2 K[1])dK[1]+c_1\right ) \]
Sympy. Time used: 0.990 (sec). Leaf size: 12
from sympy import * 
x = symbols("x") 
y = Function("y") 
ode = Eq(y(x)/tan(x) - 2*cos(x) + Derivative(y(x), x),0) 
ics = {} 
dsolve(ode,func=y(x),ics=ics)
 
\[ y{\left (x \right )} = \frac {C_{1} - \cos ^{2}{\left (x \right )}}{\sin {\left (x \right )}} \]