# Solving $y'(x)-2xy(x)=2x$ by using power series

I have a first order differential equation:

$y'(x)-2xy(x)=2x$

I want to construct a function that satisfies this equation by using power series.

General approach:

$y(x)=\sum_0^\infty a_nx^n$

Differentiate once:

$y'(x)=\sum_1^\infty a_nnx^{n-1}$

Now I plug in the series into my diff. equation:

$\sum_1^\infty a_nnx^{n-1}-2x\sum_0^\infty a_nx^n=2x$

$\iff \sum_0^\infty a_{n+1}(n+1)x^n-2x\sum_0^\infty a_nx^n=2x$

$\iff \sum_0^\infty [a_{n+1}(n+1)x^n-2xa_nx^n]=2x$

$\iff \sum_0^\infty [a_{n+1}(n+1)-2xa_n]x^n=2x$

Now I can equate the coefficients:

$a_{n+1}(n+1)-2xa_n=2x$

I am stuck here. I don't really understand why equating the coefficients works in the first place. Whats the idea behind doing this. I don't want to blindly follow some rules so maybe someone can explain it to me. Do I just solve for $a_{n+1}$ now?

Edit:

Additional calculation in response to LutzL:

$\sum_1^\infty a_nnx^{n-1}-\sum_0^\infty 2a_nx^{n+1}=2x$

$\iff \sum_0^\infty a_{n+1}(n+1)x^n-\sum_1^\infty 2a_{n-1}x^n=2x$

$\iff \sum_1^\infty a_{n+1}(n+1)x^n+a_1-\sum_1^\infty 2a_{n-1}x^n=2x$

$\iff \sum_1^\infty [a_{n+1}(n+1)-2a_{n-1}]x^n=2x-a_1$

So how do I deal with the x on the other side now? Can I just equate the coefficients like this:

$a_{n+1}(n+1)-2a_{n-1}=2x-a_1$?

• Go one step further: $$\sum_{n=2}^∞[a_{n+1}(n+1)−2a_{n−1}]x^n=2x−(2a_2-2a_0)x-a_1$$ to get $a_1=0$, $a_2=a_0+1$ and $a_{n+1}=2a_{n-1}/(n+1)$ for all further degrees $n=2,3,…$. – LutzL Apr 12 '15 at 11:19
• Nice! Will try that. Thank you very much for your help. – qmd Apr 12 '15 at 11:27
• I am really sorry but I just can't understand how you are getting $a_1=0$. Are you just plugging in n=1,2,3.... ? Could you maybe show me what I am comparing these coefficients with. – qmd Apr 12 '15 at 14:21
• Because $a_1$ is the only constant term. As said in the answer, you have to balance the coefficients of the same powers of $x$ on both sides of the equation. – LutzL Apr 12 '15 at 14:25

it may be easier to see what is going on if you $\bf don't$ use the sigma notation for the sums. here is how finding solution by series works. you assume the solution is of the form $$y = a_0 + a_1x + a_2 x^2 + a_3x^3 +\cdots\\y' = a_1 + 2a_2 x + 3a_3x^2 +\cdots$$ and sub in the differential equation $y' - 2xy = 2x.$ that gives $$a_1 + 2a_2 x + 3a_3x^2 +\cdots -2x\left(a_0 + a_1x + a_2 x^2 + a_3x^3 +\cdots\right) = 2x \to \\ a_1 + (2a_2 - 2a_0)x + (3a_3 - 2a_1)x^2 + (4a_4-2a_2)x^3+ \cdots = 0 + 2x + 0x^2 + 0x^3 + \cdots \tag 1$$

we make $(1)$ hold true by picking the right values for the coefficients $a_0, a_1, a_2, \cdots$

equating the constant term, we find \begin{align} 1:\,a_1 &= 0\\ x:\,2a_2 - 2a_0 &= 2 \to a_2 = 1 + a_0\\ x^2:\,3a_3 - 2a_1 &= 0 \to a_3 = 0\\ x^3:\, 4a_4 - 2a_2 &= 0 \to a_4 = \frac12a_2 = \frac12 (1+a_0)\\ x^4:\,5a_5 - 2a_3 &= 0\to a_5 = 0 \\ x^5:\, 6a_6 - 2a_4 &\to a_6 = \frac13a_2 = \frac1{3!}(1+a_0)\\ \vdots\\ a_{2n} &=\frac 1{n!}(1+a_0), a_{2n+1} = 0. \end{align}

now collecting all these together, we have \begin{align}y &= a_0 + \left(1 + a_0\right)x^2 + \frac 1{2!}\left(1 + a_0\ \right)x^4 +\cdots\\ &=x^2 + \frac 1{2!} x^4 + \cdots + a_0\left(1 + x^2 + \frac1{2!}x^4 + \frac1{3!} x^6 + \cdots\right)\\ &=e^{x^2}-1 + a_0e^{x^2}\end{align}

in particular, you see that if we set $a_0 = -1$ we find that $y = -1$ is a particular solution.

therefore the general solution is $$y = e^{x^2}-1 + a_0e^{x^2}$$ where $a_0$ is arbitrary.

• Thank you! That helped a lot. – qmd Apr 12 '15 at 12:54
• Just a quick question about equating the coefficients. I still don't quite understand what to equate them with. How are you getting $a_1=0$ and where did the $2x$ on the other side of the equation go. – qmd Apr 12 '15 at 13:52
• suppose someone tells you that $x^2 + 3x + 2 = ax^2 + bx + c$ needs to be true for all $x.$ how will you find out what $a, b, c$ must be? – abel Apr 12 '15 at 14:44
• Then I would just equate the coefficients of x. $1x^2=ax^2$ and so on. However let's take this equation: $\sum_2^\infty [a_{n+1}(n+1)−2a_{n−1}]x^n=2x−(2a_2−2a_0)x−a_1]$ If I want to find the coefficients of $x^1$ then on the right I get $2-2a_2-2a_0$ How would I find them on the left? – qmd Apr 12 '15 at 15:06
• @Rzeta, you are welcome. i teach for a living and so i have lots of patience. no it does not. making $y = 0$ at $x = 0$ will force $a_0 = 0.$ – abel Apr 12 '15 at 15:34

You have to compare coefficients of like powers, there should be no variable $x$ remaining in the resulting equations. For that one has invented a technique called "index shift", that you actually correctly employed in the case of the derivative series. In the other part, $$x\sum_{k=0}^\infty a_kx^k=\sum_{k=0}^\infty a_kx^{k+1}=\sum_{n=1}^\infty a_{n-1}x^n$$ And using the Kronecker delta $$2x=\sum_{n=0}^\infty (2\delta_{n,1})x^n$$ where $$δ_{n,a}=\begin{cases}1&n=a\\0&n\ne a\end{cases}$$

• Thanks. I don't know what the kronecker delta is. If I shift the index as you suggested then I have two series starting at $n=1$. However, in one series I have $x^n$ and in the other series (y'(x)) I have a $x^{n-1}$. How will I be able to combine them and factor out a $x^n$ without there being a $x^{-1}$ left? – qmd Apr 12 '15 at 10:53
• I am going to add the calculation I did in my question. – qmd Apr 12 '15 at 11:01
• You can treat the cases $n=0$ and perhaps also $n=1$ separately, or introduce the artificial coefficient $a_{-1}=0$. – LutzL Apr 12 '15 at 11:12
• I have added a calculation in my opening post. Is the goal to get rid of all the x's? Even the 2x on the other side? – qmd Apr 12 '15 at 11:13
• Yes. Coefficients are constant and thus independent of the variable $x$. You compare terms of the same degree, the degree includes contributions of all factors. – LutzL Apr 12 '15 at 11:15