59.5.5 problem 10.2

Internal problem ID [15025]
Book : AN INTRODUCTION TO ORDINARY DIFFERENTIAL EQUATIONS by JAMES C. ROBINSON. Cambridge University Press 2004
Section : Chapter 10, Two tricks for nonlinear equations. Exercises page 97
Problem number : 10.2
Date solved : Thursday, October 02, 2025 at 10:01:53 AM
CAS classification : [[_1st_order, `_with_symmetry_[F(x),G(x)]`]]

\begin{align*} {\mathrm e}^{-y} \sec \left (x \right )+2 \cos \left (x \right )-{\mathrm e}^{-y} y^{\prime }&=0 \end{align*}
Maple. Time used: 0.014 (sec). Leaf size: 45
ode:=exp(-y(x))*sec(x)+2*cos(x)-exp(-y(x))*diff(y(x),x) = 0; 
dsolve(ode,y(x), singsol=all);
 
\[ y = \ln \left (-\frac {\left (\sin \left (\frac {x}{2}\right )+\cos \left (\frac {x}{2}\right )\right )^{2}}{\left (-4 \cos \left (\frac {x}{2}\right )^{2}+c_1 +2 x \right ) \left (2 \cos \left (\frac {x}{2}\right )^{2}-1\right )}\right ) \]
Mathematica. Time used: 0.798 (sec). Leaf size: 33
ode=Exp[-y[x]]*Sec[x]+2*Cos[x]-Exp[-y[x]]*D[y[x],x]==0; 
ic={}; 
DSolve[{ode,ic},y[x],x,IncludeSingularSolutions->True]
 
\begin{align*} y(x)&\to \log \left (\frac {e^{2 \text {arctanh}\left (\tan \left (\frac {x}{2}\right )\right )}}{2 (-x+\cos (x)-2 c_1)}\right ) \end{align*}
Sympy
from sympy import * 
x = symbols("x") 
y = Function("y") 
ode = Eq(2*cos(x) - exp(-y(x))*Derivative(y(x), x) + exp(-y(x))/cos(x),0) 
ics = {} 
dsolve(ode,func=y(x),ics=ics)
 
TypeError : exp takes exactly 1 argument (2 given)