Integral with summations inside

I am a big fan of blackpenredpen. This guy posts videos on Youtube about calculus and more. Some days ago I received a notification and this is what the thumbnail contained:

$\large&space;\int&space;\left&space;(&space;\frac{1}{x-1}&space;+\frac{\sum_{k=0}^{2018}(k+1)x^k}{\sum_{k=0}^{2019}x^k}\right&space;)\mathrm{d}x$

I thought this was just insane and I had no idea how to start, but I gave it a try anyway. You can click here for his video!

Although you might be tempted, you can’t simplify x^k because that’s a sum. Instead, let’s expand this to see if there’s any pattern. First though, let’s take the integral of the first term, which is way easier (we’re applying linearity): we know that the antiderivative of 1/x is ln(x), therefore the integral of 1/(x-1) will be ln(x-1). At this point we can write:

$\dpi{120}&space;\int&space;\frac{1}{x-1}&space;\mathrm{d}x&space;+\int&space;\frac{\sum_{k=0}^{2018}(k+1)x^k}{\sum_{k=0}^{2019}x^k}\mathrm{d}x$ $\dpi{120}&space;\ln(x-1)&space;+\int&space;\frac{\sum_{k=0}^{2018}(k+1)x^k}{\sum_{k=0}^{2019}x^k}\mathrm{d}x$

Now, let’s analyse each sum individually:

$\large&space;\sum_{k=0}^{2018}(k+1)x^k$

This is simply

$(0+1)x^0+(1+1)x^1+(2+1)x^2+(3+1)x^3+...+(2018+1)x^{2018}$ $1+2x+3x^2+4x^3+...+2019x^{2018}$

This looks a lot like a sum of derivatives, to be more specific the sum of the first derivative of x^k: the derivative of x is 1, of x² is 2x, of x³ is 3x² and so on. But there’s nothing we can do right now. Let’s give a look at the other sum:

$\large&space;\sum_{k=0}^{2019}x^k$

We get

$\dpi{120}&space;x^0+x^1+x^2+x^3+x^4+...+x^{2019}$ $\dpi{120}&space;1+x+x^2+x^3+x^4+...+x^{2019}$

Here instead we have the sum of the function x^k, and what’s cool is that this sum is actually the derivative of the first sum, as we saw before! This means we can perform a u-substitution by letting u be equal to this sum so that its derivative will cancel out with the other sum. First though, I would like to write the integral in a different way:

$\large&space;\int&space;\sum_{k=0}^{2018}(k+1)x^k\cdot&space;\frac{1}{\sum_{k=0}^{2019}x^k}\,\mathrm{d}x$

This was just to make things less messy. At this point we can substitute:

$\dpi{120}&space;u=\sum_{k=0}^{2019}x^k\;\;\;\;\;\mathrm{d}u=\sum_{k=0}^{2018}(k+1)x^k\,\mathrm{d}x$

Notice

$\dpi{120}&space;\int&space;{\color{Blue}&space;\sum_{k=0}^{2018}(k+1)x^k}\cdot&space;\frac{1}{{\color{Red}&space;\sum_{k=0}^{2019}x^k}}\,{\color{Blue}&space;\mathrm{d}x}$

The part in blue is our du and the one in red is our u; this becomes

$\dpi{120}&space;\int&space;\frac{1}{u}\,&space;\mathrm{d}u$

I couldn’t believe it all reduced to this way too easy integral, and I didn’t know whether to be excited or disappointed because it thought it could not be possible, but I kept going. So, as we know, the antiderivative of this is simply ln(u), and so

$\dpi{120}&space;\ln\left&space;(&space;\sum_{k=0}^{2019}&space;x^k\right&space;)$

Let’s not forget about the first integral though! The two combined give

$\dpi{120}&space;\ln(x-1)+\ln\left&space;(&space;\sum_{k=0}^{2019}&space;x^k\right&space;)$

Now, this is a sum of two logarithms: this is one of the properties: ln(a)+ln(b)=ln(a*b), therefore

$\dpi{120}&space;\ln\left&space;(&space;(x-1)\sum_{k=0}^{2019}&space;x^k\right&space;)=\ln\left&space;(x\sum_{k=0}^{2019}&space;x^k-\sum_{k=0}^{2019}&space;x^k&space;\right&space;)$

Let’s now see what we get from each sum:

$\dpi{120}&space;x\sum_{k=0}^{2019}&space;x^k$

This is

$\dpi{120}&space;x(1+x+x^2+x^3+x^4+...+x^{2019})=x+x^2+x^3+x^4+x^5+...+x^{2020}$ $\dpi{120}&space;\sum_{k=0}^{2019}x^k$

As we saw before, this is

$\dpi{120}&space;1+x+x^2+x^3+x^4+...+x^{2019}$

Now, what happens when we subtract them? (this is what’s inside ln, so we need to solve for it):

$\dpi{120}&space;(x+x^2+x^3+x^4+x^5+...+x^{2020})-(1+x+x^2+x^3+x^4+...+x^{2019})$

You can see it better here:

$\dpi{120}&space;0+x+x^2+x^3+x^4+x^5+...+x^{2020}$ $\dpi{120}&space;-1-x-x^2-x^3-x^4-...-x^{2019}$

As you can see, each term cancels out except for the first term, -1 and the last term, +x^2020. This simplifies amazingly!

$\dpi{120}&space;\ln\left&space;(x\sum_{k=0}^{2019}&space;x^k-\sum_{k=0}^{2019}&space;x^k&space;\right&space;)=\ln(-1+x^{2020})=\ln(x^{2020}-1)$

When I checked for the answer at the end of the video, I was so happy!

Finally, we have:

$\dpi{120}&space;\int&space;\left&space;(&space;\frac{1}{x-1}&space;+\frac{\sum_{k=0}^{2018}(k+1)x^k}{\sum_{k=0}^{2019}x^k}\right&space;)\mathrm{d}x=\ln(x^{2020}-1)+C$

How satisfying is this? I just loved it!