6.6.21 problem 21

Internal problem ID [1700]
Book : Elementary differential equations with boundary value problems. William F. Trench. Brooks/Cole 2001
Section : Chapter 2, First order equations. Exact equations. Section 2.5 Page 79
Problem number : 21
Date solved : Tuesday, September 30, 2025 at 05:15:13 AM
CAS classification : [_linear]

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

With initial conditions

\begin{align*} y \left (0\right )&=1 \\ \end{align*}
Maple. Time used: 0.020 (sec). Leaf size: 10
ode:=sin(x)-sin(x)*y(x)-2*cos(x)+cos(x)*diff(y(x),x) = 0; 
ic:=[y(0) = 1]; 
dsolve([ode,op(ic)],y(x), singsol=all);
 
\[ y = 1+2 \tan \left (x \right ) \]
Mathematica. Time used: 0.058 (sec). Leaf size: 11
ode=(Sin[x]-y[x]*Sin[x]-2*Cos[x])+(Cos[x])*D[y[x],x]==0; 
ic=y[0]==1; 
DSolve[{ode,ic},y[x],x,IncludeSingularSolutions->True]
 
\begin{align*} y(x)&\to 2 \tan (x)+1 \end{align*}
Sympy. Time used: 0.374 (sec). Leaf size: 8
from sympy import * 
x = symbols("x") 
y = Function("y") 
ode = Eq(-y(x)*sin(x) + sin(x) + cos(x)*Derivative(y(x), x) - 2*cos(x),0) 
ics = {y(0): 1} 
dsolve(ode,func=y(x),ics=ics)
 
\[ y{\left (x \right )} = 2 \tan {\left (x \right )} + 1 \]