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, as the file states it
What it loads
- yantra/patha/sphuta.jsmodule
- yantra/patha/parahita-madhyama.jsmodule
- yantra/patha/katapayadi.jsmodule
- yantra/patha/kala-dvara.jsmodule
- yantra/patha/ss-udaya.jsmodule
- yantra/patha/ss-chaya.jsmodule
- yantra/patha/ss-graha.jsmodule
- yantra/patha/ss-grahana.jsmodule
- yantra/patha/ss-drishya.jsmodule
- yantra/patha/vedha-lekha.jsmodule
What it exports
SS verses named in the header
- SS 1.29verseyuge sūryajñaśukrāṇāṃ khacatuṣkaradārṇavāḥ । kujārkiguruśīghrāṇāṃ bhagaṇāḥ pūrvayāyinām ।।
- SS 2.34verseravermandaparidhyaṃśā manavaḥ śītago radāḥ ।
- SS 1.68versebhacakraliptāśītyaṃśaṃ paramaṃ dakṣiṇottaram । vikṣipyate svapātena svakrāntyantādanuṣṇaguḥ ।।
- SS 3.9versetriṃśatkṛtyo yuge bhānāṃ cakraṃ prākparilambate । tadguṇādbhūdinairbhaktāddyugaṇādyadavāpyate ।।
- SS 3.20versetanmāndaṃ asakṛdvāmaṃ phalaṃ madhyo divākaraḥ । svākṣārkāpakramayutirdiksāmye antaraṃ anyathā ।।
- SS 8.14versegrahavaddyuniśe bhānāṃ kuryāddṛkkarma pūrvavat । grahamelakavaccheṣaṃ grahabhuktyā dināni ca ।।
- SS 4.7versetulyau rāśyādibhiḥ syātāṃ amāvāsyāntakālikau । sūryendū paurṇamāsyante bhārdhe bhāgādikau samau ।।
- SS 10.1verseudayāstavidhiḥ prāgvatkartavyaḥ śītagorapi । bhāgairdvādaśabhiḥ paścāddṛśyaḥ prāgyātyadṛśyatām ।।
- SS 2.43versemāndaṃ karmaikaṃ arkendorbhaumādīnāṃ athocyate । śaighryaṃ māndaṃ punarmāndaṃ śaighryaṃ catvāryanukramāt ।।
- SS 1.34versebhānāṃ aṣṭākṣivasvadritridvidvyaṣṭaśarendavaḥ । bhodayā bhagaṇaiḥ svaiḥ svairūnāḥ svasvodayā yuge ।।
The channels it runs in
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.
── exact rationals {num, den} ─────────────────────────────────────────────────────────────────────
The text's value of a parameter (the epochs: its mean place at day `t`, degrees).
Exact mean places of the canon at day t (cached; the BigInt residues of sphuta.js / parahita-madhyama.js).
Four operations of SS 2.43-2.44 (ss-graha.js fourSteps) with the epicycle pairs given.
The model at parameter changes x ({ name: δ }). ctx = { canon, epoch, base, planetBase }.
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.
The instant near t0 at which Moon − Sun = target degrees (Newton on the model's own places).
The instant near t0 at which the Moon's sidereal longitude is `lambda`.
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.
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.
The text's sunset of civil day N at the site (ss-drishya.js sunEvent): the observer's own sunset, held fixed.
The tag of a set of records (see the header): synthetic overrides; then paramparā, owner, or both pooled.
The paramparā's records and the owner's are fitted together only when the caller asks (opts.pool: true).
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).
One observation → { id, kind, t, rows: [{ what, unit, observed, sigma, arc, ineq, margin }], predict(M) → values }.
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.
── the fit ─────────────────────────────────────────────────────────────────────────────────────────
Normalized residuals: equalities (observed − predicted)/σ; an inequality only while violated, (margin − g)/σ.
The identifiability freeze on the scaled Jacobian columns (rows that carry information only).
Observation records → equations, after checking each (fields, synthetic → generator, canon).
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)
Simplest rational p/q (smallest q) in [lo, hi] — the Stern-Brocot descent; [BigInt p, BigInt q].
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.
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}.
The place under a Śakābda form: the canon's own mean place less the minutes, exact arcseconds in [0, 1,296,000).
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.
A non-negative integer as a Kaṭapayādi word (first syllable the units, katapayadi.js), with its decoding checked.
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.
bhūtasaṅkhyā: an integer as word-numerals, first word the units (as the verses are read); null if a digit has no word.
exportedScan one parameter (others at `deltas`) and return the intervals where every inequality row holds.
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.
── the default path: the median dhruva, and a rate from two epochs (design §4.5) ─────────────────────
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
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.
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).
A vedha-chaya/1 file (ss-chaya.js validate/reduce) → chaya observations: each noon shadow with the file's place.
A seeded generator (mulberry32) with normal deviates by Marsaglia's polar method.
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 (