Finite geometric series

Function

context $n\in{\mathbb N}$
definition $Q_n: \mathbb C\to\mathbb C$
definition $Q_n(z):=\sum_{k=0}^n z^k $

todo: In fact

$\sum_{k=0}^n a^k\,b^{n-k} = \dfrac{1}{a-b}(a^{n+1}-b^{n+1})$

so

$\sum_{k=0}^n z^k = \dfrac{1}{1-z}(1-z^{n+1})$

i.e.

$\dfrac{1}{1-z} = \dfrac{1}{1-z\cdot{z^n}} \sum_{k=0}^n z^k$

i.e.

$z^{n+1}-1 = (z-1)\sum_{k=0}^n z^k$

Remarks

The last line can be used to show that a bunch of ugly expressions have a factor. You may extend it to

$\left(z^{n+1}-(a+1)\right)+a = (z-1)\sum_{k=0}^n z^k$

etc.

The proof of the infinitude of primes using Fermat numbers uses this.

In $\mathbb C$, the equation $\left(\frac{x}{b}\right)^n=1$ is solved by $x=b\cdot{\mathrm e}^{2\pi i\frac{k}{n}}$, so

$a^n-b^n = (a-b)\prod_{k=1}^{n-1} (a-b\cdot{\mathrm e}^{2\pi i\frac{k}{n}})$

n = 6;
Product[a - b*Exp[2 \[Pi] I*k/n], {k, 1, n}] // FullSimplify

References

Wikipedia: Geometric series, Geometric progression


Requirements

Complex number

Infinite geometric series