12.1.22 problem Problem 14.26

Internal problem ID [3478]
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.26
Date solved : Tuesday, September 30, 2025 at 06:39:55 AM
CAS classification : [_linear]

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

With initial conditions

\begin{align*} y \left (\frac {\pi }{2}\right )&=1 \\ \end{align*}
Maple. Time used: 0.025 (sec). Leaf size: 10
ode:=diff(y(x),x)*sin(x)+2*cos(x)*y(x) = 1; 
ic:=[y(1/2*Pi) = 1]; 
dsolve([ode,op(ic)],y(x), singsol=all);
 
\[ y = \frac {1}{\cos \left (x \right )+1} \]
Mathematica. Time used: 0.028 (sec). Leaf size: 14
ode=Sin[x]*D[y[x],x]+2*y[x]*Cos[x]==1; 
ic=y[Pi/2]==1; 
DSolve[{ode,ic},y[x],x,IncludeSingularSolutions->True]
 
\begin{align*} y(x)&\to \tan \left (\frac {x}{2}\right ) \csc (x) \end{align*}
Sympy
from sympy import * 
x = symbols("x") 
y = Function("y") 
ode = Eq(2*y(x)*cos(x) + sin(x)*Derivative(y(x), x) - 1,0) 
ics = {y(pi/2): 1} 
dsolve(ode,func=y(x),ics=ics)
 
ValueError : Couldnt solve for initial conditions