12.2.20 problem 20

Internal problem ID [1556]
Book : Elementary differential equations with boundary value problems. William F. Trench. Brooks/Cole 2001
Section : Chapter 2, First order equations. Linear first order. Section 2.1 Page 41
Problem number : 20
Date solved : Saturday, March 29, 2025 at 10:58:55 PM
CAS classification : [_linear]

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

Maple. Time used: 0.001 (sec). Leaf size: 10
ode:=diff(y(x),x)+y(x)*tan(x) = cos(x); 
dsolve(ode,y(x), singsol=all);
 
\[ y = \left (x +c_1 \right ) \cos \left (x \right ) \]
Mathematica. Time used: 0.04 (sec). Leaf size: 12
ode=D[y[x],x] +Tan[x]*y[x]==Cos[x]; 
ic={}; 
DSolve[{ode,ic},y[x],x,IncludeSingularSolutions->True]
 
\[ y(x)\to (x+c_1) \cos (x) \]
Sympy. Time used: 0.395 (sec). Leaf size: 8
from sympy import * 
x = symbols("x") 
y = Function("y") 
ode = Eq(y(x)*tan(x) - cos(x) + Derivative(y(x), x),0) 
ics = {} 
dsolve(ode,func=y(x),ics=ics)
 
\[ y{\left (x \right )} = \left (C_{1} + x\right ) \cos {\left (x \right )} \]