Solving Differential Equations with Taylor Series

Many differential equations don’t have solutions which can be expressed in terms of finite combinations of familiar functions. However, we can often solve for the Taylor series of the solution.

For example, to solve the differential equation $y’^\prime+xy’+xy=e^x$, we can substitute the Taylor series $y=\sum_{n=0}^\infty a_n x^n$ and $e^x = \sum_{n=0}^\infty \frac{x^n}{n!}$ and solve for the coefficients $a_n$. Differentiating, we have $y’=\sum_{n=1}^\infty na_n x^{n-1}$ and $y’^\prime = \sum_{n=2}^\infty n(n-1) a_n x^{n-2}$. Substituting the derivatives in the differential equation, re-indexing so that all exponents are $n$, expressing all sums with the same starting index, and combining terms under a single sum, we condense the expression into a single polynomial.

$\begin{align*} e^x &= y'' + xy' + xy \\ \sum_{n=0}^\infty \frac{x^n}{n!} &= \sum_{n=2}^\infty n(n−1)a_n x^{n−2} + x\sum_{n=1}^\infty na_n x^{n−1} + x \sum_{n=0}^\infty a_n x^n \\ \sum_{n=0}^\infty \frac{x^n}{n!} &= \sum_{n=2}^\infty n(n−1)a_n x^{n−2} + \sum_{n=1}^\infty na_n x^{n} + \sum_{n=0}^\infty a_nx^{n+1} \\ \sum_{n=0}^\infty \frac{x^n}{n!} &= \sum_{n=0}^\infty (n+2)(n+1)a_{n+2} x^{n} + \sum_{n=1}^\infty na_n x^{n} + \sum_{n=1}^\infty a_{n−1}x^{n} \\ 1+\sum_{n=1}^\infty \frac{x^n}{n!} &= 2a_2 + \sum_{n=1}^\infty (n+2)(n+1)a_{n+2} x^{n} + \sum_{n=1}^\infty na_n x^{n} + \sum_{n=1}^\infty a_{n−1}x^{n} \\ 0 &= 2a_2−1 + \sum_{n=1}^\infty \left[ (n+2)(n+1)a_{n+2} + na_n + a_{n−1} − \frac{1}{n!} \right] x^{n} \end{align*}$


For the expression to evaluate to $0$, we must have $2a_2-1=0$ and $(n+2)(n+1)a_{n+2} + na_n + a_{n-1} - \frac{1}{n!} = 0$ for $n > 1$. So, we can choose $a_0$ and $a_1$ to be our constants $a_0 = C_1$ and $a_1 = C_2$, set $a_2 = \frac{1}{2}$, and express all other coefficients $a_n$ for $n>3$ in terms of the constants $a_0 = C_1$ and $a_1 = C_2$ through a recurrence:

$\begin{align*} 0 &= (n+2)(n+1)a_{n+2}+na_n+a_{n−1} − \frac{1}{n!} \hspace{1.3cm} ( n \geq 1) \\ a_{n+2} &= \frac{1}{(n+2)(n+1)} \left( \frac{1}{n!}−na_n−a_{n−1} \right) \hspace{1.8cm} (n \geq 1) \\ a_{n} &= \frac{1}{n(n−1)} \left( \frac{1}{(n−2)!} − (n−2)a_{n−2}−a_{n−3} \right) \hspace{.48cm} ( n \geq 3) \end{align*}$


Thus, our solution is given by $y=\sum_{n=0}^\infty a_n x^n$ where $a_0=C_1$, $a_1=C_2$, $a_2=\frac{1}{2}$, and

$\begin{align*} a_n = \frac{1}{n(n−1)} \left( \frac{1}{(n−2)!} − (n−2)a_{n−2}−a_{n−3} \right) \hspace{.5cm} (n \geq 3). \end{align*}$


As another example, we will solve the differential equation $y’’^\prime=y’y$ using the same process. We write the solution as the Taylor series $y=\sum_{n=0}^\infty a_n x^n$, substitute its derivatives into the equation, and simplify.

$\begin{align*} y''' &= y'y \\ \sum_{n=3}^\infty n(n−1)(n−2)a_n x^{n−3} &= \left( \sum_{n=1}^\infty na_nx^{n−1} \right) \left( \sum_{n=0}^\infty a_nx^n \right) \\ \sum_{n=3}^\infty n(n−1)(n−2)a_n x^{n−3} &= \left( \sum_{k=0}^\infty (k+1) a_{k+1} x^{k} \right) \left( \sum_{m=0}^\infty a_mx^m \right) \\ \sum_{n=3}^\infty n(n−1)(n−2)a_n x^{n−3} &= \sum_{k,m=0}^\infty (k+1) a_{k+1} a_m x^{k+m} \\ \sum_{n=0}^\infty (n+3)(n+2)(n+1)a_{n+3} x^{n} &= \sum_{n=0}^\infty \left[ \sum_{k=0}^n (k+1) a_{k+1} a_{n−k} \right] x^n \end{align*}$


We can choose $a_0 = C_1$, $a_1 = C_2$, and $a_2 = C_3$ as our constants and express all other coefficients $a_n$ for $n \geq 3$ in terms of these constants through a recurrence:

$\begin{align*} (n+3)(n+2)(n+1)a_{n+3} &= \sum_{k=0}^n (k+1)a_{k+1}a_{n−k} \hspace{1.4cm} (n \geq 0) \\ a_{n+3} &= \frac{ \sum_{k=0}^n (k+1)a_{k+1}a_{n−k} }{(n+3)(n+2)(n+1)} \hspace{.9cm} (n \geq 0) \\ a_{n} &= \frac{ \sum_{k=0}^{n−3} (k+1)a_{k+1}a_{n−3−k} }{n(n−1)(n−2)} \hspace{.5cm} (n \geq 3) \end{align*}$


Thus, our solution is given by $y=\sum_{n=0}^\infty a_n x^n$ where $a_0=C_1$, $a_1=C_2$, $a_2 = C_3$, and

$\begin{align*} a_n = \frac{\sum_{k=0}^{n−3} (k+1)a_{k+1}a_{n−3−k} }{n(n−1)(n−2)} \hspace{.5cm} (n \geq 3). \end{align*}$



Practice Problems


Use Taylor series to solve the following differential equations. (You can view the solution by clicking on the problem.)

$\begin{align*} 1) \hspace{.5cm} y'''+x^2y=1 \end{align*}$
Solution:
$\begin{align*} & a_0 = C_1, \, a_1=C_2, \, a_2 = C_3, \, a_3 = \frac{1}{6} , \, a_4=0 \\ & a_n = −\frac{a_{n−5} }{n(n−1)(n−2)} \hspace{.5cm} (n \geq 5) \end{align*}$


$\begin{align*} 2) \hspace{.5cm} y''+xy=e^x \end{align*}$
Solution:
$\begin{align*} & a_0 = C_1, \, a_1=C_2, \, a_2 = \frac{1}{2} \\ & a_n = \frac{1}{n(n−1)} \left[ \frac{1}{(n−2)!} − a_{n−3} \right] \hspace{.5cm} (n \geq 3) \end{align*}$


$\begin{align*} 3) \hspace{.5cm} y'''=\frac{y'}{1-x} \end{align*}$
Solution:
$\begin{align*} & a_0 = C_1, \, a_1=C_2, \, a_2 = C_3 \\ & a_n = \frac{ \sum_{k=0}^{n−3} (k+1)a_{k+1} }{n(n−1)(n−2)} \hspace{.5cm} (n \geq 3) \end{align*}$


$\begin{align*} 1) \hspace{.5cm} y'''=xy' \ln(1+x) \end{align*}$
Solution:
$\begin{align*} & a_0 = C_1, \, a_1=C_2, \, a_2 = C_3, \, a_3=0, \, a_4=0 \\ & a_n = \frac{ \sum_{k=1}^{n−4} \frac{(−1)^{n−k}}{n−k−3} a_k }{n(n−1)(n−2)} \hspace{.5cm} (n \geq 5) \end{align*}$


Leave a Comment