18.1.26 problem Problem 14.30 (b)

Internal problem ID [3482]
Book : Mathematical methods for physics and engineering, Riley, Hobson, Bence, second edition, 2002
Section : Chapter 14, First order ordinary differential equations. 14.4 Exercises, page 490
Problem number : Problem 14.30 (b)
Date solved : Sunday, March 30, 2025 at 01:44:25 AM
CAS classification : [[_1st_order, `_with_symmetry_[F(x)*G(y),0]`]]

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

With initial conditions

\begin{align*} y \left (0\right )&=\frac {\pi }{2} \end{align*}

Maple. Time used: 4.250 (sec). Leaf size: 18
ode:=(2*sin(y(x))-x)*diff(y(x),x) = tan(y(x)); 
ic:=y(0) = 1/2*Pi; 
dsolve([ode,ic],y(x), singsol=all);
 
\[ y = \arcsin \left (\frac {x}{2}+\frac {\sqrt {x^{2}+4}}{2}\right ) \]
Mathematica. Time used: 18.142 (sec). Leaf size: 67
ode=(2*Sin[y[x]]-x)*D[y[x],x]==Tan[y[x]]; 
ic=y[0]==Pi/2; 
DSolve[{ode,ic},y[x],x,IncludeSingularSolutions->True]
 
\begin{align*} y(x)\to \cot ^{-1}\left (\sqrt {\frac {x^2}{2}-\frac {1}{2} \sqrt {x^4+4 x^2}}\right ) \\ y(x)\to \cot ^{-1}\left (\frac {\sqrt {x^2+\sqrt {x^2 \left (x^2+4\right )}}}{\sqrt {2}}\right ) \\ \end{align*}
Sympy. Time used: 137.988 (sec). Leaf size: 76
from sympy import * 
x = symbols("x") 
y = Function("y") 
ode = Eq((-x + 2*sin(y(x)))*Derivative(y(x), x) - tan(y(x)),0) 
ics = {y(0): pi/2} 
dsolve(ode,func=y(x),ics=ics)
 
\[ \left [ y{\left (x \right )} = 2 \operatorname {atan}{\left (- \frac {x}{2} + \frac {\sqrt {x^{2} + 4}}{2} + \sqrt {\frac {\left (x - \sqrt {x^{2} + 4}\right )^{2}}{4} - 1} \right )}, \ y{\left (x \right )} = - 2 \operatorname {atan}{\left (\frac {x}{2} - \frac {\sqrt {x^{2} + 4}}{2} + \sqrt {\frac {\left (x - \sqrt {x^{2} + 4}\right )^{2}}{4} - 1} \right )}\right ] \]