संस्कृतव्याकरणम् · 22 of 27 Home
छन्दःशास्त्रम् · पिङ्गल-वृत्तरत्नाकरौ

Reading the
weight of a syllable

Sanskrit verse is not counted in stresses, the way English verse is, and not quite in syllables either. It is counted in weight — light or heavy, लघु or गुरु — and once you can call that by eye, a whole line resolves into a pattern you can name. Nothing below needs music or an ear for metre. It is a mechanical skill, three rules deep.

देव
→
–⏑
→
?
scanned
लघु — light, one mora गुरु — heavy, two morae गणः — three syllables read as a unit

Why bother scanning at all

Orientation

A verse recited with the wrong weights is not merely inelegant — in ritual and recitation contexts it is a real error, the way singing the wrong notes is. And weight is not just about performance: it is one of the few checks a reader has on a transmitted text.

If a manuscript reading makes a metre come out one syllable short, that is not a minor slip — it usually means a word was mis-copied, and the metre tells you where to look. Editors of Sanskrit texts have used this for centuries: the verse form is evidence, independent of what the words appear to say. This page builds that skill from the ground up — how to call a single syllable light or heavy, then how the light and heavy syllables of a whole line identify which of the classical metres it is in — and ends with a scanner you can test on real text, including on itself.

What this page is not. Chandas — metrics — is a separate vedāṅga from the Aṣṭādhyāyī, codified by Piṅgala and later by the वृत्तरत्नाकरः, not by Pāṇini. This project's corpus (corpus.py) covers sound, sandhi, declension and the dhātupāṭha — it has no chandas layer, so the gaṇa formulas and yati positions below are standard classical prosody, not a citation into this site's own sūtra text. What is pulled mechanically, and checked, is every worked example: each is a verse you may already know — from the Bhagavad-gītā for the śloka and the triṣṭubh metres, from the Stotramālā for the rest — taken from this site's own texts and checked at build time to scan cleanly. The scanner's accuracy is measured separately, against the Pañcatantra, the one text here whose editor labelled the metre of every verse.
लघु गुरु

The one skill everything else rests on

by eye

A syllable — strictly an अक्षर, one vowel with whatever consonants cling to it — is गुरु (heavy, counted as two morae) under exactly three conditions, and लघु (light, one mora) otherwise. Check them in this order.

दीर्घेRule 1 — the vowel is long

आ ई ऊ ॠ ॡ are the long partners of अ इ उ ऋ ऌ, and ए ऐ ओ औ — the four grammar calls the diphthongs — are treated as long unconditionally; Sanskrit prosody does not recognise a "short ए". Any syllable built on one of these nine vowels is गुरु no matter what follows it.

संयोगेRule 2 — a conjunct follows

A short vowel is still गुरु if two or more consonants stand between it and the next vowel — a संयोगः. One consonant is not enough: a single consonant is read as the onset of the following syllable and leaves the vowel before it untouched. This is the rule that surprises people, because it means the weight of a syllable can depend on the word standing next to it, not just its own spelling — and it works straight across a word boundary, exactly as it works inside one word.

अनुस्वार-विसर्गेRule 3 — anusvāra or visarga follows

A short vowel carrying ं or ः is गुरु, because both close the syllable exactly as a consonant would — they are, in origin, exactly that: a nasal or a sibilant reduced to a mark.

A fourth thing, which is a licence rather than a rule. The last syllable of every metrical pāda is always counted गुरु, whatever it actually is — because a pause follows it, and a pause closes a syllable the way a consonant does. This applies at every pāda boundary, including one in the middle of a printed line (a śloka's two lines are four pādas), and the scanner below applies it exactly that way.

Three of these, worked from real text

Not a made-up sentence — the opening pāda of Gītā 2.47, कर्मण्येवाधिकारस्ते, scanned mechanically below (the anuṣṭubh entry further down scans the whole verse). Hover a syllable, or read the title text, for the reason.

Visarga behaves exactly like a consonant cluster — it closes the syllable it sits on — and a real संयोग a few syllables later does the same to a short vowel with nothing else unusual about it. The first pāda of Gītā 2.48:

And anusvāra, in a word that also carries a conjunct — two different rules, one syllable each, in "नित्यं" (Gītā 2.21, वेदाविनाशिनं नित्यं):

गणाः

Eight syllables read as one unit

यमाताराजभानसलगम्

Once a line is scanned into a string of लघु and गुरु, nobody reads it three syllables at a time in isolation — Sanskrit prosody names eight possible three-syllable patterns and calls each a गण, and every fixed metre below is stated as a short sequence of these, not as thirty-odd individual syllables.

The traditional mnemonic for the eight is one word: — and its own construction is the best-kept secret in the subject. Scan the mnemonic itself, and its ten syllables, taken three at a time, spell out all eight gaṇas in order — the word teaches itself.

Read the table below the same way: syllables 1–3 give य, syllables 2–4 give म, syllables 3–5 give त, sliding one syllable at a time through all eight — and the last two syllables, ल and गं, are not a gaṇa at all but the two single weights every formula below also needs on their own. They do a second job as well, and it is the more remarkable one: ल गं scan ⏑ –, exactly like the first two syllables य मा. The word is a circle written out as a line — the next section says what that circle is.

गणःअक्षराणिweightsस्मरणम्
B(2, 3)

A circle of eight syllables

de Bruijn cycle

The trick inside यमाताराजभानसलगं has a name in modern mathematics. The word is a de Bruijn sequence — precisely, the binary de Bruijn sequence of order 3, written B(2, 3) — and no shorter string could hold all eight gaṇas.

A de Bruijn sequence of order n over an alphabet of k symbols is a cyclic string in which every possible word of length n appears exactly once as a run of neighbours. Here the alphabet is the two weights (k = 2: लघु and गुरु) and the words are the gaṇas (n = 3), so there are 2³ = 8 words to fit in. A ring of eight syllables has exactly eight places where a window can start, so eight is the least it could possibly take: no syllable is wasted, and every new syllable makes a new gaṇa. Cut the ring open to write it as a line, and the two windows that ran across the cut need the first n − 1 = 2 syllables written again at the end — 8 + 2 = 10 syllables, exactly the length of the mnemonic. Those two extra syllables are ल गं. That they also name लघु and गुरु is a bonus the composer added on top.

Write लघु as 0 and गुरु as 1 and the word becomes a ten-digit binary string. The rows below are read off the scanner above, not typed:

The final syllable is गुरु however the word is spelt — …सलगम्, …सलगं or …सलगाम् all close it, with the म् or the anusvāra (rule 3) or with a long vowel (rule 1) — so every version in circulation gives the same ring.

Watch the window go round

Step the three-syllable window through its eight positions. On the ring it simply goes round. On the line it slides to the right, and for the last two positions it borrows ल गं, which scan exactly like य मा because they are य मा, met a second time. The right-hand picture is explained just below.

the ring — eight syllables, eight windows
the same walk as a graph — places are pairs, roads are gaṇas

Three other names for the same object

de Bruijn grapha walk that uses every road once

Take the four possible pairs of weights — ⏑⏑, ⏑–, –⏑, –– — as four places, and let each gaṇa be a one-way road from its first two weights to its last two: य = ⏑ – – runs from ⏑– to ––, म = – – – runs from –– back to ––. That gives eight roads between four places, the right-hand picture above. Reciting the mnemonic is a walk that travels every road exactly once and ends where it began: an Eulerian circuit. Turn the picture inside out — the eight gaṇas as the places, a road wherever one gaṇa can follow another by a one-syllable shift (य → म: ⏑ – – → – – –) — and the same word is a Hamiltonian cycle, visiting every gaṇa exactly once. Both pictures are called de Bruijn graphs, of order 2 and order 3.

shift registera three-slot machine that writes the word

Keep the last three syllables in three slots. At each step compute the next syllable from them, push it in, and let the oldest fall out. Given the right rule, this machine — a feedback shift register — writes the mnemonic round and round forever. The simplest rules are linear: add up some of the three slots and keep only odd or even (XOR). Your browser has just tried all seven such rules against the word itself; the best one is shown here, step by step:

गणःslotsnext in the wordlinear rule

universal cyclethe general idea

A ring that lists every member of some family exactly once, each member a window onto the next, is called a universal cycle (Chung, Diaconis and Graham, 1992). De Bruijn sequences are the case where the family is "all words of a fixed length"; the same question is asked of permutations, subsets and partitions.

Why "code" is not quite the right word. The mnemonic is sometimes called a code. A code, strictly, pairs each message with its own codeword, each standing alone. Here nothing stands alone: the eight "codewords" overlap as much as they possibly can, each sharing two syllables with the next. The word is an enumeration of all eight gaṇas, packed as tightly as mathematics allows.

Only two such rings exist

window nwords 2nring length as a linerings foundformula 22n−1−n

How old is it?

Nobody knows, and it is worth being exact about that. The mnemonic is attested in print by 1869, in C. P. Brown's Sanskrit Prosody and Numerical Symbols Explained, where Brown calls it an ancient line and ascribes it to Pāṇini. Nothing supports the ascription. It is not a sūtra of the Aṣṭādhyāyī — — and it is not in Piṅgala's Chandaḥśāstra either, though Piṅgala names the eight gaṇas by these same eight letters. Sherman Stein brought it to mathematicians as a "memory wheel" in the 1960s and dated it to about 1000 CE; Subhash Kak, answering a query from Donald Knuth in 2000, found no textual basis for that date and could trace the word no earlier than Brown. He left the question open, and it is still open.

Even 1869 is early. It is a quarter of a century before Camille Flye Sainte-Marie counted such sequences in 1894, and three-quarters of one before N. G. de Bruijn's 1946 paper gave them his name. Knuth takes it up in the history section of The Art of Computer Programming (vol. 4A, §7.2.1.7), and accounts of the subject now open with it as the earliest known example of a de Bruijn cycle. That it is centuries older, handed down orally like so much else, is entirely possible. No text yet shows it.

The same object today

The property that makes the mnemonic work — any window of n neighbours tells you exactly where you are — is what engineers need whenever a position must be read from a small local patch:

  • Absolute position encoders. One track of marks round a shaft or along a rail, arranged so that every window of n marks is different: a sensor that sees n neighbouring marks knows the absolute position at once, with no need to count from a home point.
  • Structured-light 3D scanning. A projector throws coloured stripes in a de Bruijn order, so a camera can identify each stripe from its neighbours and triangulate depth from a single image.
  • Camera pens. Paper printed with a faint dot pattern in which every small square window is unique — a two-dimensional cousin, the de Bruijn torus or array — lets a pen with a tiny camera know where on the page it is writing.
  • Genome assembly. DNA is read in short overlapping fragments; assemblers stitch them back together by finding an Eulerian path in a de Bruijn graph — the picture above, with A, C, G and T in place of लघु and गुरु.

So the gaṇa mnemonic a student learns on the first day of chandas and the stripe pattern of a depth scanner are, quite literally, the same object.

Two ways to count a line

वर्णवृत्तम् · मात्राछन्दः

Every metre below belongs to one of two families, and they are counted by completely different units.

वर्णवृत्तम्Counted by syllable

Every pāda has a fixed number of syllables, and — in a समवृत्त like शार्दूलविक्रीडित or स्रग्धरा — every one of those positions has a fixed weight, stated as a run of gaṇas. Get one syllable wrong and the line no longer scans as that metre at all. Almost everything on this page, including अनुष्टुभ् in its own looser way, is वर्णवृत्त.

मात्राछन्दःCounted by mora

The syllable count is free; what is fixed is the total मात्रा — light=1, heavy=2 — in each half of the verse. Two short syllables and one long one are interchangeable, because both total two morae. The one मात्राछन्द worth knowing well is आर्या: enormously common in didactic and gnomic verse (72 of the 1,071 scannable Pañcatantra verses below are आर्या — the second most frequent metre in the whole text, after अनुष्टुभ् itself), and built on a single, checkable fact: its first half totals 30 morae, its second half 27.

The metres worth knowing

Thirteen metres, each with its formula, its yati (the compulsory pause inside a pāda — always at a word-break, never mid-word), how often it actually occurs in the Pañcatantra (the labelled text the scanner is tested on below), and one verse you may already know by heart — from the Gītā for the śloka and the triṣṭubh family, from the Stotramālā for the rest. Each is checked at build time to scan as its metre on every pāda; a stotra verse must also carry that metre in the Stotramālā's own annotation.

अनुष्टुभ् — the one that is not a fixed formula

By far the commonest metre in classical Sanskrit — 846 of the 1,071 labelled verses below, four out of every five — and the one every other book on this site quotes without comment, so it earns its own explanation. Four pādas of eight syllables is necessary but nowhere near sufficient: positions 1–4 and 8 are close to free (the small set of exceptions are called विपुला and are not covered here). What is actually fixed, in the standard पथ्या form, is just three positions per pāda:

त्रिष्टुभ् — eleven syllables, three metres

त्रिष्टुभ् is not itself one pattern; it is the name for the class of metres with an eleven-syllable pāda. Two of its members are true समवृत्त — every pāda identical — and differ from each other in exactly one syllable, the very first:

उपजाति is what happens when a poet mixes the two. Take some pādas in इन्द्रवज्रा's pattern and others in उपेन्द्रवज्रा's, inside the same stanza, and the result is called उपजाति rather than either name alone — the single commonest त्रिष्टुभ्-class metre in the Pañcatantra by a wide margin, and in the Gītā too ().

The rest — one formula each

Every metre below is a समवृत्त: state the gaṇa sequence for one pāda and all four are identical.

आर्या and its family — counted, not patterned

Three verses share one skeleton and differ only in how the mora budget is split between the two halves of the verse. The आर्या example is from Śaṅkara's Viṣṇuṣaṭpadī; the other two stay with the Pañcatantra, because neither the Gītā nor the Stotramālā has a genuine उद्गीति or उपगीति — every verse there that the scanner reads as one turns out to be a śloka whose halves happen to total 27 mātrās, and the Stotramālā's own annotation calls each of them अनुष्टुप्.

Every metre, at a glance

छन्दःप्रति-पादसूत्रम्यतिः पञ्चतन्त्रे

Scan a verse

अभ्यासः

Paste any Devanāgarī verse, or pick one below. Every syllable lights लघु or गुरु by the three rules above, the gaṇas assemble underneath in triples, and the metre is named — or honestly reported as unmatched, with the closest candidate and exactly where it stops matching.

Tested against the whole Pañcatantra

honesty check

Running now, in your browser, over every one of the labelled verses above — the same code that just scanned your verse.

छन्दःपञ्चतन्त्रेscanner agrees%

Where this comes from

Coverage
Different sources, used for different things. The rules — the three conditions for गुरु, the eight gaṇas, the yati and gaṇa formula for each metre — are standard classical prosody (the Piṅgala–Vṛttaratnākara tradition), because this project's corpus has no chandas layer to pull them from; that is stated here rather than left implicit. The worked examples are pulled by reference from this site's own texts — the Bhagavad-gītā from the Prasthānatrayī corpus (English from its translation layer) and the Stotramālā (text and English from its reader) — and the build refuses any that does not scan cleanly. The de Bruijn facts are computed in your browser from the scanned mnemonic; the history rests on C. P. Brown, Sanskrit Prosody and Numerical Symbols Explained (London: Trübner, 1869), p. 28; S. Kak, "Yamātārājabhānasalagām: an interesting combinatoric sūtra", Indian Journal of History of Science 35 (2000), 123–127; S. Stein, Mathematics: The Man-Made Universe (1969); and D. E. Knuth, The Art of Computer Programming, vol. 4A, §7.2.1.7. The per-metre counts and the scanner's accuracy figure are measured mechanically against ss-data/texts/pancatantram/pancatantram.json, 1,098 verses of which 1,071 carry the editor's own metre label across 20 distinct metres. This page teaches the 13 that between them account for % of that text; the remainder — हरिणी, द्रुतविलम्बितम्, शालिनी, वियोगिनी, प्रमिताक्षरा, रथोद्धता — occur 10 times in total and are not covered, and the scanner correctly leaves every one of them unmatched rather than guessing.

Check yourself

अभ्यासः

Eight questions: six on scanning by eye and naming what you scanned, two on the mnemonic's hidden structure.