2.4.11 Problem 11

Maple
Mathematica
Sympy

Internal problem ID [10356]
Book : First order enumerated odes
Section : section 4. First order odes solved using series method
Problem number : 11
Date solved : Thursday, November 27, 2025 at 10:35:06 AM
CAS classification : [_linear]

\begin{align*} y^{\prime } \cos \left (x \right )+\frac {y}{x}&=x \\ \end{align*}
Series expansion around \(x=0\).

Since this is an inhomogeneous, then let the solution be

\[ y = y_h + y_p \]
Where \(y_h\) is the solution to the homogeneous ode \(y^{\prime } \cos \left (x \right )+\frac {y}{x} = 0\),and \(y_p\) is a particular solution to the inhomogeneous ode. First, we solve for \(y_h\) Let the homogeneous solution be represented as Frobenius power series of the form
\[ y = \moverset {\infty }{\munderset {n =0}{\sum }}a_{n} x^{n +r} \]
Then
\[ y^{\prime } = \moverset {\infty }{\munderset {n =0}{\sum }}\left (n +r \right ) a_{n} x^{n +r -1} \]
Substituting the above back into the ode gives
\begin{equation} \tag{1} \left (\moverset {\infty }{\munderset {n =0}{\sum }}\left (n +r \right ) a_{n} x^{n +r -1}\right ) \cos \left (x \right )+\frac {\moverset {\infty }{\munderset {n =0}{\sum }}a_{n} x^{n +r}}{x} = 0 \end{equation}
Hence the ODE in Eq (1) becomes
\[ \left (1-\frac {1}{2} x^{2}+\frac {1}{24} x^{4}-\frac {1}{720} x^{6}\right ) \left (\moverset {\infty }{\munderset {n =0}{\sum }}\left (n +r \right ) a_{n} x^{n +r -1}\right )+\frac {\moverset {\infty }{\munderset {n =0}{\sum }}a_{n} x^{n +r}}{x} = 0\tag {1} \]
Expanding the first term in (1) gives
\begin{equation} \tag{1} 1\cdot \left (\moverset {\infty }{\munderset {n =0}{\sum }}\left (n +r \right ) a_{n} x^{n +r -1}\right )-\frac {x^{2}}{2}\cdot \left (\moverset {\infty }{\munderset {n =0}{\sum }}\left (n +r \right ) a_{n} x^{n +r -1}\right )+\frac {x^{4}}{24}\cdot \left (\moverset {\infty }{\munderset {n =0}{\sum }}\left (n +r \right ) a_{n} x^{n +r -1}\right )-\frac {x^{6}}{720}\cdot \left (\moverset {\infty }{\munderset {n =0}{\sum }}\left (n +r \right ) a_{n} x^{n +r -1}\right )+\frac {\moverset {\infty }{\munderset {n =0}{\sum }}a_{n} x^{n +r}}{x} = 0 \end{equation}
Which simplifies to
\begin{equation} \tag{2A} \moverset {\infty }{\munderset {n =0}{\sum }}\left (-\frac {x^{n +r +5} a_{n} \left (n +r \right )}{720}\right )+\left (\moverset {\infty }{\munderset {n =0}{\sum }}\frac {x^{n +r +3} a_{n} \left (n +r \right )}{24}\right )+\moverset {\infty }{\munderset {n =0}{\sum }}\left (-\frac {x^{1+n +r} a_{n} \left (n +r \right )}{2}\right )+\left (\moverset {\infty }{\munderset {n =0}{\sum }}\left (n +r \right ) a_{n} x^{n +r -1}\right )+\left (\moverset {\infty }{\munderset {n =0}{\sum }}x^{n +r -1} a_{n}\right ) = 0 \end{equation}
The next step is to make all powers of \(x\) be \(n +r -1\) in each summation term. Going over each summation term above with power of \(x\) in it which is not already \(x^{n +r -1}\) and adjusting the power and the corresponding index gives
\begin{align*} \moverset {\infty }{\munderset {n =0}{\sum }}\left (-\frac {x^{n +r +5} a_{n} \left (n +r \right )}{720}\right ) &= \moverset {\infty }{\munderset {n =6}{\sum }}\left (-\frac {a_{n -6} \left (n +r -6\right ) x^{n +r -1}}{720}\right ) \\ \moverset {\infty }{\munderset {n =0}{\sum }}\frac {x^{n +r +3} a_{n} \left (n +r \right )}{24} &= \moverset {\infty }{\munderset {n =4}{\sum }}\frac {a_{n -4} \left (-4+n +r \right ) x^{n +r -1}}{24} \\ \moverset {\infty }{\munderset {n =0}{\sum }}\left (-\frac {x^{1+n +r} a_{n} \left (n +r \right )}{2}\right ) &= \moverset {\infty }{\munderset {n =2}{\sum }}\left (-\frac {a_{n -2} \left (n +r -2\right ) x^{n +r -1}}{2}\right ) \\ \end{align*}
Substituting all the above in Eq (2A) gives the following equation where now all powers of \(x\) are the same and equal to \(n +r -1\).
\begin{equation} \tag{2B} \moverset {\infty }{\munderset {n =6}{\sum }}\left (-\frac {a_{n -6} \left (n +r -6\right ) x^{n +r -1}}{720}\right )+\left (\moverset {\infty }{\munderset {n =4}{\sum }}\frac {a_{n -4} \left (-4+n +r \right ) x^{n +r -1}}{24}\right )+\moverset {\infty }{\munderset {n =2}{\sum }}\left (-\frac {a_{n -2} \left (n +r -2\right ) x^{n +r -1}}{2}\right )+\left (\moverset {\infty }{\munderset {n =0}{\sum }}\left (n +r \right ) a_{n} x^{n +r -1}\right )+\left (\moverset {\infty }{\munderset {n =0}{\sum }}x^{n +r -1} a_{n}\right ) = 0 \end{equation}
The indicial equation is obtained from \(n=0\). From Eq (2) this gives
\[ \left (n +r \right ) a_{n} x^{n +r -1}+x^{n +r -1} a_{n} = 0 \]
When \(n=0\) the above becomes
\[ r a_{0} x^{-1+r}+x^{-1+r} a_{0} = 0 \]
The corresponding balance equation is found by replacing \(r\) by \(m\) and \(a\) by \(c\) to avoid confusing terms between particular solution and the homogeneous solution. Hence the balance equation is
\[ \left (x^{-1+m} m +x^{-1+m}\right ) c_{0} = x \]
This equation will used later to find the particular solution.

Since \(a_{0}\neq 0\) then the indicial equation becomes

\[ \left (r +1\right ) x^{-1+r} = 0 \]
Since the above is true for all \(x\) then the indicial equation simplifies to
\[ r +1 = 0 \]
Solving for \(r\) gives the root of the indicial equation as
\[ r=-1 \]

Which after substituting earlier equations, simplifies to

\begin{gather*} a_{2} = \frac {a_{0} r}{6+2 r} \end{gather*}
\(n=2\) gives
\begin{gather*} -\frac {a_{1} \left (r +1\right )}{2}+a_{3} \left (3+r \right )+a_{3} = 0 \end{gather*}
Which after substituting earlier equations, simplifies to
\begin{gather*} \begin {aligned} a_{3} \left (3+r \right )+a_{3} = 0 \end {aligned} \end{gather*}
Or
\begin{gather*} \begin {aligned} a_{3} = 0 \end {aligned} \end{gather*}
Which after substituting earlier equations, simplifies to
\begin{gather*} a_{4} = \frac {a_{0} r \left (9+5 r \right )}{24 \left (3+r \right ) \left (5+r \right )} \end{gather*}
\(n=4\) gives
\begin{gather*} \frac {a_{1} \left (r +1\right )}{24}-\frac {a_{3} \left (3+r \right )}{2}+a_{5} \left (5+r \right )+a_{5} = 0 \end{gather*}
Which after substituting earlier equations, simplifies to
\begin{gather*} \begin {aligned} a_{5} \left (5+r \right )+a_{5} = 0 \end {aligned} \end{gather*}
Or
\begin{gather*} \begin {aligned} a_{5} = 0 \end {aligned} \end{gather*}
For \(6\le n\), the recurrence equation is
\begin{equation} \tag{4} -\frac {a_{n -6} \left (n +r -6\right )}{720}+\frac {a_{n -4} \left (-4+n +r \right )}{24}-\frac {a_{n -2} \left (n +r -2\right )}{2}+a_{n} \left (n +r \right )+a_{n} = 0 \end{equation}
And so on. Therefore the solution is
\begin{align*} y &= \moverset {\infty }{\munderset {n =0}{\sum }}a_{n} x^{n +r}\\ &= a_{0} x^{r}+a_{1} x^{r +1}+a_{2} x^{2+r}+a_{3} x^{3+r} + \dots \end{align*}

Substituting the values for \(a_{n}\) found above, the solution becomes

\[ y = a_{0} x^{r}+\frac {a_{0} r \,x^{2+r}}{6+2 r}+\frac {a_{0} r \left (9+5 r \right ) x^{4+r}}{24 \left (3+r \right ) \left (5+r \right )}+\dots \]
Which can be written as
\[ y = x^{r} \left (a_{0}+\frac {a_{0} r \,x^{2}}{6+2 r}+\frac {a_{0} r \left (9+5 r \right ) x^{4}}{24 \left (3+r \right ) \left (5+r \right )}+O\left (x^{6}\right ) a_{0}\right ) \]
Collecting terms, the solution becomes
\[ y = x^{r} \left (1+\frac {x^{2} r}{6+2 r}+\frac {r \left (9+5 r \right ) x^{4}}{24 \left (3+r \right ) \left (5+r \right )}+O\left (x^{6}\right )\right ) a_{0} \]
Finally, since \(r = -1\), then the solution becomes
\begin{equation} \tag{3} y_h =\frac {\left (1-\frac {x^{2}}{4}-\frac {x^{4}}{48}+O\left (x^{6}\right )\right ) a_{0}}{x} \end{equation}
Now the particular solution is found Solving the balance equation \(\left (x^{-1+m} m +x^{-1+m}\right ) c_{0} = x\) for \([c_{0}, m]\) gives
\begin{align*} c_{0} &= {\frac {1}{3}}\\ m &= 2 \end{align*}

replacing \(a_{n}\) and \(r\) in each term of summation equation (2B) by \(c_{n}\) and \(m\) results in

\[ \moverset {\infty }{\munderset {n =6}{\sum }}\left (-\frac {c_{n -6} \left (n +m -6\right ) x^{n +m -1}}{720}\right )+\left (\moverset {\infty }{\munderset {n =4}{\sum }}\frac {c_{n -4} \left (-4+n +m \right ) x^{n +m -1}}{24}\right )+\moverset {\infty }{\munderset {n =2}{\sum }}\left (-\frac {c_{n -2} \left (n +m -2\right ) x^{n +m -1}}{2}\right )+\left (\moverset {\infty }{\munderset {n =0}{\sum }}\left (n +m \right ) c_{n} x^{n +m -1}\right )+\left (\moverset {\infty }{\munderset {n =0}{\sum }}x^{n +m -1} c_{n}\right ) = 0 \]
replacing \(m\) by its value found which is \(2\) then the above becomes
\begin{equation} \tag{2B} \moverset {\infty }{\munderset {n =6}{\sum }}\left (-\frac {c_{n -6} \left (n -4\right ) x^{1+n}}{720}\right )+\left (\moverset {\infty }{\munderset {n =4}{\sum }}\frac {c_{n -4} \left (n -2\right ) x^{1+n}}{24}\right )+\moverset {\infty }{\munderset {n =2}{\sum }}\left (-\frac {c_{n -2} n \,x^{1+n}}{2}\right )+\left (\moverset {\infty }{\munderset {n =0}{\sum }}\left (n +2\right ) c_{n} x^{1+n}\right )+\left (\moverset {\infty }{\munderset {n =0}{\sum }}x^{1+n} c_{n}\right ) = 0 \end{equation}
The above equation (2B*) is now used to determine all \(c_{n}\) terms for \(0<n\).

Going over (2B*) and for \(n\) from \(1\) to order \(6\), the following set of equations are obtained

\[ \left [4 c_{1} = 0, -c_{0}+5 c_{2} = 0, -\frac {3 c_{1}}{2}+6 c_{3} = 0, \frac {c_{0}}{12}-2 c_{2}+7 c_{4} = 0, \frac {c_{1}}{8}-\frac {5 c_{3}}{2}+8 c_{5} = 0, -\frac {c_{0}}{360}+\frac {c_{2}}{6}-3 c_{4}+9 c_{6} = 0\right ] \]
Using \(c_{0}={\frac {1}{3}}\) the equations becomes
\[ \left [4 c_{1} = 0, -\frac {1}{3}+5 c_{2} = 0, -\frac {3 c_{1}}{2}+6 c_{3} = 0, \frac {1}{36}-2 c_{2}+7 c_{4} = 0, \frac {c_{1}}{8}-\frac {5 c_{3}}{2}+8 c_{5} = 0, -\frac {1}{1080}+\frac {c_{2}}{6}-3 c_{4}+9 c_{6} = 0\right ] \]
Solving these equations gives the coefficients \(c_{n}\) needed to find the particular solution
\[ \left \{c_{1} = 0, c_{2} = {\frac {1}{15}}, c_{3} = 0, c_{4} = {\frac {19}{1260}}, c_{5} = 0, c_{6} = {\frac {53}{13608}}\right \} \]
Therefore the particular solution for this term is
\begin{align*} y_p &= \sum _{n=0}^\infty c_{n} x^{n+m}\\ &= \sum _{n=0}^\infty c_{n} x^{n+2} \end{align*}

Applying the above using the values we found above for \(c_{n}\) results in

\begin{align*} y_p &= \frac {1}{3} x^{2}+c_{1} x^{3}+c_{2} x^{4}+c_{3} x^{5}+c_{4} x^{6}+c_{5} x^{7}+c_{6} x^{8} \\ &=\frac {1}{3} x^{2}+\frac {1}{15} x^{4}+\frac {19}{1260} x^{6}+\frac {53}{13608} x^{8} \\ \end{align*}
The above sum is truncated if needed such that no powers on \(x\) appear which is equal or larger than the equested order of \(6\). This results in
\[ y_p = \frac {1}{3} x^{2}+\frac {1}{15} x^{4} + O(x^6) \]
Hence the particular solution is
\begin{align*} y_p &= c_{\frac {1}{3} x^{2}+\frac {1}{15} x^{4}} \end{align*}

The solution is

\begin{align*} y&=y_h + y_p \\ y &= \frac {\left (1-\frac {x^{2}}{4}-\frac {x^{4}}{48}+O\left (x^{6}\right )\right ) c_1}{x}+\frac {x^{2}}{3}+\frac {x^{4}}{15} \\ \end{align*}
Figure 2.95: Slope field \(y^{\prime } \cos \left (x \right )+\frac {y}{x} = x\)
Maple. Time used: 0.007 (sec). Leaf size: 32
Order:=6; 
ode:=cos(x)*diff(y(x),x)+y(x)/x = x; 
dsolve(ode,y(x),type='series',x=0);
 
\[ y = \frac {c_1 \left (1-\frac {1}{4} x^{2}-\frac {1}{48} x^{4}+\operatorname {O}\left (x^{6}\right )\right )}{x}+x^{2} \left (\frac {1}{3}+\frac {1}{15} x^{2}+\operatorname {O}\left (x^{4}\right )\right ) \]

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} \\ {} & {} & \cos \left (x \right ) \left (\frac {d}{d x}y \left (x \right )\right )+\frac {y \left (x \right )}{x}=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 )=\frac {-\frac {y \left (x \right )}{x}+x}{\cos \left (x \right )} \\ \bullet & {} & \textrm {Collect w.r.t.}\hspace {3pt} y \left (x \right )\hspace {3pt}\textrm {and simplify}\hspace {3pt} \\ {} & {} & \frac {d}{d x}y \left (x \right )=-\frac {y \left (x \right )}{\cos \left (x \right ) x}+\frac {x}{\cos \left (x \right )} \\ \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 {y \left (x \right )}{\cos \left (x \right ) x}=\frac {x}{\cos \left (x \right )} \\ \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 {y \left (x \right )}{\cos \left (x \right ) x}\right )=\frac {\mu \left (x \right ) x}{\cos \left (x \right )} \\ \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 {y \left (x \right )}{\cos \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 )}{\cos \left (x \right ) x} \\ \bullet & {} & \textrm {Solve to find the integrating factor}\hspace {3pt} \\ {} & {} & \mu \left (x \right )={\mathrm e}^{\int \frac {1}{\cos \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 \frac {\mu \left (x \right ) x}{\cos \left (x \right )}d x +\mathit {C1} \\ \bullet & {} & \textrm {Evaluate the integral on the lhs}\hspace {3pt} \\ {} & {} & y \left (x \right ) \mu \left (x \right )=\int \frac {\mu \left (x \right ) x}{\cos \left (x \right )}d x +\mathit {C1} \\ \bullet & {} & \textrm {Solve for}\hspace {3pt} y \left (x \right ) \\ {} & {} & y \left (x \right )=\frac {\int \frac {\mu \left (x \right ) x}{\cos \left (x \right )}d x +\mathit {C1}}{\mu \left (x \right )} \\ \bullet & {} & \textrm {Substitute}\hspace {3pt} \mu \left (x \right )={\mathrm e}^{\int \frac {1}{\cos \left (x \right ) x}d x} \\ {} & {} & y \left (x \right )=\frac {\int \frac {{\mathrm e}^{\int \frac {1}{\cos \left (x \right ) x}d x} x}{\cos \left (x \right )}d x +\mathit {C1}}{{\mathrm e}^{\int \frac {1}{\cos \left (x \right ) x}d x}} \\ \bullet & {} & \textrm {Simplify}\hspace {3pt} \\ {} & {} & y \left (x \right )=\left (\int x \,{\mathrm e}^{\int \frac {\sec \left (x \right )}{x}d x} \sec \left (x \right )d x +\mathit {C1} \right ) {\mathrm e}^{-\int \frac {\sec \left (x \right )}{x}d x} \end {array} \]
Mathematica
ode=Cos[x]*D[y[x],x]+y[x]/x==x; 
AsymptoticDSolveValue[ode,y[x],{x,0,5}]
 

Not solved

Sympy
from sympy import * 
x = symbols("x") 
y = Function("y") 
ode = Eq(-x + cos(x)*Derivative(y(x), x) + y(x)/x,0) 
ics = {} 
dsolve(ode,func=y(x),ics=ics,hint="1st_power_series",x0=0,n=6)
 
ValueError : ODE -x + cos(x)*Derivative(y(x), x) + y(x)/x does not match hint 1st_power_series