I would like the function $f(n,M)$, where $n$ and $M$ are integers and $n\le M$, so that $f$ satisfies the following two conditions: (1) $\sum_{n=0}^M (-1)^n f(n,M) = \tfrac{1}{2}$ (2) $f(n,M) \approx 1$ whenever $n\ll M$ The function is needed as a summation mollifier to ensure a piecewise function is continuous (each region of the piecewise function is a series expansion). The function $f(n,M) = e^{-\frac{k n^2}{M^2}}$ is close for large $k$, but the summation is not exactly $\frac{1}{2}$ and thus the piecewise function has a discontinuity. I should also mention that $f(n,M) = 1$ for $n<M$ and $f(n,M) = 1/2$ for $n=M$ works, but I would prefer a smoother function. Below is some additional context to address Gottfried Helms's comment. I am computing a finite series approximation for $\frac{1}{1+g(x)}$ for smooth $g$ where $0<g(x)<1$ for $x<1$ and $1<g(x)$ for $x>1$. For $x<1$, I would like to expand $\frac{1}{1+g(x)} = \sum_{n=0}^\infty (-1)^n g(x)^n$. For $x>1$, I would like to expand $\frac{1}{1+g(x)} = \frac{g(x)^{-1}} {1+g(x)^{-1}} = g(x)^{-1} \sum_{n=0}^\infty (-1)^n g(x)^{-n}$. Terms for both series converge to the alternating sequence $\sum_{n=0}^\infty (-1)^n$ as $x\rightarrow 1$. I want to introduce a mollifier $f(n,M)$ so that the $M$-term approximation to the function is continuous: $\frac{1}{1+g(x)} \approx \begin{cases} \hphantom{g(x)^{-1}}\sum_{n=0}^M (-1)^n f(n,M) g(x)^n & x<1 \\ g(x)^{-1} \sum_{n=0}^M (-1)^n f(n,M) g(x)^{-n} & x \ge 1 \end{cases}$. The two requirements for $f(n,M)$ are intended to ensure that (1) the approximation is continuous at $x=1$ where $\frac{1}{1+g(1)} = 1/2$ and (2) the approximation is accurate far from the point $x=1$ where $g(x)$ is not near 1. I am not very knowledgeable about divergent series or series acceleration, so I may be missing something easier. The reason I am leaning toward modifying the terms is that I would like to preserve the polynomial structure of the approximation in $g(x)$ or $g(x)^{-1}$.