2.1.11 Problem 11

2.1.11.1 Solved using first_order_ode_linear
2.1.11.2 Maple
2.1.11.3 Mathematica
2.1.11.4 Sympy

Internal problem ID [9997]
Book : Own collection of miscellaneous problems
Section : section 1.0
Problem number : 11
Date solved : Monday, December 08, 2025 at 06:30:14 PM
CAS classification : [_linear]

2.1.11.1 Solved using first_order_ode_linear

0.037 (sec)

Entering first order ode linear solver

\begin{align*} y^{\prime }&=x +\frac {\sec \left (x \right ) y}{x} \\ \end{align*}
In canonical form a linear first order is
\begin{align*} y^{\prime } + q(x)y &= p(x) \end{align*}

Comparing the above to the given ode shows that

\begin{align*} q(x) &=-\frac {\sec \left (x \right )}{x}\\ p(x) &=x \end{align*}

The integrating factor \(\mu \) is

\[ \mu = {\mathrm e}^{\int -\frac {\sec \left (x \right )}{x}d x} \]
Therefore the solution is
\[ y = \left (\int x \,{\mathrm e}^{\int -\frac {\sec \left (x \right )}{x}d x}d x +c_1 \right ) {\mathrm e}^{-\int -\frac {\sec \left (x \right )}{x}d x} \]
Figure 2.29: Slope field \(y^{\prime } = x +\frac {\sec \left (x \right ) y}{x}\)

Summary of solutions found

\begin{align*} y &= \left (\int x \,{\mathrm e}^{\int -\frac {\sec \left (x \right )}{x}d x}d x +c_1 \right ) {\mathrm e}^{-\int -\frac {\sec \left (x \right )}{x}d x} \\ \end{align*}
2.1.11.2 Maple. Time used: 0.000 (sec). Leaf size: 31
ode:=diff(y(x),x) = x+sec(x)*y(x)/x; 
dsolve(ode,y(x), singsol=all);
 
\[ y = \left (\int x \,{\mathrm e}^{-\int \frac {\sec \left (x \right )}{x}d x}d x +c_1 \right ) {\mathrm e}^{\int \frac {\sec \left (x \right )}{x}d x} \]

Maple trace

Methods for first order ODEs: 
--- Trying classification methods --- 
trying a quadrature 
trying 1st order linear 
<- 1st order linear successful
 

Maple step by step

\[ \begin {array}{lll} & {} & \textrm {Let's solve}\hspace {3pt} \\ {} & {} & \frac {d}{d x}y \left (x \right )=x +\frac {\sec \left (x \right ) y \left (x \right )}{x} \\ \bullet & {} & \textrm {Highest derivative means the order of the ODE is}\hspace {3pt} 1 \\ {} & {} & \frac {d}{d x}y \left (x \right ) \\ \bullet & {} & \textrm {Solve for the highest derivative}\hspace {3pt} \\ {} & {} & \frac {d}{d x}y \left (x \right )=x +\frac {\sec \left (x \right ) y \left (x \right )}{x} \\ \bullet & {} & \textrm {Group terms with}\hspace {3pt} y \left (x \right )\hspace {3pt}\textrm {on the lhs of the ODE and the rest on the rhs of the ODE}\hspace {3pt} \\ {} & {} & \frac {d}{d x}y \left (x \right )-\frac {\sec \left (x \right ) y \left (x \right )}{x}=x \\ \bullet & {} & \textrm {The ODE is linear; multiply by an integrating factor}\hspace {3pt} \mu \left (x \right ) \\ {} & {} & \mu \left (x \right ) \left (\frac {d}{d x}y \left (x \right )-\frac {\sec \left (x \right ) y \left (x \right )}{x}\right )=\mu \left (x \right ) x \\ \bullet & {} & \textrm {Assume the lhs of the ODE is the total derivative}\hspace {3pt} \frac {d}{d x}\left (y \left (x \right ) \mu \left (x \right )\right ) \\ {} & {} & \mu \left (x \right ) \left (\frac {d}{d x}y \left (x \right )-\frac {\sec \left (x \right ) y \left (x \right )}{x}\right )=\left (\frac {d}{d x}y \left (x \right )\right ) \mu \left (x \right )+y \left (x \right ) \left (\frac {d}{d x}\mu \left (x \right )\right ) \\ \bullet & {} & \textrm {Isolate}\hspace {3pt} \frac {d}{d x}\mu \left (x \right ) \\ {} & {} & \frac {d}{d x}\mu \left (x \right )=-\frac {\mu \left (x \right ) \sec \left (x \right )}{x} \\ \bullet & {} & \textrm {Solve to find the integrating factor}\hspace {3pt} \\ {} & {} & \mu \left (x \right )={\mathrm e}^{\int -\frac {\sec \left (x \right )}{x}d x} \\ \bullet & {} & \textrm {Integrate both sides with respect to}\hspace {3pt} x \\ {} & {} & \int \left (\frac {d}{d x}\left (y \left (x \right ) \mu \left (x \right )\right )\right )d x =\int \mu \left (x \right ) x d x +\mathit {C1} \\ \bullet & {} & \textrm {Evaluate the integral on the lhs}\hspace {3pt} \\ {} & {} & y \left (x \right ) \mu \left (x \right )=\int \mu \left (x \right ) x d x +\mathit {C1} \\ \bullet & {} & \textrm {Solve for}\hspace {3pt} y \left (x \right ) \\ {} & {} & y \left (x \right )=\frac {\int \mu \left (x \right ) x d x +\mathit {C1}}{\mu \left (x \right )} \\ \bullet & {} & \textrm {Substitute}\hspace {3pt} \mu \left (x \right )={\mathrm e}^{\int -\frac {\sec \left (x \right )}{x}d x} \\ {} & {} & y \left (x \right )=\frac {\int {\mathrm e}^{\int -\frac {\sec \left (x \right )}{x}d x} x d x +\mathit {C1}}{{\mathrm e}^{\int -\frac {\sec \left (x \right )}{x}d x}} \\ \bullet & {} & \textrm {Simplify}\hspace {3pt} \\ {} & {} & y \left (x \right )=\left (\int {\mathrm e}^{-\int \frac {\sec \left (x \right )}{x}d x} x d x +\mathit {C1} \right ) {\mathrm e}^{\int \frac {\sec \left (x \right )}{x}d x} \end {array} \]
2.1.11.3 Mathematica. Time used: 0.048 (sec). Leaf size: 56
ode=D[y[x],x] == x+Sec[x]*y[x]/x; 
ic={}; 
DSolve[{ode,ic},y[x],x,IncludeSingularSolutions->True]
 
\begin{align*} y(x)&\to \exp \left (\int _1^x\frac {\sec (K[1])}{K[1]}dK[1]\right ) \left (\int _1^x\exp \left (-\int _1^{K[2]}\frac {\sec (K[1])}{K[1]}dK[1]\right ) K[2]dK[2]+c_1\right ) \end{align*}
2.1.11.4 Sympy. Time used: 9.135 (sec). Leaf size: 36
from sympy import * 
x = symbols("x") 
y = Function("y") 
ode = Eq(-x + Derivative(y(x), x) - y(x)/(x*cos(x)),0) 
ics = {} 
dsolve(ode,func=y(x),ics=ics)
                                                                                  
                                                                                  
 
\[ - \int x e^{- \int \frac {1}{x \cos {\left (x \right )}}\, dx}\, dx - \int \frac {y{\left (x \right )} e^{- \int \frac {1}{x \cos {\left (x \right )}}\, dx}}{x \cos {\left (x \right )}}\, dx = C_{1} \]