2.4.2 Problem 2
Internal
problem
ID
[10347]
Book
:
First
order
enumerated
odes
Section
:
section
4.
First
order
odes
solved
using
series
method
Problem
number
:
2
Date
solved
:
Thursday, November 27, 2025 at 10:34:52 AM
CAS
classification
:
[[_linear, `class A`]]
\begin{align*}
y^{\prime }+y&=\sin \left (x \right ) \\
\end{align*}
Series expansion around
\(x=0\) .
Solving ode using Taylor series method. This gives review on how the Taylor series method
works for solving first order ode. Let
\[ y^{\prime }=f\left ( x,y\right ) \]
Where
\(f\left ( x,y\right ) \) is analytic at expansion point
\(x_{0}\) . We can
always shift to
\(x_{0}=0\) if
\(x_{0}\) is not zero. So from now we assume
\(x_{0}=0\,\) . Assume also that
\(y\left ( x_{0}\right ) =y_{0}\) . Using Taylor
series
\begin{align*} y\left ( x\right ) & =y\left ( x_{0}\right ) +\left ( x-x_{0}\right ) y^{\prime }\left ( x_{0}\right ) +\frac {\left ( x-x_{0}\right ) ^{2}}{2}y^{\prime \prime }\left ( x_{0}\right ) +\frac {\left ( x-x_{0}\right ) ^{3}}{3!}y^{\prime \prime }\left ( x_{0}\right ) +\cdots \\ & =y_{0}+xf+\frac {x^{2}}{2}\left . \frac {df}{dx}\right \vert _{x_{0},y_{0}}+\frac {x^{3}}{3!}\left . \frac {d^{2}f}{dx^{2}}\right \vert _{x_{0},y_{0}}+\cdots \\ & =y_{0}+\sum _{n=0}^{\infty }\frac {x^{n+1}}{\left ( n+1\right ) !}\left . \frac {d^{n}f}{dx^{n}}\right \vert _{x_{0},y_{0}}\end{align*}
But
\begin{align} \frac {df}{dx} & =\frac {\partial f}{\partial x}+\frac {\partial f}{\partial y}f\tag {1}\\ \frac {d^{2}f}{dx^{2}} & =\frac {d}{dx}\left ( \frac {df}{dx}\right ) \nonumber \\ & =\frac {\partial }{\partial x}\left ( \frac {df}{dx}\right ) +\frac {\partial }{\partial y}\left ( \frac {df}{dx}\right ) f\tag {2}\\ \frac {d^{3}f}{dx^{3}} & =\frac {d}{dx}\left ( \frac {d^{2}f}{dx^{2}}\right ) \nonumber \\ & =\frac {\partial }{\partial x}\left ( \frac {d^{2}f}{dx^{2}}\right ) +\left ( \frac {\partial }{\partial y}\frac {d^{2}f}{dx^{2}}\right ) f\tag {3}\\ & \vdots \nonumber \end{align}
And so on. Hence if we name \(F_{0}=f\left ( x,y\right ) \) then the above can be written as
\begin{align} F_{0} & =f\left ( x,y\right ) \tag {4}\\ F_{n} & =\frac {d}{dx}\left ( F_{n-1}\right ) \nonumber \\ & =\frac {\partial }{\partial x}F_{n-1}+\left ( \frac {\partial F_{n-1}}{\partial y}\right ) F_{0} \tag {5}\end{align}
For example, for \(n=1\,\) we see that
\begin{align*} F_{1} & =\frac {d}{dx}\left ( F_{0}\right ) \\ & =\frac {\partial }{\partial x}F_{0}+\left ( \frac {\partial F_{0}}{\partial y}\right ) F_{0}\\ & =\frac {\partial f}{\partial x}+\frac {\partial f}{\partial y}f \end{align*}
Which is (1). And when \(n=2\)
\begin{align*} F_{2} & =\frac {d}{dx}\left ( F_{1}\right ) \\ & =\frac {\partial }{\partial x}F_{1}+\left ( \frac {\partial F_{1}}{\partial y}\right ) F_{0}\\ & =\frac {\partial }{\partial x}\left ( \frac {\partial f}{\partial x}+\frac {\partial f}{\partial y}f\right ) +\frac {\partial }{\partial y}\left ( \frac {\partial f}{\partial x}+\frac {\partial f}{\partial y}f\right ) f\\ & =\frac {\partial }{\partial x}\left ( \frac {df}{dx}\right ) +\frac {\partial }{\partial y}\left ( \frac {df}{dx}\right ) f \end{align*}
Which is (2) and so on. Therefore (4,5) can be used from now on along with
\begin{equation} y\left ( x\right ) =y_{0}+\sum _{n=0}^{\infty }\frac {x^{n+1}}{\left ( n+1\right ) !}\left . F_{n}\right \vert _{x_{0},y_{0}} \tag {6}\end{equation}
Hence
\begin{align*} F_0 &= -y+\sin \left (x \right )\\ F_1 &= \frac {d F_0}{dx} \\ &= \frac {\partial F_0}{\partial x}+ \frac {\partial F_0}{\partial y} F_0 \\ &= y-\sin \left (x \right )+\cos \left (x \right )\\ F_2 &= \frac {d F_1}{dx} \\ &= \frac {\partial F_1}{\partial x}+ \frac {\partial F_1}{\partial y} F_1 \\ &= -y-\cos \left (x \right )\\ F_3 &= \frac {d F_2}{dx} \\ &= \frac {\partial F_2}{\partial x}+ \frac {\partial F_2}{\partial y} F_2 \\ &= y\\ F_4 &= \frac {d F_3}{dx} \\ &= \frac {\partial F_3}{\partial x}+ \frac {\partial F_3}{\partial y} F_3 \\ &= -y+\sin \left (x \right ) \end{align*}
And so on. Evaluating all the above at initial conditions \(x \left (0\right ) = 0\) and \(y \left (0\right ) = y \left (0\right )\) gives
\begin{align*} F_0 &= -y \left (0\right )\\ F_1 &= 1+y \left (0\right )\\ F_2 &= -y \left (0\right )-1\\ F_3 &= y \left (0\right )\\ F_4 &= -y \left (0\right ) \end{align*}
Substituting all the above in (6) and simplifying gives the solution as
\[
y = \left (1-x +\frac {1}{2} x^{2}-\frac {1}{6} x^{3}+\frac {1}{24} x^{4}-\frac {1}{120} x^{5}\right ) y \left (0\right )+\frac {x^{2}}{2}-\frac {x^{3}}{6}+O\left (x^{6}\right )
\]
Since
\(x = 0\) is also
an ordinary point, then standard power series can also be used. Writing the ODE as
\begin{align*} y^{\prime } + q(x)y &= p(x) \\ y^{\prime }+y &= \sin \left (x \right ) \end{align*}
Where
\begin{align*} q(x) &= 1\\ p(x) &= \sin \left (x \right ) \end{align*}
Next, the type of the expansion point \(x = 0\) is determined. This point can be an ordinary point, a
regular singular point (also called removable singularity), or irregular singular point (also called
non-removable singularity or essential singularity). When \(x = 0\) is an ordinary point, then the
standard power series is used. If the point is a regular singular point, Frobenius series is
used instead. Irregular singular point requires more advanced methods (asymptotic
methods) and is not supported now. Hopefully this will be added in the future. \(x = 0\) is called an
ordinary point \(q(x)\) has a Taylor series expansion around the point \(x = 0\) . \(x = 0\) is called a regular
singular point if \(q(x)\) is not not analytic at \(x = 0\) but \(x q(x)\) has Taylor series expansion. And finally, \(x = 0\) is
an irregular singular point if the point is not ordinary and not regular singular. This
is the most complicated case. Now the expansion point \(x = 0\) is checked to see if it is an
ordinary point or not. Let the solution be represented as power series of the form
\[ y = \moverset {\infty }{\munderset {n =0}{\sum }}a_{n} x^{n} \]
Then
\begin{align*} y^{\prime } &= \moverset {\infty }{\munderset {n =1}{\sum }}n a_{n} x^{n -1} \end{align*}
Substituting the above back into the ode gives
\begin{align*} \left (\moverset {\infty }{\munderset {n =1}{\sum }}n a_{n} x^{n -1}\right )+\left (\moverset {\infty }{\munderset {n =0}{\sum }}a_{n} x^{n}\right ) = \sin \left (x \right )\tag {1} \end{align*}
Expanding \(\sin \left (x \right )\) as Taylor series around \(x=0\) and keeping only the first \(6\) terms gives
\begin{align*} \sin \left (x \right ) &= x -\frac {1}{6} x^{3}+\frac {1}{120} x^{5} + \dots \\ &= x -\frac {1}{6} x^{3}+\frac {1}{120} x^{5} \end{align*}
Which simplifies to
\begin{equation}
\tag{2} \left (\moverset {\infty }{\munderset {n =1}{\sum }}n a_{n} x^{n -1}\right )+\left (\moverset {\infty }{\munderset {n =0}{\sum }}a_{n} x^{n}\right ) = x -\frac {1}{6} x^{3}+\frac {1}{120} x^{5}
\end{equation}
The next step is to make all powers of
\(x\) be
\(n\) in each summation term.
Going over each summation term above with power of
\(x\) in it which is not already
\(x^{n}\) and
adjusting the power and the corresponding index gives
\begin{align*}
\moverset {\infty }{\munderset {n =1}{\sum }}n a_{n} x^{n -1} &= \moverset {\infty }{\munderset {n =0}{\sum }}\left (n +1\right ) a_{n +1} x^{n} \\
\end{align*}
Substituting all the above in Eq
(2) gives the following equation where now all powers of
\(x\) are the same and equal to
\(n\) .
\begin{equation}
\tag{3} \left (\moverset {\infty }{\munderset {n =0}{\sum }}\left (n +1\right ) a_{n +1} x^{n}\right )+\left (\moverset {\infty }{\munderset {n =0}{\sum }}a_{n} x^{n}\right ) = x -\frac {1}{6} x^{3}+\frac {1}{120} x^{5}
\end{equation}
For
\(0\le n\) , the recurrence equation is
\begin{equation}
\tag{4} \left (\left (n +1\right ) a_{n +1}+a_{n}\right ) x^{n} = x -\frac {1}{6} x^{3}+\frac {1}{120} x^{5}
\end{equation}
For
\(n = 0\) the recurrence equation gives
\begin{align*}
\left (a_{1}+a_{0}\right ) 1&=0 \\
a_{1}+a_{0} &= 0 \\
\end{align*}
Which after
substituting the earlier terms found becomes
\[
a_{1} = -a_{0}
\]
For
\(n = 1\) the recurrence equation gives
\begin{align*}
\left (2 a_{2}+a_{1}\right ) x&=x \\
2 a_{2}+a_{1} &= 1 \\
\end{align*}
Which after
substituting the earlier terms found becomes
\[
a_{2} = \frac {1}{2}+\frac {a_{0}}{2}
\]
For
\(n = 2\) the recurrence equation gives
\begin{align*}
\left (3 a_{3}+a_{2}\right ) x^{2}&=0 \\
3 a_{3}+a_{2} &= 0 \\
\end{align*}
Which after
substituting the earlier terms found becomes
\[
a_{3} = -\frac {1}{6}-\frac {a_{0}}{6}
\]
For
\(n = 3\) the recurrence equation gives
\begin{align*}
\left (4 a_{4}+a_{3}\right ) x^{3}&=-\frac {x^{3}}{6} \\
4 a_{4}+a_{3} &= -{\frac {1}{6}} \\
\end{align*}
Which after
substituting the earlier terms found becomes
\[
a_{4} = \frac {a_{0}}{24}
\]
For
\(n = 4\) the recurrence equation gives
\begin{align*}
\left (5 a_{5}+a_{4}\right ) x^{4}&=0 \\
5 a_{5}+a_{4} &= 0 \\
\end{align*}
Which after
substituting the earlier terms found becomes
\[
a_{5} = -\frac {a_{0}}{120}
\]
For
\(n = 5\) the recurrence equation gives
\begin{align*}
\left (6 a_{6}+a_{5}\right ) x^{5}&=\frac {x^{5}}{120} \\
6 a_{6}+a_{5} &= {\frac {1}{120}} \\
\end{align*}
Which
after substituting the earlier terms found becomes
\[
a_{6} = \frac {1}{720}+\frac {a_{0}}{720}
\]
And so on. Therefore the solution is
\begin{align*} y &= \moverset {\infty }{\munderset {n =0}{\sum }}a_{n} x^{n}\\ &= a_{3} x^{3}+a_{2} x^{2}+a_{1} x +a_{0} + \dots \end{align*}
Substituting the values for \(a_{n}\) found above, the solution becomes
\[
y = a_{0}-a_{0} x +\left (\frac {1}{2}+\frac {a_{0}}{2}\right ) x^{2}+\left (-\frac {1}{6}-\frac {a_{0}}{6}\right ) x^{3}+\frac {a_{0} x^{4}}{24}-\frac {a_{0} x^{5}}{120}+\dots
\]
Collecting terms, the solution
becomes
\begin{equation}
\tag{3} y = \left (1-x +\frac {1}{2} x^{2}-\frac {1}{6} x^{3}+\frac {1}{24} x^{4}-\frac {1}{120} x^{5}\right ) a_{0}+\frac {x^{2}}{2}-\frac {x^{3}}{6}+O\left (x^{6}\right )
\end{equation}
Figure 2.87: Slope field \(y^{\prime }+y = \sin \left (x \right )\)
✓ Maple. Time used: 0.004 (sec). Leaf size: 47
Order :=6;
ode := diff ( y ( x ), x )+ y ( x ) = sin(x);
dsolve ( ode , y ( x ), type = ' series ' , x =0);
\[
y = \left (1-x +\frac {1}{2} x^{2}-\frac {1}{6} x^{3}+\frac {1}{24} x^{4}-\frac {1}{120} x^{5}\right ) y \left (0\right )+\frac {x^{2}}{2}-\frac {x^{3}}{6}+O\left (x^{6}\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} \\ {} & {} & \frac {d}{d x}y \left (x \right )+y \left (x \right )=\sin \left (x \right ) \\ \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 )=-y \left (x \right )+\sin \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 )+y \left (x \right )=\sin \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 )+y \left (x \right )\right )=\mu \left (x \right ) \sin \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 )+y \left (x \right )\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 )=\mu \left (x \right ) \\ \bullet & {} & \textrm {Solve to find the integrating factor}\hspace {3pt} \\ {} & {} & \mu \left (x \right )={\mathrm e}^{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 ) \sin \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 \mu \left (x \right ) \sin \left (x \right )d x +\mathit {C1} \\ \bullet & {} & \textrm {Solve for}\hspace {3pt} y \left (x \right ) \\ {} & {} & y \left (x \right )=\frac {\int \mu \left (x \right ) \sin \left (x \right )d x +\mathit {C1}}{\mu \left (x \right )} \\ \bullet & {} & \textrm {Substitute}\hspace {3pt} \mu \left (x \right )={\mathrm e}^{x} \\ {} & {} & y \left (x \right )=\frac {\int {\mathrm e}^{x} \sin \left (x \right )d x +\mathit {C1}}{{\mathrm e}^{x}} \\ \bullet & {} & \textrm {Evaluate the integrals on the rhs}\hspace {3pt} \\ {} & {} & y \left (x \right )=\frac {-\frac {{\mathrm e}^{x} \cos \left (x \right )}{2}+\frac {{\mathrm e}^{x} \sin \left (x \right )}{2}+\mathit {C1}}{{\mathrm e}^{x}} \\ \bullet & {} & \textrm {Simplify}\hspace {3pt} \\ {} & {} & y \left (x \right )=-\frac {\cos \left (x \right )}{2}+\frac {\sin \left (x \right )}{2}+{\mathrm e}^{-x} \mathit {C1} \end {array} \]
✓ Mathematica. Time used: 0.013 (sec). Leaf size: 54
ode = D [ y [ x ], x ]+ y [ x ]== Sin [ x ];
AsymptoticDSolveValue [ ode , y [ x ],{ x ,0,5}]
\[
y(x)\to -\frac {x^3}{6}+\frac {x^2}{2}+c_1 \left (-\frac {x^5}{120}+\frac {x^4}{24}-\frac {x^3}{6}+\frac {x^2}{2}-x+1\right )
\]
✓ Sympy. Time used: 0.181 (sec). Leaf size: 41
from sympy import *
x = symbols("x")
y = Function("y")
ode = Eq(y(x) - sin(x) + Derivative(y(x), x),0)
ics = {}
dsolve ( ode , func = y ( x ), ics = ics , hint ="1 st_power_series ", x0 =0, n =6)
\[
y{\left (x \right )} = \frac {x^{2} \left (C_{1} + 1\right )}{2} - \frac {x^{3} \left (C_{1} + 1\right )}{6} + C_{1} - C_{1} x + \frac {C_{1} x^{4}}{24} - \frac {C_{1} x^{5}}{120} + O\left (x^{6}\right )
\]