Geometric power-series remainder (source code)

= Geometric power-series remainder
{title2=$\frac1{1-z}-\sum_{n=0}^{N}z^n=\frac{z^{N+1}}{1-z}$}

For the degree-$N$ <partial sum> $P_N(z)=1+z+\cdots+z^N$ of the <geometric series>, the finite identity $(1-z)P_N(z)=1-z^{N+1}$ gives
$$
\frac1{1-z}-P_N(z)=\frac{z^{N+1}}{1-z},\qquad z\ne1.
$$
For any fixed $0<r<1$, the <triangle inequality> then gives the uniform error bound
$$
\sup_{|z|\le r}\left|\frac1{1-z}-P_N(z)\right|
\le\frac{r^{N+1}}{1-r}.
$$
Equality is attained at the positive real point $z=r$, so this is the exact worst-case error on that closed <disk>. It also proves <uniform convergence> on each such disk, not just <pointwise convergence>.

\Image[/geometric-power-series-approximation.png]
{title=<Polynomial approximations> improve within the <radius of convergence>, but approaching its boundary can require many terms}
{description=Left: degree-$N$ <partial sums> approximate $1/(1-x)$ for $-0.95\le x\le0.95$. Right: the exact worst-case error on $|z|\le r$ for three choices of $r$. A tolerance $10^{-3}$ needs minimum degrees $10$, $87$, and $1145$ for $r=0.5$, $0.9$, and $0.99$, respectively.}

Given a positive tolerance $\varepsilon$, choosing $N$ with $r^{N+1}/(1-r)\le\varepsilon$ turns a convergence statement into a finite stopping rule. For $\varepsilon=10^{-3}$, degree ten suffices throughout $|z|\le1/2$. Nearer the boundary, $r=0.9$ requires degree $87$ and $r=0.99$ requires degree $1145$. The required degree depends on both the tolerance and the region, not just on the name of the <function>.