<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[SutraToSyntax - Medium]]></title>
        <description><![CDATA[The history of Indian mathematics — classical and medieval — implemented and verified in modern Python. Rigorous, sourced, runnable, with the code to check every claim. - Medium]]></description>
        <link>https://medium.com/sutratosyntax?source=rss----18f06c0ae01e---4</link>
        <image>
            <url>https://cdn-images-1.medium.com/proxy/1*TGH72Nnw24QL3iV9IOm4VA.png</url>
            <title>SutraToSyntax - Medium</title>
            <link>https://medium.com/sutratosyntax?source=rss----18f06c0ae01e---4</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 05 Dec 2026 20:32:43 GMT</lastBuildDate>
        <atom:link href="https://medium.com/feed/sutratosyntax" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[The Fibonacci Sequence That Reaches Back One Step Further]]></title>
            <link>https://medium.com/sutratosyntax/the-fibonacci-sequence-that-reaches-back-one-step-further-a524e530d4e6?source=rss----18f06c0ae01e---4</link>
            <guid isPermaLink="false">https://medium.com/p/a524e530d4e6</guid>
            <category><![CDATA[python]]></category>
            <category><![CDATA[golden-ratio]]></category>
            <category><![CDATA[india]]></category>
            <category><![CDATA[mathematics]]></category>
            <dc:creator><![CDATA[Sri Kapali]]></dc:creator>
            <pubDate>Fri, 03 Jul 2026 00:56:04 GMT</pubDate>
            <atom:updated>2026-07-03T00:56:04.298Z</atom:updated>
            <content:encoded><![CDATA[<h3>In 1356, Nārāyaṇa Paṇḍita posed a herd-growth problem whose count follows almost the Fibonacci rule — but reaches back three terms instead of two. That one change swaps the golden ratio for a lesser-known constant. Here is the sequence, the herd it comes from, and the irrational number it hides — in runnable Python.</h3><p>There is a tidy claim you will see passed around: <em>Indians discovered the Fibonacci sequence before Fibonacci.</em> Like most tidy claims about old mathematics, it is part true, part overstated, and more interesting once you pin down which part is which.</p><p>The true part: Sanskrit prosodists were counting with additive recurrences of the Fibonacci kind centuries before Leonardo of Pisa — a thread I flagged at the end of the Piṅgala post (Virahāṅka, Gopāla, Hemacandra). And in 1356, <strong>Nārāyaṇa Paṇḍita</strong> wrote down a <em>different</em> recurrence of the same family, from a problem about breeding cows, whose count is a genuine mathematical object still catalogued today.</p><p>The overstated part: Nārāyaṇa’s cows are <strong>not</strong> the Fibonacci sequence, and this is <strong>not</strong> a “we got there first” story. It is something better — a <em>sibling</em> recurrence, with a different reach-back and a different limiting ratio, showing that the tradition was exploring the whole <em>family</em> of such rules, not racing to one famous member. We will keep the sibling and the celebrity apart below.</p><p>Everything here is generated by code that runs and checks itself.</p><h3>Who Nārāyaṇa was, and when</h3><p><strong>Nārāyaṇa Paṇḍita</strong> wrote the <strong><em>Gaṇita Kaumudī</em></strong> (“Moonlight of Mathematics”) in <strong>1356 CE</strong> — a date that is not seriously contested, which makes him easier to place than Piṅgala. He worked squarely in the <strong>medieval</strong> period; I label it medieval deliberately, because calling everything in this tradition “ancient” is one of the flattenings this series resists. Kim Plofker’s history treats the <em>Gaṇita Kaumudī</em> as one of the major Sanskrit mathematical works of its era, especially rich in combinatorics.</p><p>And, as always: this is not “Vedic mathematics” in the 1965-Tirtha marketing sense. It is a real, dated medieval text. The honest version needs no inflation.</p><h3>The problem, and the sequence it makes</h3><p>Nārāyaṇa’s problem is a population one, in the spirit of Fibonacci’s rabbits: a cow produces one calf a year, each calf matures and in turn begins producing — and you count the herd year by year. The running count comes out as</p><pre>1, 1, 1, 2, 3, 4, 6, 9, 13, 19, 28, 41, 60, 88, ...</pre><p>It opens looking almost like Fibonacci’s 1, 1, 2, 3, 5, 8, … and then quietly diverges. The reason is the rule behind it. Fibonacci adds the <strong>two</strong> previous terms; Nārāyaṇa&#39;s count adds the term just before and the term <strong>three</strong> back:</p><blockquote><strong><em>N(n) = N(n−1) + N(n−3)</em></strong></blockquote><p>This sequence is real enough to have a catalogue number: it is <strong>OEIS A000930</strong>, “Narayana’s cows.”</p><h3>A recurrence, and the constant it hides</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*HygTC7MbHfGww4ddEosVTQ.gif" /></figure><p><em>Figure 1. The count 1, 1, 1, 2, 3, 4, 6, 9, 13, 19, … Each term is the sum of its predecessor and the term three places back. The ratio of successive terms does not approach the golden ratio φ, but a lesser-known cousin, the supergolden ratio ψ ≈ 1.4656.</em></p><p>Here is the honest care the problem needs. Nārāyaṇa’s prose describes calves that mature and <em>then</em> breed — often paraphrased as breeding “in the fourth year.” It is tempting to map “fourth year” straight onto the recurrence, but the index reach-back is <strong>three</strong>, not four, and different modern retellings even start the sequence with slightly different initial terms. These are <strong>counting conventions</strong> — how you number the founding year — not disagreements about the mathematics. So rather than assert one definitive herd-timing, the code below does two things: it runs the recurrence, <em>and</em> it runs a literal age-cohort simulation of a herd, and checks that the two agree. If the recurrence really describes the herd, the simulation must reproduce it — and it does.</p><pre>def cows_recurrence(n_terms):<br>    &quot;&quot;&quot;N(n) = N(n-1) + N(n-3), with N0 = N1 = N2 = 1.&quot;&quot;&quot;<br>    N = [1, 1, 1]<br>    while len(N) &lt; n_terms:<br>        N.append(N[-1] + N[-3])<br>    return N[:n_terms]</pre><pre>def cows_simulation(years):<br>    &quot;&quot;&quot;A literal herd, tracked by age. Independent of the recurrence above:<br>    each cow, once mature, adds one calf per year; we total the herd each year.<br>    This age-cohort reading reproduces OEIS A000930.&quot;&quot;&quot;<br>    ages = {1: 1}                          # one founder, in its first year<br>    totals = []<br>    for _ in range(years):<br>        totals.append(sum(ages.values()))<br>        newborns = sum(c for a, c in ages.items() if a &gt;= 3)   # mature cows breed<br>        aged = {a + 1: c for a, c in ages.items()}<br>        if newborns:<br>            aged[1] = aged.get(1, 0) + newborns<br>        ages = aged<br>    return totals</pre><pre>def supergolden(iters=200):<br>    &quot;&quot;&quot;Real root of x^3 - x^2 - 1 = 0, by Newton&#39;s method — no library constant.&quot;&quot;&quot;<br>    x = 1.5<br>    for _ in range(iters):<br>        f  = x**3 - x**2 - 1<br>        fp = 3*x**2 - 2*x<br>        x -= f / fp<br>    return x</pre><pre># ---- checks ----<br>known = [1, 1, 1, 2, 3, 4, 6, 9, 13, 19, 28, 41, 60, 88, 129, 189, 277]<br>assert cows_recurrence(len(known)) == known            # matches OEIS A000930<br>assert cows_simulation(25) == cows_recurrence(25)      # herd == recurrence<br>psi = supergolden()<br>assert abs(psi**3 - psi**2 - 1) &lt; 1e-12                # psi solves the cubic<br>N = cows_recurrence(60)<br>assert abs(N[-1] / N[-2] - psi) &lt; 1e-6                 # ratio -&gt; psi<br>print(f&quot;all checks passed; psi = {psi:.13f}&quot;)</pre><p>Output (from the full self-checking script):</p><pre>Narayana&#39;s cows self-checks<br>--------------------------------------------------------<br>  [PASS] recurrence matches OEIS A000930 prefix<br>  [PASS] herd simulation == recurrence (25 terms)<br>  [PASS] psi solves x^3-x^2-1=0  (psi=1.4655712318768)<br>  [PASS] N[59]/N[58] -&gt; psi  (ratio=1.4655712319)<br>All self-checks passed.</pre><p>That extra step back does something quietly beautiful. Fibonacci’s ratios approach the <strong>golden ratio</strong> φ ≈ 1.618, the root of x² = x + 1. Nārāyaṇa&#39;s ratios approach a different constant — the <strong>supergolden ratio</strong> ψ ≈ <strong>1.4656</strong>, the real root of</p><blockquote><strong><em>x³ − x² − 1 = 0</em></strong></blockquote><p>A cousin of φ, born from the same kind of question, hiding one extra term back in the recurrence. (I compute ψ from scratch by Newton’s method above rather than quoting a stored constant, so the value is checked against the cubic and against the sequence’s own ratio; still, if you cite the digits, confirm them against a primary numerical source.)</p><h3>A Fibonacci cousin, yes. “India invented Fibonacci,” no.</h3><p>Here is the distinction the headline plays on, made precise, because it matters.</p><ul><li><strong>The cousin is real.</strong> Nārāyaṇa’s cows are a genuine additive recurrence in the Fibonacci family, from a dated medieval text, with a well-defined limiting ratio. That much is solid.</li><li><strong>The takeover claim is false.</strong> This sequence is <em>not</em> the Fibonacci sequence, and Nārāyaṇa was not “beating” Fibonacci at his own sequence. It is a <strong>different</strong> rule with a <strong>different</strong> constant.</li></ul><p>There is a separate, legitimate priority thread — that the <em>Fibonacci numbers themselves</em> appear in Sanskrit prosody before Leonardo, via <strong>Virahāṅka, Gopāla, and Hemacandra</strong>, whose dates are uncertain and span several centuries. I raised it, carefully, at the close of the Piṅgala post, and it deserves its own treatment. But it is a different story from this one. Nārāyaṇa’s contribution is not “the same sequence, earlier”; it is “a neighbouring sequence, explored on its own terms.” The honest sentence is: <em>the Fibonacci pattern is one member of a family of recurrences, and this tradition was mapping the family — Nārāyaṇa’s cows are the member that reaches back three.</em></p><h3>The original text — and what I will not fake</h3><p>The standing rule for this series: I quote source verses only when I can verify them against a real edition, and I never transcribe Sanskrit I cannot check.</p><p>For this piece I have <strong>not</strong> verified the cows verses character for character against a critical edition of the <em>Gaṇita Kaumudī</em>. So no IAST here. What I can state, with what to double-check flagged:</p><ul><li>The source is <strong>Nārāyaṇa Paṇḍita’s <em>Gaṇita Kaumudī</em></strong> (1356 CE); the cows/calves problem sits in its combinatorial material. I have not pinned the exact section/verse number — confirm it in the edition you cite.</li><li>The sequence is <strong>OEIS A000930</strong>, which records the recurrence a(n) = a(n-1) + a(n-3) and the supergolden limit. That catalogue entry is a reliable, checkable anchor for the mathematics.</li><li>An English translation of the <em>Gaṇita Kaumudī</em> was produced by <strong>Parmanand Singh</strong>, published in the journal <em>Gaṇita Bhāratī</em> (in installments, around the late 1990s–early 2000s). I am fairly confident this exists but have not re-verified the exact volumes and years — treat it as a lead to confirm, not a settled citation.</li></ul><p>If you have a critical edition or Singh’s translation to hand, I would like to add the exact verse (in IAST, with its numbering). Until then, the verbal statement above is a faithful paraphrase, and the code is the verifiable artefact.</p><h3>Where it shows up</h3><ul><li><strong>Linear recurrences and their characteristic roots.</strong> Nārāyaṇa’s cows are a clean example of how a recurrence’s long-run growth is governed by the largest root of its characteristic polynomial — here x³ − x² − 1 = 0.</li><li><strong>The supergolden ratio.</strong> ψ is a named constant (the “supergolden ratio”) that recurs in its own small corner of combinatorics and geometry, much as φ does in a larger one.</li><li><strong>Compositions and tilings.</strong> A000930 also counts things like the ways to tile a strip with pieces of length 1 and 3 — the same reach-back-three structure, in a different costume.</li><li><strong>Population and growth models.</strong> Any process where new units mature after a fixed delay before contributing produces a lagged recurrence of exactly this shape.</li></ul><p>(Honest framing: these are places the <em>mathematics</em> lives, not a claim that Nārāyaṇa was studying tilings or characteristic polynomials. He was counting a herd; the structure he found turned out to have a long reach.)</p><h3>Sources, and a note on rigor</h3><ul><li><strong>Kim Plofker, <em>Mathematics in India</em> (Princeton University Press, 2009)</strong> — the standard scholarly history; discusses Nārāyaṇa and the <em>Gaṇita Kaumudī</em>. The reliable anchor above.</li><li><strong>Primary text:</strong> Nārāyaṇa Paṇḍita, <em>Gaṇita Kaumudī</em> (1356). English translation by <strong>Parmanand Singh</strong> in <em>Gaṇita Bhāratī</em> (verify volumes/years before citing precisely).</li><li><strong>Sequence reference:</strong> OEIS <strong>A000930</strong> (“Narayana’s cows”), for the recurrence and the supergolden-ratio limit — directly checkable online.</li><li><strong>On the separate Fibonacci-in-prosody thread:</strong> Parmanand Singh, “The So-called Fibonacci Numbers in Ancient and Medieval India,” <em>Historia Mathematica</em> 12 (1985), 229–244 — relevant to the Virahāṅka/Gopāla/Hemacandra story, <em>not</em> to the cows. Cited here only to keep the two threads distinct.</li></ul><p>A note on what is claimed: I have labelled Nārāyaṇa <strong>medieval</strong> (1356, not contested), kept <strong>his cows separate from the Fibonacci sequence</strong>, kept them separate again from the <strong>prosody Fibonacci-priority</strong> thread, and flagged the “fourth year vs. reach-back-three” gap as a <strong>counting convention</strong> resolved by simulation rather than asserted. If any line proves too cautious or not cautious enough against a primary source, I would rather fix it than smooth it over.</p><p>The Python in this post is self-checking: it asserts that the recurrence matches the catalogued sequence, that an independent herd simulation reproduces it, that ψ solves its cubic, and that the term ratios converge to ψ. If it printed all checks passed, the claims above are doing real arithmetic, not decoration.</p><p><em>Next in the series: named once it is verified, not before.</em></p><p>Subscribe at <a href="https://sutratosyntax.substack.com/"><strong>https://sutratosyntax.substack.com</strong></a> for the rest of the series: the history, honestly sourced, with code you can actually run.</p><p><em>Views my own.</em></p><p>Tags: Mathematics, History, Programming, Python, Fibonacci</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a524e530d4e6" width="1" height="1" alt=""><hr><p><a href="https://medium.com/sutratosyntax/the-fibonacci-sequence-that-reaches-back-one-step-further-a524e530d4e6">The Fibonacci Sequence That Reaches Back One Step Further</a> was originally published in <a href="https://medium.com/sutratosyntax">SutraToSyntax</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Counting in Two Symbols, Two Thousand Years Before Boole]]></title>
            <link>https://medium.com/sutratosyntax/counting-in-two-symbols-two-thousand-years-before-boole-e54b7da79969?source=rss----18f06c0ae01e---4</link>
            <guid isPermaLink="false">https://medium.com/p/e54b7da79969</guid>
            <category><![CDATA[mathematics]]></category>
            <category><![CDATA[python-programming]]></category>
            <category><![CDATA[hinduism]]></category>
            <category><![CDATA[binary]]></category>
            <dc:creator><![CDATA[Sri Kapali]]></dc:creator>
            <pubDate>Sat, 27 Jun 2026 01:43:08 GMT</pubDate>
            <atom:updated>2026-06-27T01:43:08.522Z</atom:updated>
            <content:encoded><![CDATA[<h3>Pingala laid out Sanskrit metres as patterns of light and heavy syllables — and, read with one fixed rule, that layout is binary counting. Here is the system, in runnable Python. (And a word on why it is binary, not Boolean.)</h3><p>There is a tidy claim you will see passed around: <em>an ancient Indian scholar invented binary.</em> Like most tidy claims about old mathematics, it is part true, part overstated, and more interesting once you pin down which part is which.</p><p>The true part: Pingala, in a treatise on Sanskrit prosody, classifies every syllable as one of two kinds and then lays out <strong>all</strong> the patterns of a metre in a fixed order. Read that table with a single, simple convention and it counts 0, 1, 2, 3, … in base two — place values, carries, and all. He also gives a clever way to count the patterns that is, in modern terms, exponentiation by squaring.</p><p>The overstated part: this is <strong>binary representation</strong>, not <strong>Boolean algebra</strong>, and not the modern positional number system either. Those are different inventions by different people, and conflating them is exactly the kind of flattening this newsletter exists to resist. We will keep them apart below.</p><p>Everything here is generated by code that runs and checks itself.</p><h3>Who Pingala was, and when (carefully)</h3><p>Pingala is the author of the <em>Chandahsastra</em> (also written <em>Chandahsutra</em>), a compact treatise on <strong>chandas</strong> — Sanskrit metre. His dating is genuinely uncertain and debated among scholars; he is usually placed somewhere in the last few centuries BCE, but I would not state a specific year as settled, and you should treat any single date you see quoted with suspicion. What is not in doubt is that the text is old, and that the combinatorial machinery in it was elaborated by later commentators over many centuries.</p><p>One thing to set aside immediately: this is <strong>not</strong> “Vedic mathematics” in the modern marketing sense (that is a 20th-century system, published by Bharati Krishna Tirtha in 1965, and neither Vedic nor ancient). Pingala’s work is a real, dated piece of Indian mathematical prosody. The honest version needs no inflation.</p><h3>Two syllables, and the whole point</h3><p>Sanskrit metre is built from syllables of two weights:</p><ul><li><strong>laghu</strong> — light / short</li><li><strong>guru</strong> — heavy / long</li></ul><p>A line of <em>n</em> syllables is just a sequence of these two symbols. So there are exactly <strong>2ⁿ</strong> possible patterns for an <em>n</em>-syllable metre. That doubling is the seed of everything that follows, and Pingala builds the rest of the apparatus around it: a way to write all the patterns out (<strong>prastara</strong>), a way to recover the pattern sitting in a given row (<strong>nasta</strong>), a way to find the row number of a given pattern (<strong>uddista</strong>), and a way to count the total (<strong>sankhya</strong>).</p><p>Fix one convention — <strong>guru = 0, laghu = 1, with the leftmost syllable as the ones place</strong> — and those four operations become, respectively: list the binary numerals, decode a number to binary, encode binary to a number, and compute 2ⁿ.</p><h3>The prastara is a binary counter</h3><p>Pingala’s rule for laying out every pattern (the <em>prastara-vidhi</em>): start with the all-<em>guru</em> row. To get the next row, scan from the left to the first <em>guru</em>; put a <em>laghu</em> there, turn everything to its left back to <em>guru</em>, and copy everything to its right unchanged. Stop after the all-<em>laghu</em> row.</p><p>Run that rule for a 4-syllable metre and watch what the rows spell out:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/864/1*H-GPJYi3pu_T7pUY-LcNSw.gif" /></figure><p><em>Figure 1. The 16 patterns of a 4-syllable metre in Pingala’s order. With guru = 0, laghu = 1, and the leftmost syllable as the ones place, the rows are simply 0000, 0001, 0010, … , 1111 — the counting numbers 0 through 15 in binary.</em></p><p>That is not an analogy. It is the same object. Here is the layout and the two inverse operations that read it both ways:</p><pre>def prastara(n):<br>    &quot;&quot;&quot;All 2**n laghu/guru patterns, in Pingala&#39;s classical order.&quot;&quot;&quot;<br>    row = [&quot;G&quot;] * n<br>    rows = [&quot;&quot;.join(row)]<br>    while &quot;G&quot; in row:<br>        i = row.index(&quot;G&quot;)          # first guru from the left<br>        row[i] = &quot;L&quot;<br>        for j in range(i):<br>            row[j] = &quot;G&quot;<br>        rows.append(&quot;&quot;.join(row))<br>    return rows</pre><pre>def uddista(pattern):<br>    &quot;&quot;&quot;Pattern -&gt; row number: place values 1,2,4,... over the syllables,<br>    sum over the laghu (light) ones, add 1.  That is a binary numeral.&quot;&quot;&quot;<br>    return 1 + sum(1 &lt;&lt; i for i, s in enumerate(pattern) if s == &quot;L&quot;)</pre><pre>def nasta(n, r):<br>    &quot;&quot;&quot;Row number -&gt; pattern: read the bits of r-1, leftmost = ones place.&quot;&quot;&quot;<br>    m, out = r - 1, []<br>    for _ in range(n):<br>        out.append(&quot;L&quot; if (m &amp; 1) else &quot;G&quot;)<br>        m &gt;&gt;= 1<br>    return &quot;&quot;.join(out)</pre><pre>def sankhya(n):<br>    &quot;&quot;&quot;Total = 2**n, by Pingala&#39;s halve-and-square (exponentiation by squaring).&quot;&quot;&quot;<br>    steps, m = [], n<br>    while m &gt; 0:<br>        if m % 2 == 0:<br>            steps.append(&quot;sq&quot;);  m //= 2     # halve  -&gt; square on replay<br>        else:<br>            steps.append(&quot;dbl&quot;); m -= 1      # minus one -&gt; double on replay<br>    r = 1<br>    for op in reversed(steps):<br>        r = r * r if op == &quot;sq&quot; else r * 2<br>    return r</pre><pre># checks<br>rows = prastara(4)<br>assert len(rows) == 16 and len(set(rows)) == 16<br>for idx, pat in enumerate(rows, start=1):<br>    assert uddista(pat) == idx<br>    assert nasta(4, idx) == pat<br>    assert idx - 1 == sum(1 &lt;&lt; i for i, s in enumerate(pat) if s == &quot;L&quot;)<br>assert all(sankhya(n) == 2 ** n for n in range(40))<br>print(&quot;prastara of 4 syllables -&gt; 16 patterns, counting 0..15 in binary:&quot;)<br>for idx, pat in enumerate(rows, start=1):<br>    bits = &quot;&quot;.join(&quot;1&quot; if s == &quot;L&quot; else &quot;0&quot; for s in reversed(pat))<br>    print(f&quot;  row {idx:&gt;2}: {pat}  =  {bits}  =  {idx-1}&quot;)<br>print(&quot;sankhya(10) =&quot;, sankhya(10), &quot;= 2**10&quot;)<br>print(&quot;all checks passed&quot;)</pre><p>Output:</p><pre>prastara of 4 syllables -&gt; 16 patterns, counting 0..15 in binary:<br>  row  1: GGGG  =  0000  =  0<br>  row  2: LGGG  =  0001  =  1<br>  row  3: GLGG  =  0010  =  2<br>  ...<br>  row 15: GLLL  =  1110  =  14<br>  row 16: LLLL  =  1111  =  15<br>sankhya(10) = 1024 = 2**10<br>all checks passed</pre><p>The <strong>uddista</strong> rule is the one to dwell on. Pingala says: write the place values 1, 2, 4, 8, … over the syllables from the left, add up the ones standing over the <em>laghu</em> syllables, and add 1. Strip the “add 1” (which only exists because he numbers rows from 1, not 0) and that instruction is the definition of a binary numeral: a sum of distinct powers of two. <strong>nasta</strong> is its inverse — repeated halving, which is exactly how you read a number off in binary.</p><p>(One honest caveat: which parity — even or odd — maps to which syllable, and whether the count starts at 0 or 1, varies between editions and retellings. The code fixes one self-consistent choice and verifies that uddista and nasta invert each other and agree with the prastara order. The <em>structure</em> is the invariant; the labelling is convention.)</p><h3>The Meru-prastara: powers of two, split by weight</h3><p>If 2ⁿ is the total, a natural next question is: how many of those patterns have exactly <em>k</em> heavy syllables? The answer is the binomial coefficient C(n, k), and arranging those counts in a stack gives Pascal’s triangle — known in this tradition as the <strong>Meru-prastara</strong>, the “Mount Meru arrangement.”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/983/1*YNqij4wJ33iPTiL27ly8aw.gif" /></figure><p><em>Figure 2. The Meru-prastara. Each cell counts the patterns with a given number of heavy syllables, C(r, k); each row sums to 2ʳ. This is Pascal’s triangle, several centuries before Pascal.</em></p><p>A careful attribution here, because it is often blurred: the explicit “Mount Meru” diagram is laid out in <strong>Halayudha’s</strong> commentary, the <em>Mritasanjivani</em>, written around the 10th century CE — well after Pingala. Pingala’s own text supplies the underlying counting; the iconic triangular picture is the commentator’s. Both deserve credit, and for different things.</p><p>The same sankhya function above computes 2ⁿ not by multiplying out, but by Pingala&#39;s <strong>halve-and-square</strong> procedure: reduce <em>n</em> to zero by halving when it is even and subtracting one when it is odd, then replay those steps from a seed of 1 — squaring for each halving, doubling for each subtraction. That is <strong>exponentiation by squaring</strong>, O(log n) multiplications instead of n. It is still the algorithm your computer uses to raise numbers to large powers, and it is still how fast modular exponentiation works inside RSA. (The <em>Chandahsastra</em> states this verbally, with markers usually read as <em>sunya</em> and <em>dvi</em>; the exact verse numbering differs across editions, so I am not going to assert one — see the note below.)</p><h3>Binary, yes. Boolean, no.</h3><p>Here is the distinction the headline plays on, made precise, because it matters.</p><ul><li><strong>Binary representation</strong> is writing numbers in base two — a positional system over two symbols. Pingala’s prastara, read as above, <em>is</em> this. The modern positional treatment was set out by <strong>Leibniz in 1703</strong>; he arrived at it independently, with no evidence he knew of Pingala. Same idea, two cultures, about two millennia apart.</li><li><strong>Boolean algebra</strong> is something else: an algebra of logic — operations (AND, OR, NOT) over truth values — introduced by <strong>George Boole</strong> in <em>The Mathematical Analysis of Logic</em> (1847) and <em>An Investigation of the Laws of Thought</em> (1854). It is what lets two-valued symbols <em>compute</em>, and it is the layer that turns binary digits into logic gates.</li></ul><p>Pingala gives you the digits and the counting. He does not give you the algebra of logic. The honest sentence is: <em>Pingala’s prosody is binary representation; Boole’s is the algebra that came nearly two thousand years later and made it logical.</em> The two together are why your processor works — but they are two inventions, not one.</p><h3>The original text — and what I will not fake</h3><p>The standing rule for this series: I quote source verses only when I can verify them against a real edition, and I never transcribe Sanskrit I cannot check.</p><p>For this piece I have not verified, character for character, the specific aphorisms for the prastara and the halve-and-square count against a critical edition of the <em>Chandahsastra</em>. So I am not going to print IAST here and risk a corrupted line. What I can state with confidence:</p><ul><li>The source is Pingala’s <strong><em>Chandahsastra</em></strong> (<em>Chandahsutra</em>), a treatise on Sanskrit metre.</li><li>The combinatorial apparatus — and the explicit <strong>Meru-prastara</strong> — is elaborated in <strong>Halayudha’s</strong> <em>Mritasanjivani</em> commentary (c. 10th century CE).</li><li>The four operations (prastara, nasta, uddista, sankhya) and the powers-of-two count are standard features of this tradition, discussed in modern scholarship (see Sources).</li></ul><p>If you have a critical edition of the <em>Chandahsastra</em> with Halayudha’s commentary, I would like to add the exact verses (in IAST, with their numbering in that edition) for the prastara rule and the halve-and-square sutras. Until then, the verbal algorithm above is a faithful paraphrase, and the code is the verifiable artefact.</p><p><em>A related thread, flagged honestly:</em> a different prosody problem — counting metres by total <strong>duration</strong> rather than syllable count — produces the <strong>Fibonacci numbers</strong>, and was studied by Virahanka, Gopala, and Hemachandra. Their dates are uncertain and span several centuries (roughly mid-first-millennium to ~12th century CE); I mention it only as a cousin of this story, not as part of Pingala’s own text.</p><h3>Where it shows up</h3><ul><li><strong>Every digital device.</strong> Binary representation is the substrate of all of it. Pingala’s prastara is a clean, ancient instance of the same idea: two symbols, place value, exhaustive enumeration.</li><li><strong>Fast exponentiation.</strong> The halve-and-square trick is exponentiation by squaring — the standard fast-power algorithm, and the engine of modular exponentiation in public-key cryptography like RSA.</li><li><strong>Combinatorics.</strong> The Meru-prastara is Pascal’s triangle: binomial coefficients, the binomial theorem, and the backbone of basic probability.</li><li><strong>Enumerating possibilities in code.</strong> “List all 2ⁿ subsets / on-off patterns” is a daily task — feature flags, truth tables, bitmask dynamic programming. The prastara is exactly that enumeration.</li></ul><p>(Honest framing: these are places the <em>mathematics</em> lives, not a claim that Pingala foresaw cryptography. He was solving a prosody problem, and the structure he found turned out to be load-bearing far beyond it.)</p><h3>Sources, and a note on rigor</h3><ul><li><strong>Kim Plofker, <em>Mathematics in India</em> (Princeton University Press, 2009)</strong> — the standard scholarly history; covers Pingala, the prastara, the combinatorial rules, and their later elaboration. The reliable anchor for everything above.</li><li><strong>Primary text:</strong> Pingala, <em>Chandahsastra</em>, with <strong>Halayudha’s <em>Mritasanjivani</em></strong> commentary (c. 10th c. CE) for the Meru-prastara.</li><li><strong>For the Boolean / binary distinction:</strong> George Boole, <em>The Mathematical Analysis of Logic</em> (1847) and <em>An Investigation of the Laws of Thought</em> (1854); and Leibniz’s 1703 paper on binary arithmetic for the positional system. These are well-documented; I have not re-verified publication details against first editions here, so confirm them if you cite them precisely.</li></ul><p>A note on what is claimed: I have <strong>not</strong> given Pingala’s date (it is genuinely contested), I have attributed the explicit Pascal/Meru triangle to <strong>Halayudha</strong>, not Pingala, and I have kept <strong>binary representation</strong> and <strong>Boolean algebra</strong> as two separate inventions. If any of those lines later proves too cautious or not cautious enough against a primary source, I would rather fix it than smooth it over.</p><p>The Python in this post is self-checking: it asserts that the prastara has 2ⁿ distinct rows, that uddista and nasta invert each other, that the rows literally equal 0…2ⁿ−1 in binary, and that the halve-and-square count equals 2ⁿ. If it printed all checks passed, the claims above are doing real arithmetic, not decoration.</p><p><em>Next: Post 5 takes up a different question — and I will name it once it is verified, not before.</em></p><p>Subscribe at <a href="https://sutratosyntax.substack.com/"><strong>https://sutratosyntax.substack.com</strong></a> for the rest of the series: the history, honestly sourced, with code you can actually run.</p><p><em>Views my own.</em></p><p>Tags: Mathematics, History, Programming, Python</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e54b7da79969" width="1" height="1" alt=""><hr><p><a href="https://medium.com/sutratosyntax/counting-in-two-symbols-two-thousand-years-before-boole-e54b7da79969">Counting in Two Symbols, Two Thousand Years Before Boole</a> was originally published in <a href="https://medium.com/sutratosyntax">SutraToSyntax</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[An Indian School Found the Infinite Series for π — Then Made It Converge Fast]]></title>
            <link>https://medium.com/sutratosyntax/an-indian-school-found-the-infinite-series-for-%CF%80-then-made-it-converge-fast-4d3c2e53b28b?source=rss----18f06c0ae01e---4</link>
            <guid isPermaLink="false">https://medium.com/p/4d3c2e53b28b</guid>
            <category><![CDATA[mathematics]]></category>
            <category><![CDATA[python-programming]]></category>
            <dc:creator><![CDATA[Sri Kapali]]></dc:creator>
            <pubDate>Sun, 21 Jun 2026 00:23:34 GMT</pubDate>
            <atom:updated>2026-06-21T00:23:34.625Z</atom:updated>
            <content:encoded><![CDATA[<p><em>Mādhava and the medieval Kerala school wrote the π series two and a half centuries before Europe — then did the harder thing and made it converge fast. With runnable, tested Python.</em></p><p>Most people meet π as a number you look up: 3.14159… But you can also <em>generate</em> it, digit after digit, from a strikingly simple infinite sum:</p><blockquote><em>π = 4 × (1 − 1/3 + 1/5 − 1/7 + 1/9 − …)</em></blockquote><p>In Europe this is the Gregory–Leibniz series, named for work in the 1670s. But it was written down in southern India some two and a half centuries earlier — and the same school then did something the European story took much longer to reach: they made the slow series fast.</p><h3>Mādhava and the Kerala school</h3><p>The series is credited to <strong>Mādhava of Sangamagrāma</strong> (c. 1340–1425), the founder of what we now call the Kerala school of astronomy and mathematics. Almost none of Mādhava’s own writing survives; we know his results because later members of the school recorded and credited them — above all <strong>Nīlakaṇṭha Somayāji</strong>’s <em>Tantrasaṅgraha</em> (1501) and <strong>Jyeṣṭhadeva</strong>’s <em>Yuktibhāṣā</em> (c. 1530), the latter one of the earliest texts anywhere to lay out something close to proofs of these series.</p><h3>The series, in Python</h3><p>The sum itself is a few lines, and it works — slowly.</p><pre>import math<br></pre><pre>def leibniz_quarter(n):<br>    &quot;&quot;&quot;Partial sum of n terms of 1 - 1/3 + 1/5 - ...  (approximates pi/4).&quot;&quot;&quot;<br>    return sum((-1) ** (k - 1) / (2 * k - 1) for k in range(1, n + 1))<br></pre><pre>def end_correction(n):<br>    &quot;&quot;&quot;Madhava/Kerala end-correction term applied after n terms.&quot;&quot;&quot;<br>    return (n * n + 1) / (4 * n ** 3 + 5 * n)<br></pre><pre>def pi_raw(n):<br>    return 4 * leibniz_quarter(n)<br></pre><pre>def pi_corrected(n):<br>    return 4 * (leibniz_quarter(n) + (-1) ** n * end_correction(n))<br></pre><pre>for n in (10, 50):<br>    print(f&quot;after {n} terms&quot;)<br>    print(f&quot;  raw       : {pi_raw(n):.12f}   error {pi_raw(n) - math.pi:+.2e}&quot;)<br>    print(f&quot;  corrected : {pi_corrected(n):.12f}   error {pi_corrected(n) - math.pi:+.2e}&quot;)<br>print(f&quot;  true pi   : {math.pi:.12f}&quot;)</pre><p>Ignore end_correction for a moment and just watch the raw series. It is correct, but its convergence is brutal: ten thousand terms buys you only about four correct digits.</p><p><em>Figure — The raw series for π overshoots, undershoots, and only slowly narrows toward the true value. Accurate, but you would need millions of terms for serious precision.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/960/1*cZ_qij1Th7M5i27Z7h_4dA.gif" /></figure><h3>The leap: the end-correction</h3><p>Here is the part that sets the Kerala school apart. They didn’t just write the series; they studied its <em>error</em> and built a correction for it — the <em>antya-saṃskāra</em>, or “end-correction.” After summing <em>n</em> terms, you add one small rational term, and the accuracy jumps by orders of magnitude. Running the code above prints:</p><pre>after 10 terms<br>  raw       : 3.041839618929   error -9.98e-02<br>  corrected : 3.141592705349   error +5.18e-08<br>after 50 terms<br>  raw       : 3.121594652591   error -2.00e-02<br>  corrected : 3.141592653591   error +7.18e-13<br>  true pi   : 3.141592653590</pre><p>Ten terms of the raw series give one correct digit. Ten terms <em>with the correction</em> give eight. At fifty terms the corrected value is right to about twelve decimal places — from a series that, left alone, would need on the order of a trillion terms to get there.</p><p><em>Figure — Same series, one extra term. The raw partial sums (orange) flail between 2.7 and 4; with the Kerala end-correction (green) the estimate locks onto π almost immediately.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/960/1*44j-JfwBTUeXFMmfzYX5Ew.gif" /></figure><h3>The original text</h3><p>Mādhava’s own writing on this is lost, so the verses we have are the ones his Kerala successors recorded and credited to him. The series together with the correction terms is set down in Śaṅkara Vāriyar’s <em>Yuktidīpikā</em> (the <em>Laghuvivṛtti</em> commentary on Nīlakaṇṭha’s <em>Tantrasaṅgraha</em>): the series and the first two corrections in Chapter 2, verses 271–274, and the sharper third correction a little later, in verses 295–296.</p><p>The verse states an algorithm rather than a formula. Put in plain steps, it says: take four times the diameter; alternately add and subtract four times the diameter divided by 3, then 5, then 7, and so on; stop at some odd number; then adjust the running total by a correction built from the <em>next</em> even number — which is exactly the role F(n) plays in the code above. Two terms are worth keeping:</p><ul><li><em>antya-saṃskāra</em> — the “end-correction,” the term applied after the series is cut off;</li><li><em>kaṭapayādi</em> — the syllable-based number code the Kerala authors wrote in. Mādhava’s value of π, good to about eleven decimal places, survives as one such coded verse.</li></ul><p>I’m not reproducing the Sanskrit itself here, and the reason is the house rule. In the source I checked — Krishnachandran’s 2024 survey of these correction terms — the verses are shown as page-scans of the text, not as transcribed characters, and I only print original text when it can be verified character-for-character against an edition. If you can pull the IAST from a critical edition (K. V. Sarma’s <em>Tantrasaṅgraha</em>, or the commentary edition the paper quotes), I’ll typeset and verify it for the piece.</p><h3>Where it shows up</h3><ul><li><strong>Series acceleration is everyday numerical analysis.</strong> Turning a correct-but-slow series into a fast one is exactly what modern methods like the Euler transform, Richardson extrapolation, and Shanks/Aitken acceleration do. The <em>antya-saṃskāra</em> is an early, hand-derived instance of the same idea.</li><li><strong>It’s how π and inverse trig get computed.</strong> Arctangent series — the family this one belongs to — are how inverse-trig functions and π are actually evaluated in software, and “Machin-like” arctan sums were the workhorse for computing π to ever more digits well into the computer era.</li><li><strong>The real lesson: convergence is the whole game.</strong> A formula can be perfectly correct and still useless if it converges slowly. The art — then and now — is making it fast. The Kerala school saw that distinction clearly.</li></ul><h3>Sources, and a note on rigor</h3><p>This area draws a lot of inflated claims, so it’s worth being careful. The dependable modern reference is Kim Plofker’s <em>Mathematics in India</em> (Princeton University Press, 2009); for the series and its corrections specifically, the verses live in the <em>Yuktidīpikā</em> commentary on the <em>Tantrasaṅgraha</em>, and a focused recent survey is V. N. Krishnachandran, “On Mādhava and his correction terms for the Mādhava–Leibniz series for π” (arXiv:2405.11134, 2024), which collects the verses, translations, and verse numbers used above. Two honest caveats: Mādhava’s own writing is lost, so attribution runs through later Kerala authors who credit him; and the exact Sanskrit is best taken from a critical edition rather than a secondary summary. The code above is original and tested; the history is best confirmed against sources like Plofker before repeating.</p><p><em>Next in this series: Piṅgala’s binary — how a manual on poetic metre, more than two thousand years ago, encoded binary numbers and a triangle the West would later call Pascal’s.</em></p><p><em>If you enjoyed this, you can get each new piece as it’s published — </em><a href="https://sutratosyntax.substack.com/"><em>subscribe here</em></a><em>. Views are my own.</em></p><p>Tags: Mathematics, History, Programming, Python</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4d3c2e53b28b" width="1" height="1" alt=""><hr><p><a href="https://medium.com/sutratosyntax/an-indian-school-found-the-infinite-series-for-%CF%80-then-made-it-converge-fast-4d3c2e53b28b">An Indian School Found the Infinite Series for π — Then Made It Converge Fast</a> was originally published in <a href="https://medium.com/sutratosyntax">SutraToSyntax</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[An Ancient Indian Altar Manual Computes √2 to Five Decimal Places]]></title>
            <link>https://medium.com/sutratosyntax/an-ancient-indian-altar-manual-computes-2-to-five-decimal-places-3ea94ffb6fd8?source=rss----18f06c0ae01e---4</link>
            <guid isPermaLink="false">https://medium.com/p/3ea94ffb6fd8</guid>
            <category><![CDATA[history]]></category>
            <category><![CDATA[mathematics]]></category>
            <category><![CDATA[python]]></category>
            <dc:creator><![CDATA[Sri Kapali]]></dc:creator>
            <pubDate>Sun, 07 Jun 2026 15:06:55 GMT</pubDate>
            <atom:updated>2026-06-07T15:06:55.844Z</atom:updated>
            <content:encoded><![CDATA[<p>Long before anyone wrote down a theory of irrational numbers, a manual for building brick fire-altars in India recorded a value for √2 correct to five decimal places — and, in the same breath, warned that it was a little too large.</p><p>That manual is one of the <em>Śulba-sūtras</em>, and the rule it gives is not a number you look up. It is a procedure: a short verbal recipe carried out step by step. Which makes it, quite literally, a sutra you can run as code.</p><h3>What the Śulba-sūtras are</h3><p>The <em>Śulba-sūtras</em> (“rules of the cord”) are appendices to the ritual texts of the Vedic tradition, concerned with laying out altars of precise shape and area using only cords and pegs. Doing that correctly forced their authors into real geometry: squaring rectangles, combining areas, and — the case we care about — building a square with exactly twice the area of a given one.</p><p>They are genuinely ancient. The oldest, attributed to Baudhāyana, is usually placed in the first half of the first millennium BCE (often around 800 BCE), though the dating is debated and is best treated as approximate rather than fixed. The dependable modern reference is Kim Plofker’s <em>Mathematics in India</em> (Princeton, 2009), which sets this material in careful historical context.</p><h3>The problem: doubling a square</h3><p>To double the <em>area</em> of a square, you need a new square whose side is the diagonal of the original — and that diagonal is the side times √2. So “double this altar” is, underneath, the problem of finding √2.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3igzKJRj9Ig43gXS01WZsw.png" /></figure><p>The Baudhāyana text gives the answer as an explicit construction. In words: take the side; increase it by its own third; increase that third by its own fourth; then take away the thirty-fourth part of that fourth. In symbols:</p><blockquote><em>√2 ≈ 1 + 1/3 + 1/(3·4) − 1/(3·4·34)</em></blockquote><p>The text calls the result <em>saviśeṣa</em> — “with a remainder,” or “with excess.” That single word is the striking part: whoever wrote it knew the value was not exact, and knew which way it erred.</p><h3>The rule, in Python</h3><p>It runs in a few lines, with exact fractions so nothing is lost to rounding:</p><pre>from fractions import Fraction<br>import math</pre><pre># 1 + 1/3 + 1/(3*4) - 1/(3*4*34)<br>approx = Fraction(1) + Fraction(1, 3) + Fraction(1, 3 * 4) - Fraction(1, 3 * 4 * 34)</pre><pre>print(&quot;rule  =&quot;, approx, &quot;=&quot;, float(approx))<br>print(&quot;sqrt2 =&quot;, math.sqrt(2))<br>print(&quot;error =&quot;, float(approx) - math.sqrt(2))</pre><p>Output:</p><pre>rule  = 577/408 = 1.4142156862745099<br>sqrt2 = 1.4142135623730951<br>error = 2.1239014147411694e-06</pre><p>The recipe collapses to the single fraction 577/408. It agrees with √2 to five decimal places, and it sits just <em>above</em> the true value — an overestimate of about two millionths. The text’s word <em>saviśeṣa</em> was right: a little too big.</p><h3>Why this is worth pausing on</h3><p>It is easy to inflate a fact like this, so here is the measured version. This is not evidence of a worked-out theory of irrational numbers, and it is not calculus in disguise. What it is: an explicit, repeatable procedure — an algorithm — for a non-obvious quantity, accurate to five decimals, embedded in a practical manual roughly twenty-eight centuries old, and annotated by its own author as approximate. The honesty is as impressive as the accuracy. Both are why this is the right place to begin.</p><h3>Sources, and a note on rigor</h3><p>This area attracts a great deal of overstatement, so it is worth being careful. The reliable scholarly reference is Kim Plofker’s <em>Mathematics in India</em> (Princeton University Press, 2009). Two honest caveats: the dating of the Śulba-sūtras is debated, so treat “around 800 BCE” as approximate; and the exact wording and interpretation of the rule are best read in a proper translation rather than taken from a summary. The code above is original and tested; the full code for this piece lives on GitHub at <a href="https://github.com/roasoul/sutratosyntax">github.com/roasoul/sutratosyntax</a>, and the history is best confirmed against sources like Plofker before repeating.</p><p><em>Next in this series: jump forward some fifteen centuries to the medieval Chakravala method — and watch it crack the very equation Fermat would later pose to Europe as a challenge.</em></p><p><em>If you enjoyed this, you can get each new piece as it’s published — </em><a href="https://sutratosyntax.substack.com/"><em>subscribe here</em></a><em>. Views my own.</em></p><p>Tags: Mathematics, History, Programming, Python</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3ea94ffb6fd8" width="1" height="1" alt=""><hr><p><a href="https://medium.com/sutratosyntax/an-ancient-indian-altar-manual-computes-2-to-five-decimal-places-3ea94ffb6fd8">An Ancient Indian Altar Manual Computes √2 to Five Decimal Places</a> was originally published in <a href="https://medium.com/sutratosyntax">SutraToSyntax</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>