Sharat Visweswara
4 min read updated
  • poetry
  • math
  • sanskrit

Sanskrit Poetry and Math

A Sanskrit scholar’s obsession with short and long syllables led, centuries before Europe caught on, to a number pattern you already know by heart.

All poetry has a heartbeat.

In English, that heartbeat often comes from stress: a pattern of stronger and weaker beats moving through a line. Shakespeare famously wrote in iambic pentameter, and lines such as “Shall I compare thee to a summer’s day?” are often used to illustrate the pattern of alternating unstressed and stressed syllables (What Is Iambic Pentameter?). Classical Sanskrit poetry also has meter, but it is built differently.

Sanskrit does not organize verse around stress in the same way English does. Instead, it distinguishes between light syllables (laghu) and heavy syllables (guru), and poets build metrical forms from those two basic units (Sanskrit prosody). A short open syllable such as ka is light, while a long syllable or one closed by consonants counts as heavy.

The poetic puzzle

Somewhere in the last few centuries BCE, a scholar named Pingala composed a treatise on Sanskrit prosody called the Chandaḥśāstra (Pingala). Its aim was literary, not abstractly mathematical: it described and organized the meters used in Sanskrit verse.

Yet this literary project opened a mathematical door. In the metrical system discussed in later explanations of Pingala’s work, a light syllable counts as one unit and a heavy syllable as two (Pingala’s Poetry Puzzle). That turns meter into a counting problem: for a line of total length 3, how many patterns can be formed from syllables worth 1 and 2 units?

There are exactly three:

  • light + light + light = 3
  • light + heavy = 3
  • heavy + light = 3

Two heavy syllables do not fit, because 2 + 2 is already too large. This is a tiny puzzle, but it scales. As the target length grows, the number of valid patterns grows in a striking way.

Pingala’s procedures

Pingala described systematic ways to generate and count patterns of light and heavy syllables (A History of Piṅgala’s Combinatorics). Modern historians of mathematics often describe these procedures as early algorithmic thinking, because they are step-by-step rules rather than a single compact algebraic formula.

That claim should be stated carefully. Pingala was not “inventing computer science” in a modern sense, and calling this “the first algorithm ever written” goes beyond what the evidence supports. A safer and more accurate formulation is that his work contains some of the earliest known combinatorial procedures in the study of poetic meter.

To count patterns of length n:
- Start with a light syllable, then count patterns of length n-1
- Or start with a heavy syllable, then count patterns of length n-2

Virahanka’s Recurrence Relation

Several centuries later, the same metrical tradition was developed further by Virahanka, usually dated to around the 6th century CE, though exact dating is not perfectly certain (Virahanka and related discussion). In discussions of Sanskrit prosody, Virahanka is credited with expressing the count of these metrical patterns through a recurrence relation recognizable today.

If the number of patterns of length nn is called UnU_n, then the count follows this rule:

Un=Un1+Un2U_n = U_{n-1} + U_{n-2}

The reason is elegant. Any valid pattern of total length nn must begin either with a light syllable, leaving n1n-1 units still to fill, or with a heavy syllable, leaving n2n-2 units.

Patterns of length n
├── start with L  -> patterns of length n-1
└── start with H  -> patterns of length n-2

So:
count(n) = count(n-1) + count(n-2)

That is the same recurrence behind the sequence now associated with Fibonacci (Fibonacci sequence overview). The indexing and starting terms in the Sanskrit tradition are not always presented in exactly the modern textbook way, but the underlying pattern is the same.

The road to Europe

The sequence became famous in Europe through Leonardo of Pisa, known as Fibonacci, whose 1202 book Liber Abaci included the well-known rabbit problem (Britannica on Fibonacci). The sequence later took his name, even though related recurrence patterns had appeared earlier in Indian prosodic work.

That historical twist is part of what makes this story so appealing. A sequence now taught in math classes around the world did not emerge first from rabbits, spirals, or number puzzles. It also arose from poets and scholars asking a simple artistic question: how many ways can a line of verse be made to breathe?

A better way to say it

The strongest version of the story is not that Pingala “discovered Fibonacci numbers” in the modern sense. It is that ancient and early medieval Indian scholars studying Sanskrit meter developed counting methods and recurrence relations that are mathematically equivalent to the sequence later popularized in Europe under Fibonacci’s name.

That version is both more careful and more interesting. It shows mathematics emerging not in isolation, but from memory, language, rhythm, and the practical craft of poetry.