# Madhava's correction term

Madhava's correction term is a mathematical expression attributed to Madhava of Sangamagrama (c. 1340 – c. 1425), the founder of the Kerala school of astronomy and mathematics, that can be used to give a better approximation to the value of the mathematical constant π (pi) than the partial sum approximation obtained by truncating the Madhava–Leibniz infinite series for π. The Madhava–Leibniz infinite series for π is
    ${\frac {\pi }{4}}=1-{\frac {1}{3}}+{\frac {1}{5}}-{\frac {1}{7}}+\cdots$
Taking the partial sum of the first $n$ terms we have the following approximation to π:
    ${\frac {\pi }{4}}\approx 1-{\frac {1}{3}}+{\frac {1}{5}}-{\frac {1}{7}}+\cdots +(-1)^{n-1}{\frac {1}{2n-1}}$
Denoting the Madhava correction term by $F(n)$, we have the following better approximation to π:
    ${\frac {\pi }{4}}\approx 1-{\frac {1}{3}}+{\frac {1}{5}}-{\frac {1}{7}}+\cdots +(-1)^{n-1}{\frac {1}{2n-1}}+(-1)^{n}F(n)$
Three different expressions have been attributed to Madhava as possible values of $F(n)$, namely,
    $F_{1}(n)={\frac {1}{4n}}$
    $F_{2}(n)={\frac {n}{4n^{2}+1}}$
    $F_{3}(n)={\frac {n^{2}+1}{4n^{3}+5n}}$
In the extant writings of the mathematicians of the Kerala school there are some indications regarding how the correction terms $F_{1}(n)$ and $F_{2}(n)$ have been obtained, but there are no indications on how the expression $F_{3}(n)$ has been obtained. This has led to a lot of speculative work on how the formulas might have been derived.

## Correction terms as given in Kerala texts

The expressions for $F_{2}(n)$ and $F_{3}(n)$ are given explicitly in the Yuktibhasha, a major treatise on mathematics and astronomy authored by the Indian astronomer Jyesthadeva of the Kerala school of mathematics around 1530, but that for $F_{1}(n)$ appears there only as a step in the argument leading to the derivation of $F_{2}(n)$.
The Yuktidipika–Laghuvivrthi commentary of Tantrasangraha, a treatise written by Nilakantha Somayaji an astronomer/mathematician belonging to the Kerala school of astronomy and mathematics and completed in 1501, presents the second correction term in the following verses (Chapter 2: Verses 271–274):
English translation of the verses:
    "To the diameter multiplied by 4 alternately add and subtract in order the diameter multiplied by 4 and divided separately by the odd numbers 3, 5, etc. That odd number at which this process ends, four times the diameter should be multiplied by the next even number, halved and [then] divided by one added to that [even] number squared. The result is to be added or subtracted according as the last term was subtracted or added. This gives the circumference more accurately than would be obtained by going on with that process."
In modern notations this can be stated as follows (where $d$ is the diameter of the circle):
    Circumference $=4d-{\frac {4d}{3}}+{\frac {4d}{5}}-\cdots \pm {\frac {4d}{p}}\mp {\frac {4d\left(p+1\right)/2}{1+(p+1)^{2}}}$
If we set $p=2n-1$, the last term in the right hand side of the above equation reduces to $4dF_{2}(n)$.
The same commentary also gives the correction term $F_{3}(n)$ in the following verses (Chapter 2: Verses 295–296):
English translation of the verses:
    "A subtler method, with another correction. [Retain] the first procedure involving division of four times the diameter by the odd numbers, 3, 5, etc. [But] then add or subtract it [four times the diameter] multiplied by one added to the next even number halved and squared, and divided by one added to four times the preceding multiplier [with this] multiplied by the even number halved."
In modern notations, this can be stated as follows:
    ${\text{Circumference}}=4d-{\frac {4d}{3}}+{\frac {4d}{5}}-\cdots \pm {\frac {4d}{p}}\mp {\frac {4dm}{\left(1+4m\right)(p+1)/2}},$
where the "multiplier" m=1+((p+1)/2)$^2$.{\textstyle m=1+\left((p+1)/2\right)^{2}.} If we set $p=2n-1$, the last term in the right hand side of the above equation reduces to $4dF_{3}(n)$.

## Accuracy of the correction terms

Let
    $s_{i}=1-{\frac {1}{3}}+{\frac {1}{5}}-{\frac {1}{7}}+\cdots +(-1)^{n-1}{\frac {1}{2n-1}}+(-1)^{n}F_{i}(n)$.
Then, writing $p=2n+1$, the errors $\left|{\frac {\pi }{4}}-s_{i}(n)\right|$ have the following bounds:
    ${\begin{aligned}&{\begin{aligned}{\frac {1}{p^{3}-p}}-{\frac {1}{(p+2)^{3}-(p+2)}}&<\left|{\frac {\pi }{4}}-s_{1}(n)\right|<{\frac {1}{p^{3}-p}},\\[10mu]{\frac {4}{p^{5}+4p}}-{\frac {4}{(p+2)^{5}+4(p+2)}}&<\left|{\frac {\pi }{4}}-s_{2}(n)\right|<{\frac {4}{p^{5}+4p}},\end{aligned}}\\[20mu]&{\begin{aligned}&{\frac {36}{p^{7}+7p^{5}+28p^{3}-36p}}-{\frac {36}{(p+2)^{7}+7(p+2)^{5}+28(p+2)^{3}-36(p+2)}}\cdots \\[10mu]&{\phantom {{\frac {4}{p^{5}+4p}}-{\frac {4}{(p+2)^{5}+4(p+2)}}}}<\left|{\frac {\pi }{4}}-s_{3}(n)\right|<{\frac {36}{p^{7}+7p^{5}+28p^{3}-36p}}.\end{aligned}}\end{aligned}}$

### Numerical values of the errors in the computation of π

The errors in using these approximations in computing the value of π are
    $E(n)=\pi -4\left(1-{\frac {1}{3}}+{\frac {1}{5}}-{\frac {1}{7}}+\cdots +(-1)^{n-1}{\frac {1}{2n-1}}\right)$
    $E_{i}(n)=E(n)-4\times (-1)^{n}F_{i}(n)$
The following table gives the values of these errors for a few selected values of $n$.
Errors in using the approximations $F_{1}(n),F_{2}(n),F_{3}(n)$ to compute the value of π :
| $n$ | $E(n)$ | $E_{1}(n)$ | $E_{2}(n)$ | $E_{3}(n)$ |
| 11 | $-9.07\times 10^{-2}$ | $1.86\times 10^{-4}$ | $-1.51\times 10^{-6}$ | $2.69\times 10^{-8}$ |
| 21 | $-4.76\times 10^{-2}$ | $2.69\times 10^{-5}$ | $-6.07\times 10^{-8}$ | $3.06\times 10^{-10}$ |
| 51 | $-1.96\times 10^{-2}$ | $1.88\times 10^{-6}$ | $-7.24\times 10^{-10}$ | $6.24\times 10^{-13}$ |
| 101 | $-9.90\times 10^{-3}$ | $2.43\times 10^{-7}$ | $-2.38\times 10^{-11}$ | $5.33\times 10^{-15}$ |
| 151 | $-6.62\times 10^{-3}$ | $7.26\times 10^{-8}$ | $-3.18\times 10^{-12}$ | $\approx 1\times 10^{-16}$ |

## Continued fraction expressions for the correction terms

It has been noted that the correction terms $F_{1}(n),F_{2}(n),F_{3}(n)$ are the first three convergents of the following continued fraction expressions:
* ${\cfrac {1}{4n+{\cfrac {1}{n+{\cfrac {1}{n+\cdots }}}}}}$
* ${\cfrac {1}{4n+{\cfrac {1^{2}}{n+{\cfrac {2^{2}}{4n+{\cfrac {3^{2}}{n+{\cfrac {\cdots }{\cdots +{\cfrac {r^{2}}{n[4-3(r{\bmod {2}})]+\cdots }}}}}}}}}}}}={\cfrac {1}{4n+{\cfrac {2^{2}}{4n+{\cfrac {4^{2}}{4n+{\cfrac {6^{2}}{4n+{\cfrac {8^{2}}{4n+\cdots }}}}}}}}}}$
The function $f(n)$ that renders the equation
    ${\frac {\pi }{4}}=1-{\frac {1}{3}}+{\frac {1}{5}}-\cdots \pm {\frac {1}{n}}\mp f(n+1)$
exact can be expressed in the following form:
    $f(n)={\frac {1}{2}}\times {\cfrac {1}{n+{\cfrac {1^{2}}{n+{\cfrac {2^{2}}{n+{\cfrac {3^{2}}{n+\cdots }}}}}}}}$
The first three convergents of this infinite continued fraction are precisely the correction terms of Madhava. Also, this function $f(n)$ has the following property:
    $f(2n)={\cfrac {1}{4n+{\cfrac {2^{2}}{4n+{\cfrac {4^{2}}{4n+{\cfrac {6^{2}}{4n+{\cfrac {8^{2}}{4n+\cdots }}}}}}}}}}$

## Speculative derivation by Hayashi et al.

In a paper published in 1990, a group of three Japanese researchers proposed an ingenious method by which Madhava might have obtained the three correction terms. Their proposal was based on two assumptions: Madhava used $355/113$ as the value of π and he used the Euclidean algorithm for division.
Writing
    $S(n)=\left|1-{\frac {1}{3}}+{\frac {1}{5}}-{\frac {1}{7}}+\cdots +{\frac {(-1)^{n-1}}{2n-1}}-{\frac {\pi }{4}}\right|$
and taking $\pi =355/113,$ compute the values $S(n),$ express them as a fraction with 1 as numerator, and finally ignore the fractional parts in the denominator to obtain approximations:
    ${\begin{alignedat}{3}S(1)&=\ \ \,{\frac {97}{452}}&&=\ \ \ {\frac {1}{4+{\frac {64}{97}}}}&&\approx {\frac {1}{4}},\\[6mu]S(2)&=\ \ {\frac {161}{1356}}&&=\ \ \,{\frac {1}{8+{\frac {68}{161}}}}&&\approx {\frac {1}{8}},\\[6mu]S(3)&=\ \ {\frac {551}{6780}}&&=\ \,{\frac {1}{12+{\frac {168}{551}}}}&&\approx {\frac {1}{12}},\\[6mu]S(4)&=\ {\frac {2923}{47460}}&&=\ {\frac {1}{16+{\frac {692}{2923}}}}&&\approx {\frac {1}{16}},\\[6mu]S(5)&={\frac {21153}{427140}}&&={\frac {1}{20+{\frac {4080}{21153}}}}&&\approx {\frac {1}{20}}.\end{alignedat}}$
This suggests the following first approximation to $S(n)$ which is the correction term $F_{1}(n)$ talked about earlier.
    $S(n)\approx {\frac {1}{4n}}$
The fractions that were ignored can then be expressed with 1 as numerator, with the fractional parts in the denominators ignored to obtain the next approximation. Two such steps are:
    ${\begin{alignedat}{5}{\frac {64}{97}}&=\ \,{\frac {1}{1+{\frac {33}{64}}}}&&\approx {\frac {1}{1}},&{\frac {33}{64}}&=\,{\frac {1}{1+{\frac {31}{33}}}}&&\approx {\frac {1}{1}},\\[6mu]{\frac {68}{161}}&=\ \,{\frac {1}{2+{\frac {25}{68}}}}&&\approx {\frac {1}{2}},&{\frac {25}{68}}&=\,{\frac {1}{2+{\frac {18}{25}}}}&&\approx {\frac {1}{2}},\\[6mu]{\frac {168}{551}}&=\ {\frac {1}{3+{\frac {47}{168}}}}&&\approx {\frac {1}{3}},&{\frac {47}{168}}&=\,{\frac {1}{3+{\frac {27}{47}}}}&&\approx {\frac {1}{3}},\\[6mu]{\frac {692}{2923}}&={\frac {1}{4+{\frac {155}{692}}}}&&\approx {\frac {1}{4}},&{\frac {155}{692}}&={\frac {1}{4+{\frac {72}{155}}}}&&\approx {\frac {1}{4}},\\[6mu]{\frac {4080}{21153}}&={\frac {1}{5+{\frac {753}{4080}}}}&&\approx {\frac {1}{5}},&\quad {\frac {753}{4080}}&={\frac {1}{5+{\frac {315}{753}}}}&&\approx {\frac {1}{5}}.\end{alignedat}}$
This yields the next two approximations to $S(n),$ exactly the same as the correction terms $F_{2}(n),$
    $S(n)\approx {\frac {1}{4n+{\dfrac {1}{n}}}}={\frac {n}{4n^{2}+1}},$
and $F_{3}(n),$
    $S(n)\approx {\dfrac {1}{4n+{\dfrac {1}{n+{\dfrac {1}{n}}}}}}={\frac {n^{2}+1}{n(4n^{2}+5)}},$
attributed to Madhava.