I just came across a way that the amazing mathematician Ramanujan developed of assigning a value to certain divergent series. I found it interesting, so I want to share a short summary of it here. It is based on the Euler–Maclaurin formula

\begin{align*} \sum_{k=\alpha}^\beta f(k) &= \int_\alpha^\beta f(t)\,dt + \frac{f(\alpha)+f(\beta)}{2} \\ &\quad+ \sum_{k=1}^n \frac{B_{2k}}{(2k)!}\Bigl(f^{(2k-1)}(\beta)-f^{(2k-1)}(\alpha)\Bigr) + R_n \end{align*}where $B_{2k}$ denotes the $(2k)$th Bernoulli number, $f$ has $2n+1$ continuous derivatives on $[\alpha,\beta]$ with $\alpha$, $\beta$, and $n\geq0$ being integers, and $R_n$ is the remainder term given by

\[ R_n = \int_\alpha^\beta \frac{B_{2n+1}(t-\lfloor t\rfloor)}{(2n+1)!}f^{(2n+1)}(t)\,dt . \]Taking $\alpha=0$, $\beta=x$ and letting $n$ tend to infinity we have (assuming that $R_n$ tends to zero)

\[ \sum_{k=0}^x f(k) \sim \int_a^x f(t)\,dt + \frac{f(x)}{2} + \sum_{k=1}^\infty\frac{B_{2k}}{(2k)!}f^{(2k-1)}(x) + C(a) \quad\text{as $x\to\infty$} \]where $C(a)$ is the constant

\[ C(a) = \int_0^a f(t)\,dt + \frac{f(0)}{2}-\sum_{k=1}^\infty\frac{B_{2k}}{(2k)!}f^{(2k-1)}(0) . \]Ramanujan considered $C(0)$ the “constant” of the series $\sum f(k)$ and claimed that he considered it “like the centre of gravity of a body”.

For example, letting $f(k)=1$ one sees that the series $\sum f(k)$ diverges; however, one has $C(0)=-1/2$ (note that all the derivatives of $f$ vanish in this case). Also, letting $f(k)=k$ one again has that $\sum f(k)$ diverges but in this case $C(0)=-B_2/2!=-1/12$ as all derivatives of $f$ vanish except the first.

How about a nonconverging alternating series like Grandi’s series? Here we have $f(k)=\cos(\pi k)$ and in this case $C(0)=1/2$ as $f^{(2k-1)}(0)=0$ for all $k\geq1$ since $f^{(2k-1)}(t)=(-1)^k\pi^{2k-1}\sin(\pi t)$.

Conversely, consider a series that converges, e.g., when you take $f(k)=2^{-k}$. In this case one has $C(0)=1/2+\sum_{k=1}^\infty B_{2k}(-\ln2)^{2k-1}/(2k)!\approx0.557$—which doesn’t give the correct value of $\sum f(k)=2$. What went wrong in this case? This is the reason for introducing the parameter $a$ above—for convergent series one needs to take $a\to\infty$ to achieve consistency. In this case, one computes that $\int_0^\infty2^{-t}\,dt=1/\ln2\approx1.443$ and one arrives at the happy result that $\lim_{a\to\infty}C(a)=\sum f(k)=2$.

I’m not personally aware of any applications of this but it was too cool not to share. I found this in Chapter 6 of *Ramanujan’s Notebooks, Part 1* by Bruce Berndt.