भारत · ग्रहगणित
स्थान उज्जयिनी Ujjayinī · change it on a tool⌕ search the कोश ⌘Kप्रहर — · —:—:—ours, from sunriseउज्जयिनी —:—:—UTC + λ/15 h, λ = 75.7682° E (D13)IST Error −26.9 minlocal mean time − IST = 4λ − 330 min (K12)engine 3f94072the site ↗

yantra/patha/samskara.js

संस्कार: correcting the text's OWN numbers from recorded observations, the way the tradition did — the

1255 lines · 0 exports

लेख · the header

The header, as the file states it

samskara.js — संस्कार: correcting the text's OWN numbers from recorded observations, the way the tradition did — the paramparā's own records first (the dated eclipses of Parameśvara and Nīlakaṇṭha, corpus/parampara/registry.json → corpus/jyotirmimamsa/readings.json), the owner's own when he gives them — by bīja (a small change to a revolution number) and dhruva (a new mean place at a declared epoch) — and never by borrowing a number. Every observation enters through the text's own forward model; every correction is a change to one of the text's own parameters; nothing is computed, seeded or refereed by any modern ephemeris or table. THE PARAMETERS (each switchable by name; the fit moves only those named in opts.params): <body>.rev revolutions in a yuga: sun 4,320,000, moon 57,753,336, moonApogee 488,203, node 232,238 (westward) [text: SS 1.29-1.33 via sphuta.js]; or Āryabhaṭa's 488,219 / 232,226 [parahita-madhyama.js] with canon "aryabhata". A change δn is counted from the declared epoch: Δλ = δn × (t − epoch) ÷ civil days of the yuga × 360°, so it does not jump the Kali-0 place (with 1811/4 yugas elapsed a whole revolution counted from creation turns the Kali-0 place by ¾ of a circle; the whole-number form below restores it). <body>.epoch the mean place at the declared epoch, arcminutes (the dhruva; reported at Kali 0 too). Also sunApogee.epoch. sun|moon.paridhi.even|odd the manda epicycles at the even and odd ends, 14 / 13°40′ and 32 / 31°40′ [SS 2.34-2.38]. moon.latitude the greatest latitude, 270′ [SS 1.68]. ayanamsha.phase | .amplitude | .rate the libration arc's phase (0 at Kali 0), the greatest ayanāṃśa (27° = ³⁄₁₀ of 90°) and the librations in a yuga (600) [SS 3.9-3.10 via sphuta.js]. <planet>.rev | .epoch | .mandocca.epoch | .manda.even|odd | .sighra.even|odd the five star-planets [ss-graha.js] (for Mercury and Venus .rev is the śīghrocca's, the mean planet being the mean Sun, SS 1.29). THE OBSERVATION EQUATIONS (residual = observed − the text's prediction, each in the instrument's own unit): chaya a noon shadow, aṅgula/vyaṅgula: the text's noon shadow of its sāyana Sun (SS 3.20b-3.22a, ss-chaya.js), signed north +; σ in vyaṅgula. The shadow is compared, not inverted: near a solstice it hardly moves, and the equation says so by itself. surya-sayana a shadow-Sun already reduced (ss-chaya.js reduce → chāyārka): sāyana true Sun, arcmin. surya, candra the sidereal true Sun or Moon, arcmin (candra: a Moon–yogatārā timing; σ may be given in vināḍī of time; polar: true compares the Moon's place on its circle through the dhruva, as SS 8.14-8.15 judge a conjunction). grahana a lunar eclipse, any of its sparśa, madhya and mokṣa timed: each moment (SS 4.7-4.17 on the model's own places: middle at the true opposition, discs 4.1-4.5 and half-durations 4.12-4.13 from ss-grahana.js, the latitude recomputed at the contact) − observed, in vināḍī; plus the inequality "an eclipse is possible" (4.11). The middle carries Moon − Sun; the half-duration carries the latitude, so the node. grahana-abhava a pūrṇimā with no eclipse seen: |latitude| ≥ the half-sum (4.11), an inequality. darshana the first evening the crescent was seen, day N: kālāṃśa(N) ≥ 12 and kālāṃśa(N − 1) < 12 (SS 10.1, 9.5, each body on its own horizon as ss-udaya.js/ss-drishya.js; the text's sunset): two inequalities; or one evening with seen: true | false, one inequality. graha a planet's sidereal longitude, arcmin (the four operations of SS 2.43-2.45, ss-graha.js). madhyama a mean place (a karaṇa's dhruva, or the mean Sun of SS 3.20a), arcmin — the only kind the "aryabhata" canon takes, since its true places need epicycles no local edition attests. ayanamsha an ayanāṃśa found from star transits, arcmin. Partial derivatives are central differences on the text's own model; the time-to-contact root finding is inside them. Inequalities enter as one-sided rows (active only while violated), the exterior form of a constraint. THE SOLVER: weighted least squares by Gauss-Newton, in coordinates scaled by each parameter's SCALE (the largest correction worth considering — an engineering choice, not a text number; opts.scales overrides). THE IDENTIFIABILITY FREEZE, before the first step: a parameter that no row depends on is frozen ("unseen"); then the scaled normal matrix (JᵀWJ) is decomposed by Jacobi rotations (no library), and while its weakest direction is determined worse than one scale unit (σ > opts.freezeAbove, default 1) or its condition exceeds opts.conditionMax (1e12), the parameter carrying the largest share of that direction is frozen — held at the text's value — as "degenerate" when others share the direction (the data see only a combination) or "weak" when it stands alone. Every frozen parameter is reported with its direction, its σ and the reason in words. Uncertainties are the formal σ from the stated instrument resolutions. THE TWO BĪJA FORMS (the owner's decision §7.9 recommends (a) for his own corrections, (b) only for replaying): (a) whole-number Δbhagaṇa: each fitted δn is rounded to an integer, the epochs are re-fitted with the rates held there, and the corrected place is frac(R′·(Q + days ÷ Y)) + D with R′ = R + ΔR an integer and D a whole number of vikalās — an exact residue that returns to itself after a yuga: the madhyama wheel stays closed, and so does the whole chain of SS 1.34-1.39 (risings, lunar months, adhimāsa, tithis, tithikṣaya stay integers). (b) the Śakābda form, as parahita-madhyama.js represents the Parahita rule: minutes SUBTRACTED = (mul ÷ div) × (Śaka years − zero year), with mul/div the simplest fraction within the rate's σ. It reproduces the paramparā's rule exactly when the data are the paramparā's places, and it opens the wheel unless 200·mul/div is a whole number. THE MEMORY LAYER: the corrected integers as Kaṭapayādi words (katapayadi.js encodeInteger, decoded back as a check), and as bhūtasaṅkhyā words from a lexicon the caller builds from the text's own verse words (lexiconFromVerses), so no word here is invented. Tags, from each record's `source` (owner 2026-10-08: "use those observations as data"): a result is "[synthetic]" whenever any record says synthetic (and every synthetic record must name its generator); "[paramparā]" when every record is a historical one (source "parampara": the ancestors' recorded sightings, each with its locus); "[measured]" only when every record is the owner's (source "owner", or no source — the ledger's records); "[paramparā+measured]" when both are pooled, which happens only on request (opts.pool: true) — by default the two are never mixed. The model fitted is the text's, not the sky's: the corrections describe how the recorded sky differs from the text within the text's own form of motion. THE DEFAULT PATH (owner, 2026-10-07: "use everything that aligns with 100% accuracy"): `correct(observations)` runs `robust` — the least-squares fit, with any record beyond 4σ set aside one at a time and named — which uses every record as the fit does and, like the median, is not moved by one wild record. `method: "median"` runs `dhruvaMedian` — the median residual of each body at a declared epoch, in whole kalā, as Parameśvara corrected his dhruvas; and a rate only from two epochs at least ten years apart, as a whole-number Δbhagaṇa or a Śakābda rate from a zero year. The least-squares fit above is `correct(observations, { method: "lsq" })` (or `samskara`). A median does not move for one wild record; the fit uses every kind of record (contacts, crescents, misses) and reports what the data cannot see. THE OWNER'S LEDGER: `fromLedger(file, { catalogue })` reads a certified vedha-lekha/1 ledger (vedha-lekha.js reduce): the shadows through `fromVedha`, each lunar eclipse's contacts as one `grahana`, each evening crescent as `darshana` with `seen`, and each Moon–junction-star timing as a polar `candra` at the star's dhruvaka (8.14-8.15). Star transits set the site and the clock (tier a) and enter no motion; morning crescents are listed as not used. Each solar eclipse's contacts enter as one `grahana-surya` (council KH-03): the text's own ch.5 parallax held, the conjunction and the latitude carried on the model; and `grahana-drishta` takes an eclipse seen or not seen, untimed, against 6.13's limit. Browser: window.Samskara (needs Sphuta, ParahitaMadhyama, Katapayadi, KalaDvara, SSUdaya, SSChaya, SSGraha, SSGrahana, SSDrishya, VedhaLekha); node: module.exports.
आवश्यक · requires

What it loads

required by
निर्यात · exports

What it exports

पाठ · the verses it cites

SS verses named in the header

  • SS 1.29verse
    yuge sūryajñaśukrāṇāṃ khacatuṣkaradārṇavāḥ । kujārkiguruśīghrāṇāṃ bhagaṇāḥ pūrvayāyinām ।।
  • SS 2.34verse
    ravermandaparidhyaṃśā manavaḥ śītago radāḥ ।
  • SS 1.68verse
    bhacakraliptāśītyaṃśaṃ paramaṃ dakṣiṇottaram । vikṣipyate svapātena svakrāntyantādanuṣṇaguḥ ।।
  • SS 3.9verse
    triṃśatkṛtyo yuge bhānāṃ cakraṃ prākparilambate । tadguṇādbhūdinairbhaktāddyugaṇādyadavāpyate ।।
  • SS 3.20verse
    tanmāndaṃ asakṛdvāmaṃ phalaṃ madhyo divākaraḥ । svākṣārkāpakramayutirdiksāmye antaraṃ anyathā ।।
  • SS 8.14verse
    grahavaddyuniśe bhānāṃ kuryāddṛkkarma pūrvavat । grahamelakavaccheṣaṃ grahabhuktyā dināni ca ।।
  • SS 4.7verse
    tulyau rāśyādibhiḥ syātāṃ amāvāsyāntakālikau । sūryendū paurṇamāsyante bhārdhe bhāgādikau samau ।।
  • SS 10.1verse
    udayāstavidhiḥ prāgvatkartavyaḥ śītagorapi । bhāgairdvādaśabhiḥ paścāddṛśyaḥ prāgyātyadṛśyatām ।।
  • SS 2.43verse
    māndaṃ karmaikaṃ arkendorbhaumādīnāṃ athocyate । śaighryaṃ māndaṃ punarmāndaṃ śaighryaṃ catvāryanukramāt ।।
  • SS 1.34verse
    bhānāṃ aṣṭākṣivasvadritridvidvyaṣṭaśarendavaḥ । bhodayā bhagaṇaiḥ svaiḥ svairūnāḥ svasvodayā yuge ।।
नलिका · channels

The channels it runs in

not on a channel
कार्य · the functions

Every function, what it calls, who calls it

67 top-level functions read from the source; the doc line is the comment above each; calls and callers are resolved across the registry’s modules by name. Line numbers are the file’s at engine 3f94072.

tq(T)lines 95–95
calls nothing in the registry
mod(a, m)lines 97–97
calls nothing in the registry
bmod(a, m)lines 99–99
calls nothing in the registry
big(x)lines 100–100
calls nothing in the registry
fracDeg(num, den)lines 102–102
calls nothing in the registry
called by baseOf
gcdB(a, b)lines 105–105

── exact rationals {num, den} ─────────────────────────────────────────────────────────────────────

calls nothing in the registry
called by rat
toRat(x)lines 107–107
ratNum({ num, den })lines 108–108
calls nothing in the registry
called by baseOf, daysOf, bijaForms
ratEq(a, b)lines 109–109exported
calls nothing in the registry
called by nothing in the registry
canonOf(name)lines 124–124
calls nothing in the registry
def(name, spec)lines 128–128
calls nothing in the registry
called by nothing in the registry

The text's value of a parameter (the epochs: its mean place at day `t`, degrees).

calls nothing in the registry
called by nothing in the registry
baseOf(canon)lines 173–191

Exact mean places of the canon at day t (cached; the BigInt residues of sphuta.js / parahita-madhyama.js).

called by contextOf
planetBaseOf()lines 192–195
calls nothing in the registry
called by contextOf

Four operations of SS 2.43-2.44 (ss-graha.js fourSteps) with the epicycle pairs given.

calls mod
called by buildModel
buildModel(ctx, x)lines 208–255exported

The model at parameter changes x ({ name: δ }). ctx = { canon, epoch, base, planetBase }.

model(deltas, opts = {})lines 264–264exported

The model at the text's values moved by `deltas`, about a declared epoch (Kali day). opts.ayanamsha: a tier's own ayanāṃśa rule (a function of t, degrees) in place of the text's libration — ss-tier.js gives the Kerala tier's.

called by nothing in the registry
syzygy(M, t0, target)lines 268–278exported

The instant near t0 at which Moon − Sun = target degrees (Newton on the model's own places).

moonAt(M, lambda, t0)lines 280–289exported

The instant near t0 at which the Moon's sidereal longitude is `lambda`.

called by synthesize
lunarEclipse(M, t0)lines 293–326exported

The text's lunar eclipse (SS 4) on the model: middle at the true opposition near t0 (4.7-4.8, 4.16), discs from the model's true motions (4.1-4.5, ss-grahana discsFrom), possibility (4.11), half-durations with the latitude at each contact recomputed until fixed (4.12-4.15, ss-grahana ardhas). Times in days since the Kali epoch.

palabhaOfSite(site)lines 327–327
calls nothing in the registry
kalamsaWest(M, t, palabha)lines 330–334exported

SS 10.1 with 9.5, each body on its own horizon (ss-udaya.js, the default of ss-drishya.js): the signed kālāṃśa of the Moon after the Sun at the western horizon at instant t (a sunset), on the model's places and ayanāṃśa.

sunsetOf(N, site)lines 336–336exported

The text's sunset of civil day N at the site (ss-drishya.js sunEvent): the observer's own sunset, held fixed.

calls nothing in the registry
textModelOf(M)lines 345–345
called by solarOnModel
solarOnModel(M, E0)lines 346–418
called by equationOf
calls nothing in the registry
called by equationOf
sourceOf(o)lines 432–432
calls nothing in the registry
called by nothing in the registry
tagOf(observations)lines 434–438exported

The tag of a set of records (see the header): synthetic overrides; then paramparā, owner, or both pooled.

calls nothing in the registry
called by nothing in the registry

The paramparā's records and the owner's are fitted together only when the caller asks (opts.pool: true).

calls nothing in the registry
called by nothing in the registry
only(o, keys, where)lines 462–464
calls nothing in the registry
daysOf(v, where, canonName)lines 467–477exported

A time: days since the Kali epoch, or { kali, kapala: {ghati, vinadi, prana}, calibration } read by kala-dvara.js (a kapāla counts nāḍīs of the turn unless calibration is "savana"; counted from the Kali day's origin).

calls only, ratNum, rat
called by equationOf
shadowAngula(v, where)lines 478–478
calls nothing in the registry
called by equationOf
calls nothing in the registry
called by equationOf

One observation → { id, kind, t, rows: [{ what, unit, observed, sigma, arc, ineq, margin }], predict(M) → values }.

jacobiEigen(A)lines 614–636exported

Eigen-decomposition of a real symmetric matrix by cyclic Jacobi rotations (no library, no trigonometry: the rotation is t = sgn θ ÷ (|θ| + √(θ² + 1)), c = 1/√(t² + 1), s = t·c). Returns eigenvalues ascending with unit eigenvectors.

calls nothing in the registry
called by freezeAnalysis
normalOf(cols)lines 637–637
calls nothing in the registry
called by freezeAnalysis
flatten(eqs)lines 640–644

── the fit ─────────────────────────────────────────────────────────────────────────────────────────

calls nothing in the registry
called by nothing in the registry
predictAll(eqs, M)lines 645–645
calls nothing in the registry
called by jacobianCols

Normalized residuals: equalities (observed − predicted)/σ; an inequality only while violated, (margin − g)/σ.

called by nothing in the registry
isActive(row, pred)lines 654–654
calls nothing in the registry
called by nothing in the registry
called by nothing in the registry
chi2Of(res)lines 662–662
calls nothing in the registry
called by summarize

The identifiability freeze on the scaled Jacobian columns (rows that carry information only).

called by nothing in the registry
equationsOf(observations, canon)lines 700–710exported

Observation records → equations, after checking each (fields, synthetic → generator, canon).

called by nothing in the registry
called by nothing in the registry
samskara(observations, opts = {})lines 728–728exported

Saṃskāra: fit the named parameters of the text to the observations. See the header for the rules. opts: canon ("surya" | "aryabhata"), params (names), epoch (Kali day; default the observations' mean day, rounded), fixed ({ name: δ } held, not fitted), freeze (names held at the text), freezeFirst (preference when a direction is shared), scales ({ name: scale }), freezeAbove (1), conditionMax (1e12)

calls nothing in the registry
called by bijaForms
simplestBetween(lo, hi, depth = 0)lines 823–832exported

Simplest rational p/q (smallest q) in [lo, hi] — the Stern-Brocot descent; [BigInt p, BigInt q].

calls nothing in the registry
called by bijaForms

The corrected mean place in the whole-number form, EXACT: frac(±R′·(Q + days ÷ Y)), days = τ·S/(N·R) on the turn clock, turned to arcseconds, plus the dhruva D (whole arcseconds, or {num, den}); a rational {num, den} in [0, 1,296,000). Retrograde for the node.

sakabdaMinutes(form, spandas)lines 842–846exported

The Śakābda form, EXACT, in parahita-madhyama.js's convention: minutes to SUBTRACT = (mul ÷ div) × (Śaka years elapsed − zeroYear), Śaka years = days × Sun revolutions ÷ Y − 3179, days = τ·S/(N·R). Returns {num, den}.

sakabdaArcsec(form, body, spandas)lines 848–853exported

The place under a Śakābda form: the canon's own mean place less the minutes, exact arcseconds in [0, 1,296,000).

called by nothing in the registry

SS 1.34-1.39's chain for corrected Sun and Moon revolutions. keep "risings" (default, owner 2026-10-07): the turn is the clock, so the star-risings of the yuga stay the text's and a Sun bīja changes the civil days (risings − Sun); keep "civil": the civil days stay and the risings change. With the text's own revolutions both are the text's chain.

calls big
called by bijaForms
katapayadiOf(n)lines 866–871exported

A non-negative integer as a Kaṭapayādi word (first syllable the units, katapayadi.js), with its decoding checked.

calls big
called by bijaForms
lexiconFromVerses(numbers)lines 874–883exported

A digit → words lexicon from the text's own numeral words (corpus/surya-siddhanta/numbers.json, passed in): every hyphen-separated word whose value is a single digit, most frequent first. Nothing is added that the verses lack.

calls nothing in the registry
called by nothing in the registry
bhutasankhya(n, lexicon)lines 885–889exported

bhūtasaṅkhyā: an integer as word-numerals, first word the units (as the verses are read); null if a digit has no word.

calls big
called by nothing in the registry

Scan one parameter (others at `deltas`) and return the intervals where every inequality row holds.

calls nothing in the registry
called by nothing in the registry

A certified vedha-lekha/1 ledger → saṃskāra observations, and what was not used and why. opts: catalogue (the yogatara corpus, for the stars' dhruvakas) or stars; allowSynthetic; sigmaVinadi (contacts, 1), sigmaYogaVinadi (2); anything else is passed to vedha-lekha.js reduce.

calls nothing in the registry
called by nothing in the registry
median(a)lines 1034–1034

── the default path: the median dhruva, and a rate from two epochs (design §4.5) ─────────────────────

calls nothing in the registry
called by nothing in the registry
dhruvaMedian(observations, opts = {})lines 1042–1042exported

The median path. Each record gives a residual (the sky − the text) in arcminutes of one body: a true or mean Sun, Moon or planet, an ayanāṃśa; a noon shadow inverted to the shadow-Sun (3.14b-3.19; not within 15° of a solstice, where the shadow hardly moves); a lunar eclipse's middle (or the mean of its sparśa and mokṣa) as Moon − Sun, by the motions (JM §14). The true-place residual is taken as th

calls nothing in the registry
called by nothing in the registry
robust(observations, opts = {})lines 1110–1110exported

The robust fit: the least-squares fit, then the one record whose residual is worst beyond opts.reject σ (4) is set aside and the fit run again, until no record is beyond it; every record set aside is reported with its residual and round. One at a time, worst first, because a gross error can drag good records out with it. The bīja forms are made from the final fit.

calls nothing in the registry
called by nothing in the registry
correct(observations, opts = {})lines 1129–1129exported

The correction loop's step 4 (design §4.5). method "robust" (default, owner 2026-10-07: every record used, a wild one set aside and named), "median" (the median dhruva and the ten-year rate, §4.5's first form) or "lsq" (the fit alone).

calls nothing in the registry
called by nothing in the registry

A vedha-chaya/1 file (ss-chaya.js validate/reduce) → chaya observations: each noon shadow with the file's place.

calls nothing in the registry
called by nothing in the registry
prng(seed)lines 1150–1155exported

A seeded generator (mulberry32) with normal deviates by Marsaglia's polar method.

calls nothing in the registry
called by synthesize
synthesize(spec)lines 1165–1242exported

Synthetic records from the text's model with the parameters moved by `deltas` — labelled synthetic, with their generator. spec: { epoch, deltas, seed, canon, label, shadows: { site, days: [Kali days], sigmaVyangula, round: true }, noon shadows read to the vyaṅgula eclipses: { from, to, sigmaVinadi, site, nightOnly, read, misses }, lunar eclipse contacts on a kapāla of the turn, read to the prāṇa (

called by nothing in the registry