{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": "# Surya Siddhanta Rahasya\n## सूर्यसिद्धान्त रहस्यम् · Mathematical Astronomy (14 Adhikaras)\n**Format:** decoded chapter suite · **Scope:** Astronomical Treatise · 14 Chapters\n**Execution:** every code cell below was executed with Python 3.11.15 on 2026-10-07 by scripts/library/sync_library.py; the outputs are the real stdout of that run.\n\n*यह ऐतिहासिक ग्रन्थों पर आधारित पाठ और गणना है, चिकित्सा-परामर्श नहीं। · Text and computation about historical treatises — not medical advice.*\n\n---"
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": "## Chapter 1: मध्यमाधिकारः (Mean Motion & Mahayuga Calculus)\n**Scope:** `Verses 1.1 – 1.70 (70 श्लोक in the edition) · shown here: 1.20, 1.37` · **Reading:** `14 min study`\n\n### Overview\nEstablishes the fundamental chronological coordinate system of Vedic astronomy. Decodes the 4,320,000-year Mahayuga, the exact solar civil days per cycle (1,577,917,828 days), Ahargana day-count summation, and mean planetary velocity vectors.\n\n### Ślokas & anvaya\n> **इत्थं युगसहस्रेण भूतसंहारकारकः ।  \n> कल्पो ब्राह्मं अहः प्रोक्तं शर्वरी तस्य तावती ॥**\n>\n> *itthaṃ yugasahasreṇa bhūtasaṃhārakārakaḥ ।  \n> kalpo brāhmaṃ ahaḥ proktaṃ śarvarī tasya tāvatī ।।*\n>\n> **Meter:** सूर्य-सिद्धान्त 1.20\n>\n> **Source:** editions/surya-siddhanta-full-edition.html#v1-20 — Devanāgarī, IAST, padaccheda-anvaya and English rendering as printed in the edition (सूर्य-सिद्धान्त 1.20)\n\n- **इत्थम्**: इस प्रकार\n- **युग-सहस्रेण**: एक हजार युगों से\n- **भूत-संहार-कारकः**: भूतों/प्राणियों के संहार का हेतु\n- **कल्पः**: कल्प\n- **ब्राह्मम् अहः**: ब्रह्मा का दिन\n- **प्रोक्तम्**: कहा गया\n- **शर्वरी**: रात्रि\n- **तस्य**: उसकी\n- **तावती**: उतनी ही (समान माप की)\n\nThus a thousand yugas make the kalpa that brings about the dissolution of beings. That kalpa is called a day of Brahmā; his night is of equal length.\n\n> **वसुद्व्यष्टाद्रिरूपाङ्कसप्ताद्रितिथयो युगे ।  \n> चान्द्राः खाष्टखखव्योमखाग्निखर्तुनिशाकराः ॥**\n>\n> *vasudvyaṣṭādrirūpāṅkasaptādritithayo yuge ।  \n> cāndrāḥ khāṣṭakhakhavyomakhāgnikhartuniśākarāḥ ।।*\n>\n> **Meter:** सूर्य-सिद्धान्त 1.37\n>\n> **Source:** editions/surya-siddhanta-full-edition.html#v1-37 — Devanāgarī, IAST, padaccheda-anvaya and English rendering as printed in the edition (सूर्य-सिद्धान्त 1.37)\n\n- **वसुद्व्यष्टाद्रिरूपाङ्कसप्ताद्रितिथयः**: १,५७,७९,१७,८२८ सावन (वसु ८, द्वि २, अष्ट ८, अद्रि ७, रूप १, अङ्क ९, सप्त ७, अद्रि ७, तिथि १५)\n- **युगे**: महायुग में\n- **चान्द्राः**: चान्द्र दिन (तिथि-गण)\n- **खाष्टखखव्योमखाग्निखर्तुनिशाकराः**: १,६०,३०,००,०८० (ख ०, अष्ट ८, ख ०, ख ०, व्योम ०, ख ०, अग्नि ३, ख ०, ऋतु ६, निशाकर १)\n\nIn a yuga there are 1,577,917,828 civil (sāvana) days and 1,603,000,080 lunar days (tithis). These two tallies are the backbone of the yuga calendar arithmetic.\n\n### Formulation — Ahargana & Mean Planetary Longitude Equation\n$$\\bar{\\lambda}_{\\text{graha}} = \\left( \\frac{\\text{Ahargaṇa} \\times B_{\\text{graha}}}{1577917828} \\times 360^\\circ \\right) \\pmod{360^\\circ}$$\n\nExact rational multiplication before division eliminates 64-bit floating-point accumulation drift over 5,127+ years of Kaliyuga."
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": "def compute_madhyama(ahargana, bhagana, yuga_days=1577917828):\n    mean_rev = (ahargana * bhagana) / yuga_days\n    mean_deg = (mean_rev % 1.0) * 360.0\n    return round(mean_deg, 6)"
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [
    {
     "output_type": "stream",
     "name": "stdout",
     "text": "compute_madhyama(1865420, 4320000) → 42.903923\ncompute_madhyama(1865420, 57753336) → 70.821161\n"
    }
   ],
   "source": "print('compute_madhyama(1865420, 4320000)', \"→\", repr(compute_madhyama(1865420, 4320000)))\nprint('compute_madhyama(1865420, 57753336)', \"→\", repr(compute_madhyama(1865420, 57753336)))"
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": "**Recorded output (dataset `codeOutput`, verified against the run above):**\n```\nInput: Ahargana = 1,865,420 civil days since the Kaliyuga epoch\ncompute_madhyama(1865420, 4320000) → Sūrya mean longitude: 42.903923°\ncompute_madhyama(1865420, 57753336) → Chandra mean longitude: 70.821161°\n(bhagaṇa per Mahāyuga: Sūrya 4,320,000 · Chandra 57,753,336)\nComputed by executing this snippet (Python 3).\n```"
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": "## Chapter 2: स्पष्टाधिकारः (True Longitude & Dual Epicyclic Calculus)\n**Scope:** `Verses 2.1 – 2.69 (69 श्लोक in the edition) · shown here: 2.38` · **Reading:** `16 min study`\n\n### Overview\nRigorous non-Keplerian orbital perturbation calculus. Resolves true planetary positions through pulsating Manda (eccentricity) and Śīghra (synodic-anomaly) epicycles using variable circumference equations.\n\n### Ślokas & anvaya\n> **ओजयुग्मान्तरगुणा भुजज्या त्रिज्ययोद्धृता ।  \n> युग्मे वृत्ते धनर्णं स्यादोजादूनाधिके स्फुटम् ।।**\n>\n> *ojayugmāntaraguṇā bhujajyā trijyayoddhṛtā ।  \n> yugme vṛtte dhanarṇaṃ syādojādūnādhike sphuṭam ।।*\n>\n> **Meter:** सूर्य-सिद्धान्त 2.38\n>\n> **Source:** editions/surya-siddhanta-full-edition.html#v2-38 — Devanāgarī, IAST, padaccheda-anvaya and English rendering as printed in the edition (सूर्य-सिद्धान्त 2.38)\n\n- **ओज-युग्म-अन्तर**: विषम–सम परिधि-भेद\n- **गुणा**: (भुजज्या से) गुणित\n- **भुजज्या**: केन्द्र की भुज-ज्या\n- **त्रिज्या**: radius of base circle (प्रायः ३४३८′)\n- **उद्धृता**: विभाजित\n- **युग्मे वृत्ते**: सम-परिधि पक्ष में\n- **धनर्णम्**: धन या ऋण\n- **ओजात् ऊनाधिके**: ओज से न्यून/अधिक होने पर\n- **स्फुटम्**: स्फुट (corrected) परिधि\n\nMultiply the odd–even epicycle difference by the bhuja-jyā and divide by the trijyā; applied with the proper sign to the even-circle base (according as the true circle is less or greater than the odd-end value), this yields the sphuṭa (corrected) epicycle.\n\n### Formulation — Variable Epicyclic Circumference & True Longitude (4-Samskara)\n$$p(\\theta) = p_{\\text{even}} + (p_{\\text{odd}} - p_{\\text{even}})|\\sin\\theta|, \\quad \\Delta\\theta_{\\text{manda}} = \\arcsin\\left(\\frac{p(\\theta) \\sin\\theta}{360^\\circ}\\right)$$\n\nPulsating epicycle models orbital eccentricity variation seamlessly without numerical integration."
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [],
   "source": "import math\ndef manda_correction(kendra_deg, p_even, p_odd):\n    rad = math.radians(kendra_deg)\n    p = p_even + (p_odd - p_even) * abs(math.sin(rad))\n    sin_corr = (p * math.sin(rad)) / 360.0\n    return math.degrees(math.asin(sin_corr))"
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [
    {
     "output_type": "stream",
     "name": "stdout",
     "text": "manda_correction(45.0, 72.0, 75.0) → 8.37133176823723\n"
    }
   ],
   "source": "print('manda_correction(45.0, 72.0, 75.0)', \"→\", repr(manda_correction(45.0, 72.0, 75.0)))"
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": "**Recorded output (dataset `codeOutput`, verified against the run above):**\n```\nInput: Mangala manda kendra = 45.0°; epicycle circumference 72° (even) / 75° (odd)\npulsating epicycle p(45°) = 74.121320°\nmanda_correction(45.0, 72.0, 75.0) → +8.371332°\nComputed by executing this snippet (Python 3).\n```"
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": "## Chapter 3: त्रिप्रश्नाधिकारः (Direction, Place & Time (Gnomon Geometry))\n**Scope:** `Verses 3.1 – 3.51 (51 श्लोक in the edition) · shown here: 3.1, 3.2` · **Reading:** `15 min study`\n\n### Overview\nTrigonometric resolution of the 3 fundamental astronomical questions (Dik/Direction, Desha/Longitude, and Kala/Time) using the 12-digit Shankuyantra (gnomon), solar declination (Kranti), and equinoctial shadow (Palabha).\n\n### Ślokas & anvaya\n> **शिलातले अम्बुसंशुद्धे वज्रलेपे अपि वा समे ।  \n> तत्र शङ्क्वङ्गुलैरिष्टैः समं मण्डलं आलिखेत् ।।**\n>\n> *śilātale ambusaṃśuddhe vajralepe api vā same ।  \n> tatra śaṅkvaṅgulairiṣṭaiḥ samaṃ maṇḍalaṃ ālikhet ।।*\n>\n> **Meter:** सूर्य-सिद्धान्त 3.1\n>\n> **Source:** editions/surya-siddhanta-full-edition.html#v3-01 — Devanāgarī, IAST, padaccheda-anvaya and English rendering as printed in the edition (सूर्य-सिद्धान्त 3.1)\n\n- **शिलातल**: पत्थर का समतल आधार\n- **अम्बुसंशुद्ध**: जल से साफ़ किया हुआ\n- **वज्रलेप**: कठोर/वज्र-सा लेप (चिकना प्लास्टर)\n- **सम**: एकसमान, झुकाव-रहित\n- **शङ्क्वङ्गुल**: शङ्कु की अङ्गुल-माप\n- **इष्ट**: अभीष्ट/निर्धारित\n- **मण्डल**: वृत्त\n- **आलिखेत्**: खींचे\n\nOn a stone surface cleaned with water—or even one finished with a hard vajra-plaster coating—made perfectly level, draw a circle whose radius equals the chosen number of aṅgulas of the gnomon.\n\n> **तन्मध्ये स्थापयेच्छङ्कुं कल्पनाद्वादशाङ्गुलम् ।  \n> तच्छायाग्रं स्पृशेद्यत्र वृत्ते पूर्वापरार्धयोः ।।**\n>\n> *tanmadhye sthāpayecchaṅkuṃ kalpanādvādaśāṅgulam ।  \n> tacchāyāgraṃ spṛśedyatra vṛtte pūrvāparārdhayoḥ ।।*\n>\n> **Meter:** सूर्य-सिद्धान्त 3.2\n>\n> **Source:** editions/surya-siddhanta-full-edition.html#v3-02 — Devanāgarī, IAST, padaccheda-anvaya and English rendering as printed in the edition (सूर्य-सिद्धान्त 3.2)\n\n- **तन्मध्ये**: उस वृत्त के केन्द्र में\n- **स्थापयेत्**: स्थापित करे\n- **शङ्कु**: ऊर्ध्व-दण्ड/gnomon\n- **कल्पना**: माना हुआ/परिकल्पित\n- **द्वादशाङ्गुल**: १२ अङ्गुल\n- **छायाग्र**: छाया का अग्र-बिन्दु\n- **स्पृशेत्**: स्पर्श करे\n- **वृत्त**: वृत्त-परिधि\n- **पूर्वापरार्ध**: पूर्व और पश्चिम के अर्धभाग\n\nAt the circle’s centre set a gnomon taken as twelve aṅgulas high. Note the points where the tip of its shadow meets the circumference in the eastern and western halves (of the day).\n\n### Formulation — Ascensional Difference & Gnomon Equation\n$$\\sin(\\Delta t_{\\text{char}}) = \\tan(\\phi) \\tan(\\delta), \\quad \\text{Palabhā} = 12 \\tan(\\phi)$$\n\nDetermines local sunrise, daytime length (Dinamana), and the exact local sidereal ascendant (Lagna)."
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [],
   "source": "import math\ndef calculate_chara(lat_deg, dec_deg):\n    sin_chara = math.tan(math.radians(lat_deg)) * math.tan(math.radians(dec_deg))\n    sin_chara = max(-1.0, min(1.0, sin_chara))\n    return math.degrees(math.asin(sin_chara)) * 4.0 # in minutes of time"
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [
    {
     "output_type": "stream",
     "name": "stdout",
     "text": "calculate_chara(23.1765, 17.5) → 31.03082128448708\n"
    }
   ],
   "source": "print('calculate_chara(23.1765, 17.5)', \"→\", repr(calculate_chara(23.1765, 17.5)))"
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": "**Recorded output (dataset `codeOutput`, verified against the run above):**\n```\nInput: latitude 23.1765° N (Ujjain), solar declination +17.5°\ncalculate_chara(23.1765, 17.5) → +31.0308 minutes of time\n(ascensional difference, chara)\nComputed by executing this snippet (Python 3).\n```"
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": "## Chapter 4: चन्द्रग्रहणाधिकारः (Lunar Eclipse Calculus & Shadow Cone Geometry)\n**Scope:** `Verses 4.1 – 4.26 (26 श्लोक in the edition) · shown here: 4.12` · **Reading:** `12 min study`\n\n### Overview\nMathematical mechanics of lunar eclipses. Derives the apparent diameters of the Sun, Moon, and Earth's shadow cone (Bhamandala), contact times (Sparsha and Moksha), and totality duration (Sthityardha).\n\n### Ślokas & anvaya\n> **ग्राह्यग्राहकसंयोगवियोगौ दलितौ पृथक् ।  \n> विक्षेपवर्गहीनाभ्यां तद्वर्गाभ्यां उभे पदे ।।**\n>\n> *grāhyagrāhakasaṃyogaviyogau dalitau pṛthak ।  \n> vikṣepavargahīnābhyāṃ tadvargābhyāṃ ubhe pade ।।*\n>\n> **Meter:** सूर्य-सिद्धान्त 4.12\n>\n> **Source:** editions/surya-siddhanta-full-edition.html#v4-12 — Devanāgarī, IAST, padaccheda-anvaya and English rendering as printed in the edition (सूर्य-सिद्धान्त 4.12)\n\n- **ग्राह्य-ग्राहक**: आच्छाद्य और आच्छादक\n- **संयोग**: योग\n- **वियोग**: अन्तर\n- **दलितौ**: आधे किए हुए\n- **पृथक्**: अलग-अलग\n- **विक्षेप-वर्ग-हीनाभ्याम्**: विक्षेप-वर्ग से रहित\n- **तद्-वर्गाभ्याम्**: उन (दलित योग/वियोग) के वर्गों से\n- **उभे पदे**: दोनों पद (मूल/√)\n\nHalve, separately, the sum and the difference of the eclipsed and eclipsing diameters. From those two squares, each diminished by the square of the latitude, extract both roots — the two “padas.”\n\n### Formulation — Earth Shadow Diameter & Half-Duration\n$$D_{\\text{shadow}} = \\left( D_\\odot - \\frac{D_\\odot - D_\\oplus}{D_{\\text{dist}}} \\right) \\times \\frac{R_\\text{moon}}{R_\\odot}, \\quad t_{\\text{half}} = \\sqrt{\\left(\\frac{D_m + D_s}{2}\\right)^2 - \\beta^2}$$\n\nThe half-duration rule of SS 4.12–4.13 (roots of the half-sum and half-difference, latitude removed)."
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [],
   "source": "import math\ndef lunar_eclipse_half_duration(dia_moon, dia_shadow, lat_moon):\n    sum_radii = (dia_moon + dia_shadow) / 2.0\n    if lat_moon >= sum_radii: return 0.0 # No eclipse\n    return math.sqrt(sum_radii**2 - lat_moon**2)"
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {},
   "outputs": [
    {
     "output_type": "stream",
     "name": "stdout",
     "text": "lunar_eclipse_half_duration(31.5, 82.4, 12.2) → 55.62789318318644\n"
    }
   ],
   "source": "print('lunar_eclipse_half_duration(31.5, 82.4, 12.2)', \"→\", repr(lunar_eclipse_half_duration(31.5, 82.4, 12.2)))"
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": "**Recorded output (dataset `codeOutput`, verified against the run above):**\n```\nInput: Moon diameter 31.5′, shadow diameter 82.4′, Moon latitude 12.2′\nlunar_eclipse_half_duration(31.5, 82.4, 12.2) → 55.6279 arcminutes\n(half-duration arc along the Moon's path)\nComputed by executing this snippet (Python 3).\n```"
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": "## Chapter 5: सूर्यग्रहणाधिकारः (Solar Eclipse & Topocentric Parallax (Lambana))\n**Scope:** `Verses 5.1 – 5.17 (17 श्लोक in the edition) · shown here: 5.8` · **Reading:** `15 min study`\n\n### Overview\nTopocentric parallax calculus in longitude (Lambana) and latitude (Nati). Explains why solar eclipses are strictly localized phenomena differing fundamentally from lunar eclipses.\n\n### Ślokas & anvaya\n> **मध्यलग्नार्कविश्लेषज्या छेदेन विभाजिता ।  \n> रवीन्द्वोर्लम्बनं ज्ञेयं प्राक्पश्चाद्घटिकादिकम् ।।**\n>\n> *madhyalagnārkaviśleṣajyā chedena vibhājitā ।  \n> ravīndvorlambanaṃ jñeyaṃ prākpaścādghaṭikādikam ।।*\n>\n> **Meter:** सूर्य-सिद्धान्त 5.8\n>\n> **Source:** editions/surya-siddhanta-full-edition.html#v5-08 — Devanāgarī, IAST, padaccheda-anvaya and English rendering as printed in the edition (सूर्य-सिद्धान्त 5.8)\n\n- **मध्यलग्न-अर्क-विश्लेष-ज्या**: मध्यलग्न और सूर्य के अन्तर की ज्या\n- **छेदेन विभाजिता**: छेद से भाजित\n- **रवि-इन्द्वोः**: सूर्य और चन्द्र का\n- **लम्बनं**: लम्बन (देशान्तरीय/दृष्टि-लंब-सा दृष्टिदोष)\n- **ज्ञेयं**: जानना चाहिए\n- **प्राक्-पश्चात्**: पूर्व या पश्चिम\n- **घटिका-आदिकम्**: घटी आदि (काल-माप) में\n\nThe sine of the difference between the madhyalagna (meridian ecliptic point) and the Sun, divided by the cheda, is the lambana of the Sun and the Moon. Take it as eastward or westward, and express it in ghaṭikā and the finer time units.\n\n### Formulation — Topocentric Parallax in Longitude & Latitude\n$$D=\\sqrt{M^2-(MU/R)^2},\\quad G=\\sqrt{R^2-D^2},\\quad L=\\operatorname{jyā}(\\lambda_{madhya}-\\lambda_\\odot)/C;\\quad N\\approx D/70\\approx49D/R$$\n\nSource-bounded summary of 5.3–5.12. The former 4×sin/48×sin shortcut and 5.1–5.40 metadata were generated errors and are retired."
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {},
   "outputs": [
    {
     "output_type": "error",
     "ename": "NotImplementedError",
     "evalue": "Mirror shortcut retired: use canonical mangalkaalyantra /v1/grahana?lat=…&lon=…",
     "traceback": [
      "Traceback (most recent call last):",
      "  File \"/tmp/tmpmvisq72b.py\", line 1, in <module>",
      "    raise NotImplementedError('Mirror shortcut retired: use canonical mangalkaalyantra /v1/grahana?lat=…&lon=…')",
      "NotImplementedError: Mirror shortcut retired: use canonical mangalkaalyantra /v1/grahana?lat=…&lon=…"
     ]
    }
   ],
   "source": "raise NotImplementedError('Mirror shortcut retired: use canonical mangalkaalyantra /v1/grahana?lat=…&lon=…')"
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {},
   "outputs": [
    {
     "output_type": "stream",
     "name": "stdout",
     "text": "not run: the snippet above raises deliberately\n"
    }
   ],
   "source": "# no demo call recorded for this chapter"
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": "## Chapter 6: छेद्यकाधिकारः (Graphical Eclipse Projections & Vector Diagrams)\n**Scope:** `Verses 6.1 – 6.24 (24 श्लोक in the edition) · shown here: 6.11` · **Reading:** `10 min study`\n\n### Overview\nOrthographic and stereographic geometric projection methods for drawing eclipse phase diagrams on flat wooden boards and parchment.\n\n### Ślokas & anvaya\n> **विक्षेपाग्राल्लिखेद्वृत्तं ग्राहकार्धेन तेन यत् ।  \n> ग्राह्यवृत्तं समाक्रान्तं तद्ग्रस्तं तमसा भवेत् ।।**\n>\n> *vikṣepāgrāllikhedvṛttaṃ grāhakārdhena tena yat ।  \n> grāhyavṛttaṃ samākrāntaṃ tadgrastaṃ tamasā bhavet ।।*\n>\n> **Meter:** सूर्य-सिद्धान्त 6.11\n>\n> **Source:** editions/surya-siddhanta-full-edition.html#v6-11 — Devanāgarī, IAST, padaccheda-anvaya and English rendering as printed in the edition (सूर्य-सिद्धान्त 6.11)\n\n- **विक्षेप-अग्रात्**: विक्षेप के अग्र-बिन्दु से\n- **लिखेत् वृत्तं**: वृत्त लिखे\n- **ग्राहक-अर्धेन**: ग्राहक (ग्रहण-कर्ता) के अर्ध-व्यास से\n- **तेन यत्**: उससे जो\n- **ग्राह्य-वृत्तं**: ग्राह्य (ग्रहण-पात्र) का वृत्त\n- **समाक्रान्तं**: आक्रान्त/ढका हुआ\n- **तत् ग्रस्तं**: वही ग्रस्त\n- **तमसा**: तम/अन्धकार से\n- **भवेत्**: होता है\n\nFrom the tip of the vikṣepa draw a circle with radius equal to half the eclipsing body’s diameter. Whatever of the eclipsed body’s circle that circle covers is what is seized by darkness — the geometric definition of the eclipsed portion on the board.\n\n### Formulation — Geometric Obscuration Segment\n$$\\text{Grasa} = \\frac{(D_1 + D_2)/2 - \\sqrt{\\Delta\\lambda^2 + \\Delta\\beta^2}}{D_1}$$\n\nDetermines the magnitude of eclipse and visual crescent curvature."
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {},
   "outputs": [],
   "source": "def eclipse_magnitude(d_sun, d_moon, sep_arcmin):\n    overlap = (d_sun + d_moon)/2.0 - sep_arcmin\n    return max(0.0, overlap / d_sun)"
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {},
   "outputs": [
    {
     "output_type": "stream",
     "name": "stdout",
     "text": "eclipse_magnitude(32.0, 31.4, 10.2) → 0.671875\n"
    }
   ],
   "source": "print('eclipse_magnitude(32.0, 31.4, 10.2)', \"→\", repr(eclipse_magnitude(32.0, 31.4, 10.2)))"
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": "**Recorded output (dataset `codeOutput`, verified against the run above):**\n```\nInput: Sun diameter 32.0′, Moon diameter 31.4′, centre separation 10.2′\neclipse_magnitude(32.0, 31.4, 10.2) → 0.671875 (67.19% of the solar diameter covered)\nComputed by executing this snippet (Python 3).\n```"
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": "## Chapter 7: ग्रहयुत्यधिकारः (Planetary Conjunctions & Orbital Crossings)\n**Scope:** `Verses 7.1 – 7.24 (24 श्लोक in the edition) · shown here: 7.18, 7.19` · **Reading:** `11 min study`\n\n### Overview\nCalculates geocentric planetary conjunctions (Bhedha, Ullekha, Anshuvimarda, Apasavya), occultations, and mutual distance vectors.\n\n### Ślokas & anvaya\n> **स्वशङ्कुमूर्धगौ व्योम्नि ग्रहौ दृक्तुल्यतां इतौ ।  \n> उल्लेखं तारकास्पर्शाद्भेदे भेदः प्रकीर्त्यते ।।**\n>\n> *svaśaṅkumūrdhagau vyomni grahau dṛktulyatāṃ itau ।  \n> ullekhaṃ tārakāsparśādbhede bhedaḥ prakīrtyate ।।*\n>\n> **Meter:** सूर्य-सिद्धान्त 7.18\n>\n> **Source:** editions/surya-siddhanta-full-edition.html#v7-18 — Devanāgarī, IAST, padaccheda-anvaya and English rendering as printed in the edition (सूर्य-सिद्धान्त 7.18)\n\n- **स्वशङ्कुमूर्धगौ**: अपने-अपने शङ्कु-शिखर पर\n- **व्योम्नि**: आकाश में\n- **ग्रहौ**: दोनों ग्रह\n- **दृक्तुल्यताम् इतौ**: दृष्टि-समता को प्राप्त\n- **उल्लेखम्**: उल्लेख (स्पर्श/रेखा-स्पर्श)\n- **तारकास्पर्शात्**: तारा-स्पर्श से\n- **भेदे**: भेद/पृथकता में\n- **भेदः**: भेद (पृथक्-दर्शन)\n- **प्रकीर्त्यते**: कहा जाता है\n\nThe two planets, having attained equality of vision in the sky, are shown at the tops of their respective gnomons. Contact with a star is called ullekha; when they are distinct from each other, the state is named bheda.\n\n> **युद्धं अंशुविमर्दाख्यं अंशुयोगे परस्परम् ।  \n> अंशादूने अपसव्याख्यं युद्धं एको अत्र चेदणुः ।।**\n>\n> *yuddhaṃ aṃśuvimardākhyaṃ aṃśuyoge parasparam ।  \n> aṃśādūne apasavyākhyaṃ yuddhaṃ eko atra cedaṇuḥ ।।*\n>\n> **Meter:** सूर्य-सिद्धान्त 7.19\n>\n> **Source:** editions/surya-siddhanta-full-edition.html#v7-19 — Devanāgarī, IAST, padaccheda-anvaya and English rendering as printed in the edition (सूर्य-सिद्धान्त 7.19)\n\n- **युद्धम्**: ग्रह-युद्ध\n- **अंशुविमर्दाख्यम्**: अंशु-विमर्द नामक\n- **अंशुयोगे परस्परम्**: परस्पर किरणों/अंशों के योग में\n- **अंशाद् ऊने**: एक अंश से कम (विच्छेद) पर\n- **अपसव्याख्यम्**: अपसव्य नामक\n- **युद्धम्**: युद्ध\n- **एकः अत्र चेत् अणुः**: यदि इनमें एक सूक्ष्म/अणु हो\n\nMutual pressing of the rays is the combat named aṃśu-vimarda. When the separation is less than one degree, the combat is called apasavya; and if one of the two is minute (aṇu), that condition belongs here as well.\n\n### Formulation — Mutual Angular Distance & Relative Velocity\n$$\\Delta\\theta = \\sqrt{(\\lambda_1 - \\lambda_2)^2 \\cos^2\\beta + (\\beta_1 - \\beta_2)^2}, \\quad t_{\\text{conj}} = \\frac{\\Delta\\lambda}{\\dot{\\lambda}_1 - \\dot{\\lambda}_2}$$\n\nDetermines exact collision and conjunction epochs."
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {},
   "outputs": [],
   "source": "def planetary_conjunction_time(l1, l2, v1, v2):\n    return (l2 - l1) / (v1 - v2) # in days"
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "metadata": {},
   "outputs": [
    {
     "output_type": "stream",
     "name": "stdout",
     "text": "planetary_conjunction_time(102.14, 105.78, 0.083, 0.033) → 72.80000000000001\n"
    }
   ],
   "source": "print('planetary_conjunction_time(102.14, 105.78, 0.083, 0.033)', \"→\", repr(planetary_conjunction_time(102.14, 105.78, 0.083, 0.033)))"
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": "**Recorded output (dataset `codeOutput`, verified against the run above):**\n```\nInput: Jupiter λ = 102.14° moving 0.083°/day; Saturn λ = 105.78° moving 0.033°/day\nplanetary_conjunction_time(102.14, 105.78, 0.083, 0.033) → 72.8 days\nComputed by executing this snippet (Python 3).\n```"
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": "## Chapter 8: भग्रहयुत्यधिकारः (Junction Stars (Yogatara) & Asterism Conjunctions)\n**Scope:** `Verses 8.1 – 8.21 (21 श्लोक in the edition) · shown here: 8.13` · **Reading:** `12 min study`\n\n### Overview\nCatalogues the canonical polar longitudes (Dhruvaka) and polar latitudes (Vikshepa) of the 27 junction stars (Yogataras) defining the sidereal ecliptic lattice.\n\n### Ślokas & anvaya\n> **वृषे सप्तदशे भागे यस्य याम्यो अंशकद्वयात् ।  \n> विक्षेपो अभ्यधिको भिन्द्याद्रोहिण्याः शकतं तु सः ।।**\n>\n> *vṛṣe saptadaśe bhāge yasya yāmyo aṃśakadvayāt ।  \n> vikṣepo abhyadhiko bhindyādrohiṇyāḥ śakataṃ tu saḥ ।।*\n>\n> **Meter:** सूर्य-सिद्धान्त 8.13\n>\n> **Source:** editions/surya-siddhanta-full-edition.html#v8-13 — Devanāgarī, IAST, padaccheda-anvaya and English rendering as printed in the edition (सूर्य-सिद्धान्त 8.13)\n\n- **वृषे सप्तदशे भागे**: वृष के सत्रहवें अंश में\n- **यस्य**: जिसका\n- **याम्यः**: दक्षिणी\n- **अंशकद्वयात्**: दो अंश से\n- **विक्षेपः अभ्यधिकः**: विक्षेप अधिक\n- **भिन्द्यात्**: भेद/विदीर्ण करे\n- **रोहिण्याः शकटम्**: रोहिणी का शकट (गाड़ी)\n- **सः**: वही (ग्रह/स्थिति)\n\nThat body which stands in the seventeenth degree of Taurus, with southern latitude greater than two degrees, is said to split Rohiṇī’s cart. The verse states a geometric gate: longitude window plus a latitude threshold.\n\n### Formulation — Polar to Ecliptic Transformation\n$$\\sin\\delta = \\sin\\beta \\cos\\epsilon + \\cos\\beta \\sin\\epsilon \\sin\\lambda, \\quad \\alpha = \\arctan\\left(\\frac{\\sin\\lambda \\cos\\epsilon - \\tan\\beta \\sin\\epsilon}{\\cos\\lambda}\\right)$$\n\nPreserves sidereal anchor coordinates against axial precession."
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "metadata": {},
   "outputs": [],
   "source": "YOGATARAS = {'Ashwini': (11.6, 10.0), 'Rohini': (49.5, -4.5), 'Chitra': (180.0, -1.8)}\ndef is_yogatara_occulted(moon_lon, moon_lat, star_lon, star_lat):\n    dist = ((moon_lon - star_lon)**2 + (moon_lat - star_lat)**2)**0.5\n    return dist < 0.5"
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "metadata": {},
   "outputs": [
    {
     "output_type": "stream",
     "name": "stdout",
     "text": "is_yogatara_occulted(49.3, -4.3, 49.5, -4.5) → True\n"
    }
   ],
   "source": "print('is_yogatara_occulted(49.3, -4.3, 49.5, -4.5)', \"→\", repr(is_yogatara_occulted(49.3, -4.3, 49.5, -4.5)))"
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": "**Recorded output (dataset `codeOutput`, verified against the run above):**\n```\nInput: Moon (49.3°, −4.3°); Rohini yogatārā Aldebaran (49.5°, −4.5°)\nangular distance = 0.2828° (occultation threshold in snippet: 0.5°)\nis_yogatara_occulted(49.3, -4.3, 49.5, -4.5) → True\nComputed by executing this snippet (Python 3).\n```"
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": "## Chapter 9: उदयास्ताधिकारः (Heliacal Risings & Settings (Kala-Bhaga))\n**Scope:** `Verses 9.1 – 9.18 (18 श्लोक in the edition) · shown here: 9.6, 9.7, 9.8` · **Reading:** `11 min study`\n\n### Overview\nDetermines the exact visibility threshold angles (Kalabhaga) for planets appearing from or disappearing into the Sun's blinding disk.\n\n### Ślokas & anvaya\n> **एकादशामरेज्यस्य तिथिसङ्ख्यार्कजस्य च ।  \n> अस्तांशा भूमिपुत्रस्य दश सप्ताधिकास्ततः ।।**\n>\n> *ekādaśāmarejyasya tithisaṅkhyārkajasya ca ।  \n> astāṃśā bhūmiputrasya daśa saptādhikāstataḥ ।।*\n>\n> **Meter:** सूर्य-सिद्धान्त 9.6\n>\n> **Source:** editions/surya-siddhanta-full-edition.html#v9-06 — Devanāgarī, IAST, padaccheda-anvaya and English rendering as printed in the edition (सूर्य-सिद्धान्त 9.6)\n\n- **एकादश**: ग्यारह (अंश)\n- **अमर-इज्यस्य**: अमर-इज्य = बृहस्पति के\n- **तिथि-सङ्ख्या**: तिथि-संख्या = पंद्रह\n- **आर्कजस्य**: अर्कज = शनि के\n- **च**: और\n- **अस्तांशाः**: अस्त-अंश (दृश्यता/अस्त की सीमा-डिग्री)\n- **भूमि-पुत्रस्य**: भूमि-पुत्र = मंगल के\n- **दश सप्त-अधिकाः**: दस से सात अधिक = सत्रह\n- **ततः**: उससे/तदनन्तर\n\nThe heliacal limit-degrees (astāṃśa) are: Jupiter 11°, Saturn 15° (tithi-count), Mars 17° (ten plus seven). These are fixed visibility thresholds for the three outer planets, not rates or periods.\n\n> **पश्चादस्तमयो अष्टाभिरुदयः प्राङ्महत्तया ।  \n> प्रागस्तं उदयः पश्चादल्पत्वाद्दशभिर्भृगोः ।।**\n>\n> *paścādastamayo aṣṭābhirudayaḥ prāṅmahattayā ।  \n> prāgastaṃ udayaḥ paścādalpatvāddaśabhirbhṛgoḥ ।।*\n>\n> **Meter:** सूर्य-सिद्धान्त 9.7\n>\n> **Source:** editions/surya-siddhanta-full-edition.html#v9-07 — Devanāgarī, IAST, padaccheda-anvaya and English rendering as printed in the edition (सूर्य-सिद्धान्त 9.7)\n\n- **पश्चात् अस्तमयः**: पश्चिम-अस्त\n- **अष्टाभिः**: आठ (अंशों) से\n- **उदयः प्राक्**: पूर्व-उदय\n- **महत्तया**: महत्ता/बृहत्-प्रकाश के कारण\n- **प्राक् अस्तम्**: पूर्व-अस्त\n- **उदयः पश्चात्**: पश्चिम-उदय\n- **अल्पत्वात्**: अल्पता (क्षुद्र-प्रकाश) के कारण\n- **दशभिः**: दस से\n- **भृगोः**: भृगु = शुक्र का\n\nFor Venus: western setting and eastern rising by 8° when “great” (brighter phase); eastern setting and western rising by 10° when “small” (fainter phase). Two thresholds track phase-dependent brilliance.\n\n> **एवं बुधो द्वादशभिश्चतुर्दशभिरंशकैः ।  \n> वक्री शीघ्रगतिश्चार्कात्करोत्यस्तमयोदयौ ।।**\n>\n> *evaṃ budho dvādaśabhiścaturdaśabhiraṃśakaiḥ ।  \n> vakrī śīghragatiścārkātkarotyastamayodayau ।।*\n>\n> **Meter:** सूर्य-सिद्धान्त 9.8\n>\n> **Source:** editions/surya-siddhanta-full-edition.html#v9-08 — Devanāgarī, IAST, padaccheda-anvaya and English rendering as printed in the edition (सूर्य-सिद्धान्त 9.8)\n\n- **एवम्**: इसी प्रकार\n- **बुधः**: बुध\n- **द्वादशभिः**: बारह से\n- **चतुर्दशभिः**: चौदह से\n- **अंशकैः**: अंशों द्वारा\n- **वक्री**: वक्र-गति में\n- **शीघ्र-गतिः च**: और शीघ्र-गति में\n- **आर्कात्**: सूर्य से (सापेक्ष)\n- **करोति**: करता है\n- **अस्तमय-उदयौ**: अस्त और उदय\n\nSo Mercury effects setting and rising relative to the Sun by 12° when retrograde and by 14° when in swift (śīghra) motion. The pair of limits closes the fixed-threshold list begun for the outer planets and Venus.\n\n### Formulation — Arc of Combustion (Asta) & Heliacal Rising\n$$|\\lambda_{\\text{graha}} - \\lambda_\\odot| \\ge \\Theta_{\\text{kala}}, \\quad \\text{Condition for Heliacal Visibility}$$\n\nFundamental for Vedic muhurta and civic almanac visibility flags."
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "metadata": {},
   "outputs": [],
   "source": "KALABHAGA = {'Jupiter': 11.0, 'Venus': 8.0, 'Mars': 17.0, 'Saturn': 15.0}\ndef is_combust(planet_lon, sun_lon, planet_name):\n    diff = abs(planet_lon - sun_lon) % 360.0\n    if diff > 180.0: diff = 360.0 - diff\n    return diff < KALABHAGA.get(planet_name, 14.0)"
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "metadata": {},
   "outputs": [
    {
     "output_type": "stream",
     "name": "stdout",
     "text": "is_combust(118.2, 112.4, 'Jupiter') → True\n"
    }
   ],
   "source": "print(\"is_combust(118.2, 112.4, 'Jupiter')\", \"→\", repr(is_combust(118.2, 112.4, 'Jupiter')))"
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": "**Recorded output (dataset `codeOutput`, verified against the run above):**\n```\nInput: Sun λ = 112.4°, Jupiter λ = 118.2° (Jupiter kālabhāga limit: 11°)\nseparation = 5.8°\nis_combust(118.2, 112.4, 'Jupiter') → True\nComputed by executing this snippet (Python 3).\n```"
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": "## Chapter 10: शृङ्गोन्नत्यधिकारः (Lunar Horn Elevation & Crescent Phase Geometry)\n**Scope:** `Verses 10.1 – 10.15 (15 श्लोक in the edition) · shown here: 10.9` · **Reading:** `9 min study`\n\n### Overview\nTrigonometric derivation of the illuminated lunar phase angle, crescent width (Shukla-Paksha phase), and the tilt/elevation of the northern and southern horns of the Moon.\n\n### Ślokas & anvaya\n> **सूर्योनशीतगोर्लिप्ताः शुक्लं नवशतोद्धृताः ।  \n> चन्द्रबिम्बाङ्गुलाभ्यस्तं हृतं द्वादशभिः स्फुटम् ।।**\n>\n> *sūryonaśītagorliptāḥ śuklaṃ navaśatoddhṛtāḥ ।  \n> candrabimbāṅgulābhyastaṃ hṛtaṃ dvādaśabhiḥ sphuṭam ।।*\n>\n> **Meter:** सूर्य-सिद्धान्त 10.9\n>\n> **Source:** editions/surya-siddhanta-full-edition.html#v10-09 — Devanāgarī, IAST, padaccheda-anvaya and English rendering as printed in the edition (सूर्य-सिद्धान्त 10.9)\n\n- **सूर्योन**: सूर्य से रहित / सूर्य-घटित (चन्द्र − सूर्य)\n- **शीतगोः**: चन्द्रमा की\n- **लिप्ताः**: कलाएँ (arcminutes)\n- **शुक्लं**: शुक्ल-भाग (प्रकाशित अंश)\n- **नवशत**: ९००\n- **उद्धृताः**: विभाजित\n- **चन्द्रबिम्ब-अङ्गुला**: चन्द्र-बिम्ब की अङ्गुल-माप\n- **अभ्यस्तं**: गुणा\n- **द्वादशभिः**: १२ से\n- **स्फुटम्**: शुद्ध / तात्कालिक प्रकाशित मान\n\nTake the minutes of arc of the Moon diminished by the Sun (the elongation). Divided by nine hundred they yield the “white” measure—the illuminated portion in a twelve-part scale. That quantity, multiplied by the Moon’s disk in aṅgulas and divided by twelve, is the true illuminated measure for the moment.\n\n### Formulation — Crescent Phase Width & Horn Angle\n$$W_{\\text{crescent}} = \\frac{D_{\\text{moon}}}{2} (1 - \\cos(\\lambda_m - \\lambda_s)), \\quad \\tan\\theta_{\\text{tilt}} = \\frac{\\Delta\\delta}{\\Delta\\alpha \\cos\\delta_m}$$\n\nProvides the visual phase appearance of the new Moon."
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "metadata": {},
   "outputs": [],
   "source": "import math\ndef crescent_width(elongation_deg, moon_diam=31.5):\n    return (moon_diam / 2.0) * (1.0 - math.cos(math.radians(elongation_deg)))"
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "metadata": {},
   "outputs": [
    {
     "output_type": "stream",
     "name": "stdout",
     "text": "crescent_width(36.0) → 3.0079823385945774\n"
    }
   ],
   "source": "print('crescent_width(36.0)', \"→\", repr(crescent_width(36.0)))"
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": "**Recorded output (dataset `codeOutput`, verified against the run above):**\n```\nInput: elongation 36.0° (≈ tithi 3), Moon diameter 31.5′\ncrescent_width(36.0) → 3.0080 arcminutes\nComputed by executing this snippet (Python 3).\n```"
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": "## Chapter 11: पाताधिकारः (Planetary Orbital Nodes & Vyatipata Phenomena)\n**Scope:** `Verses 11.1 – 11.23 (23 श्लोक in the edition) · shown here: 11.1, 11.2` · **Reading:** `11 min study`\n\n### Overview\nMathematical analysis of celestial declination equality (Vaidhruta and Vyatipata), when the Sun and Moon share identical declinations on opposite sides of the celestial equator.\n\n### Ślokas & anvaya\n> **एकायनगतौ स्यातां सूर्यचन्द्रमसौ यदा ।  \n> तद्युतौ मण्डले क्रान्त्योस्तुल्यत्वे वैधृताभिधः ।।**\n>\n> *ekāyanagatau syātāṃ sūryacandramasau yadā ।  \n> tadyutau maṇḍale krāntyostulyatve vaidhṛtābhidhaḥ ।।*\n>\n> **Meter:** सूर्य-सिद्धान्त 11.1\n>\n> **Source:** editions/surya-siddhanta-full-edition.html#v11-01 — Devanāgarī, IAST, padaccheda-anvaya and English rendering as printed in the edition (सूर्य-सिद्धान्त 11.1)\n\n- **एकायन-गतौ**: एक ही अयन में स्थित\n- **सूर्य-चन्द्रमसौ**: सूर्य और चन्द्रमा\n- **तद्-युतौ**: उनकी युति/संयोग-अवस्था में\n- **मण्डले**: राशि-मण्डल (भचक्र) में\n- **क्रान्त्योः तुल्यत्वे**: दोनों की क्रान्तियों (विषुवत्-अयन-झुकाव) के समान होने पर\n- **वैधृत-अभिधः**: वैधृत नामक योग कहलाता है\n\nWhen the Sun and Moon lie in the same ayan, and in the circle their conjunction is such that their declinations become equal, that condition is named Vaidhṛta. The verse fixes two co-requisites: shared ayan and equal krānti.\n\n> **विपरीतायनगतौ चन्द्रार्कौ क्रान्तिलिप्तिका ।  \n> समास्तदा व्यतीपातो भगणार्धे तयोर्युतौ ।।**\n>\n> *viparītāyanagatau candrārkau krāntiliptikā ।  \n> samāstadā vyatīpāto bhagaṇārdhe tayoryutau ।।*\n>\n> **Meter:** सूर्य-सिद्धान्त 11.2\n>\n> **Source:** editions/surya-siddhanta-full-edition.html#v11-02 — Devanāgarī, IAST, padaccheda-anvaya and English rendering as printed in the edition (सूर्य-सिद्धान्त 11.2)\n\n- **विपरीत-अयन-गतौ**: विपरीत अयनों में स्थित\n- **चन्द्र-अर्कौ**: चन्द्रमा और सूर्य\n- **क्रान्ति-लिप्तिकाः समाः**: क्रान्ति की कलाएँ समान\n- **तदा**: तब\n- **व्यतीपातः**: व्यतीपात\n- **भगण-अर्धे**: भगण के आधे पर (180°)\n- **तयोः युतौ**: दोनों की युति/योग-अवस्था में\n\nWhen Moon and Sun are in opposite ayans, their declination-minutes are equal, and their conjunction (sum-yuti) stands at half a revolution, that is Vyatīpāta. The half-bhagaṇa fixes the 180° sum against Vaidhṛta’s full-circle meeting.\n\n### Formulation — Declination Equivalence Equation\n$$\\delta_\\odot(\\lambda_\\odot) = \\pm \\delta_m(\\lambda_m, \\beta_m), \\quad \\text{Condition for Mahāpāta}$$\n\nCritical for high-precision institutional astrological and almanac calculations."
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "metadata": {},
   "outputs": [],
   "source": "def check_vyatipata(sun_dec, moon_dec, tolerance=0.1):\n    return abs(abs(sun_dec) - abs(moon_dec)) < tolerance"
  },
  {
   "cell_type": "code",
   "execution_count": 22,
   "metadata": {},
   "outputs": [
    {
     "output_type": "stream",
     "name": "stdout",
     "text": "check_vyatipata(18.42, -18.39) → True\n"
    }
   ],
   "source": "print('check_vyatipata(18.42, -18.39)', \"→\", repr(check_vyatipata(18.42, -18.39)))"
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": "**Recorded output (dataset `codeOutput`, verified against the run above):**\n```\nInput: Sun declination +18.42°, Moon declination −18.39° (tolerance 0.1°)\ndeclination-magnitude difference = 0.0300°\ncheck_vyatipata(18.42, -18.39) → True\nComputed by executing this snippet (Python 3).\n```"
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": "## Chapter 12: भूगोलाध्यायः (Cosmography, Terrestrial Sphere & Prime Meridian)\n**Scope:** `Verses 12.1 – 12.90 (90 श्लोक in the edition) · shown here: 12.32` · **Reading:** `18 min study`\n\n### Overview\nComprehensive geography and cosmography. Establishes the spherical Earth (Bhugola), prime meridian through Ujjayini (75.7885° E), Lanka equatorial zero-point, Meru polar axis, and antipodal coordinates.\n\n### Ślokas & anvaya\n> **मध्ये समन्तादण्डस्य भूगोलो व्योम्नि तिष्ठति ।  \n> बिभ्रानः परमां शक्तिं ब्रह्मणो धारणात्मकाम् ।।**\n>\n> *madhye samantādaṇḍasya bhūgolo vyomni tiṣṭhati ।  \n> bibhrānaḥ paramāṃ śaktiṃ brahmaṇo dhāraṇātmakām ।।*\n>\n> **Meter:** सूर्य-सिद्धान्त 12.32\n>\n> **Source:** editions/surya-siddhanta-full-edition.html#v12-32 — Devanāgarī, IAST, padaccheda-anvaya and English rendering as printed in the edition (सूर्य-सिद्धान्त 12.32)\n\n- **मध्ये**: मध्य में\n- **समन्तात्**: चारों ओर से\n- **अण्डस्य**: अंड/ब्रह्माण्ड का\n- **भू-गोलः**: पृथ्वी-गोलक\n- **व्योम्नि**: आकाश में\n- **तिष्ठति**: स्थित है\n- **बिभ्राणः**: धारण किये हुए\n- **परमाम् शक्तिम्**: परम शक्ति\n- **ब्रह्मणः**: ब्रह्म की\n- **धारणा-आत्मकाम्**: धारण/स्थापन-स्वरूप\n\nAt the centre of the cosmic egg, on every side, the earth-globe stands in the sky, bearing Brahman’s supreme power whose very nature is to uphold and sustain.\n\n### Formulation — Deshantara Longitudinal Time Difference\n$$\\Delta t = \\frac{\\lambda_{\\text{local}} - 75.7885^\\circ}{360^\\circ} \\times 24 \\text{ hrs}, \\quad C_{\\text{earth}} = 4,967 \\text{ Yojanas}$$\n\nSS 1.62 names the prime meridian through Laṅkā, Rohītaka and Avantī (Ujjayinī)."
  },
  {
   "cell_type": "code",
   "execution_count": 23,
   "metadata": {},
   "outputs": [],
   "source": "def deshantara_time_correction(lon_deg, ujjain_lon=75.7885):\n    return (lon_deg - ujjain_lon) * 4.0 # in minutes of time"
  },
  {
   "cell_type": "code",
   "execution_count": 24,
   "metadata": {},
   "outputs": [
    {
     "output_type": "stream",
     "name": "stdout",
     "text": "deshantara_time_correction(83.0107) → 28.888800000000003\n"
    }
   ],
   "source": "print('deshantara_time_correction(83.0107)', \"→\", repr(deshantara_time_correction(83.0107)))"
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": "**Recorded output (dataset `codeOutput`, verified against the run above):**\n```\nInput: Kāśī longitude 83.0107° E (baseline: Ujjain 75.7885° E)\ndeshantara_time_correction(83.0107) → +28.8888 minutes of time\nComputed by executing this snippet (Python 3).\n```"
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": "## Chapter 13: ज्योतिषोपनिषदध्यायः (Armillary Sphere & Observational Instruments)\n**Scope:** `Verses 13.1 – 13.25 (25 श्लोक in the edition) · shown here: 13.3, 13.23` · **Reading:** `12 min study`\n\n### Overview\nMechanical engineering blueprints for constructing the Golayantra (armillary sphere), Kapalayantra (clepsydra/water clock), and self-rotating astronomical automatons.\n\n### Ślokas & anvaya\n> **भूभगोलस्य रचनां कुर्यादाश्चर्यकारिणीम् ।  \n> अभीष्टं पृथिवीगोलं कारयित्वा तु दारवम् ॥**\n>\n> *bhūbhagolasya racanāṃ kuryādāścaryakāriṇīm ।  \n> abhīṣṭaṃ pṛthivīgolaṃ kārayitvā tu dāravam ।।*\n>\n> **Meter:** सूर्य-सिद्धान्त 13.3\n>\n> **Source:** editions/surya-siddhanta-full-edition.html#v13-03 — Devanāgarī, IAST, padaccheda-anvaya and English rendering as printed in the edition (सूर्य-सिद्धान्त 13.3)\n\n- **भू-भ-गोलस्य**: पृथ्वी और खगोल (भूगोल+भगोल) की\n- **रचनां**: रचना/प्रतिमा\n- **कुर्यात्**: बनाए\n- **आश्चर्य-कारिणीम्**: आश्चर्य उत्पन्न करने वाली\n- **अभीष्टं**: इच्छित माप का\n- **पृथिवी-गोलं**: पृथ्वी-गोलक\n- **कारयित्वा**: बनवा कर\n- **तु दारवम्**: काष्ठ-निर्मित\n\nOne should construct a wonder-working model of the earth-and-sky sphere. First fashion a wooden terrestrial globe of the desired size; on that solid body the whole armillary apparatus will rest.\n\n> **ताम्रपात्रं अधश्छिद्रं न्यस्तं कुण्डे अमलाम्भसि ।  \n> षष्टिर्मज्जत्यहोरात्रे स्फुटं यन्त्रं कपालकम् ॥**\n>\n> *tāmrapātraṃ adhaśchidraṃ nyastaṃ kuṇḍe amalāmbhasi ।  \n> ṣaṣṭirmajjatyahorātre sphuṭaṃ yantraṃ kapālakam ।।*\n>\n> **Meter:** सूर्य-सिद्धान्त 13.23\n>\n> **Source:** editions/surya-siddhanta-full-edition.html#v13-23 — Devanāgarī, IAST, padaccheda-anvaya and English rendering as printed in the edition (सूर्य-सिद्धान्त 13.23)\n\n- **ताम्र-पात्रम्**: ताँबे का पात्र\n- **अधः-छिद्रम्**: नीचे छिद्र वाला\n- **न्यस्तम्**: रखा हुआ\n- **कुण्डे**: कुंड/हौद में\n- **अमल-अम्भसि**: निर्मल जल में\n- **षष्टिः**: साठ\n- **मज्जति**: डूबता है\n- **अहोरात्रे**: एक अहोरात्र (दिन+रात) में\n- **स्फुटम्**: स्पष्ट/यथार्थ\n- **यन्त्रम् कपालकम्**: कपालक यन्त्र\n\nA copper vessel with a hole beneath, set in a basin of pure water, sinks sixty times in a day-and-night — that is the accurate kapāla instrument.\n\n### Formulation — Clepsydra Inflow/Outflow Timing Calibration\n$$1 \\text{ Ghaṭī} = 24 \\text{ minutes} = 60 \\text{ Palas} = 3,600 \\text{ Vipalas} = 360 \\text{ Prāṇas}$$\n\nCount correspondence between the prāṇa time-unit and arc division (SS 1.11: 6 prāṇa = 1 pala, 60 pala = 1 ghaṭī; 21,600 prāṇa a day, 21,600 arcminutes a circle) — not a physiological claim."
  },
  {
   "cell_type": "code",
   "execution_count": 25,
   "metadata": {},
   "outputs": [],
   "source": "def time_to_ghati(hours, minutes, seconds):\n    total_sec = hours * 3600 + minutes * 60 + seconds\n    return total_sec / 1440.0 # 1 ghati = 1440 seconds"
  },
  {
   "cell_type": "code",
   "execution_count": 26,
   "metadata": {},
   "outputs": [
    {
     "output_type": "stream",
     "name": "stdout",
     "text": "time_to_ghati(12, 0, 0) → 30.0\n"
    }
   ],
   "source": "print('time_to_ghati(12, 0, 0)', \"→\", repr(time_to_ghati(12, 0, 0)))"
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": "**Recorded output (dataset `codeOutput`, verified against the run above):**\n```\nInput: 12:00:00 elapsed from midnight (per this snippet's convention)\ntime_to_ghati(12, 0, 0) → 30.00 ghati (1 ghati = 1,440 seconds)\nComputed by executing this snippet (Python 3).\n```"
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": "## Chapter 14: मानाध्यायः (Reckoning of Time & Eras (Nine Mana Scales))\n**Scope:** `Verses 14.1 – 14.27 (27 श्लोक in the edition) · shown here: 14.1` · **Reading:** `14 min study`\n\n### Overview\nThe crowning synthesis of the nine measures of time named in SS 14.1: brāhma, divya, pitrya, prājāpatya, bārhaspatya (guru), saura, sāvana, cāndra and ārkṣa (nākṣatra).\n\n### Ślokas & anvaya\n> **ब्राह्मं दिव्यं तथा पित्र्यं प्राजापत्यं गुरोस्तथा ।  \n> सौरं च सावनं चान्द्रं आर्क्षं मानानि वै नव ।।**\n>\n> *brāhmaṃ divyaṃ tathā pitryaṃ prājāpatyaṃ gurostathā ।  \n> sauraṃ ca sāvanaṃ cāndraṃ ārkṣaṃ mānāni vai nava ।।*\n>\n> **Meter:** सूर्य-सिद्धान्त 14.1\n>\n> **Source:** editions/surya-siddhanta-full-edition.html#v14-01 — Devanāgarī, IAST, padaccheda-anvaya and English rendering as printed in the edition (सूर्य-सिद्धान्त 14.1)\n\n- **ब्राह्मं**: ब्रह्मा-मान\n- **दिव्यं**: देव/दिव्य-मान\n- **पित्र्यं**: पितृ-मान\n- **प्राजापत्यं**: प्रजापति-मान\n- **गुरोः**: गुरु/बृहस्पति-मान\n- **सौरं**: सूर्य-मान\n- **सावनं**: सावन/नागरिक-दिन-मान\n- **चान्द्रं**: चन्द्र-मान\n- **आर्क्षं**: नक्षत्र/तारकीय-मान\n- **मानानि वै नव**: ये नौ ही काल-माप हैं\n\nThere are nine measures of time: those of Brahmā, of the gods, of the pitṛs, of Prajāpati, of the preceptor (Jupiter), the solar, the civil (sāvana), the lunar, and the sidereal (ārkṣa). The verse simply names the full set before distinguishing which of them govern ordinary reckoning.\n\n### Formulation — Ratio of Sidereal to Solar Civil Revolutions\n$$\\frac{\\text{Sidereal Days}}{\\text{Civil Days}} = \\frac{1577917828 + 4320000}{1577917828} = 1.0027379093$$\n\nSidereal days = civil days + the Sun's revolutions: 1,577,917,828 + 4,320,000 = 1,582,237,828, the stellar risings of SS 1.34."
  },
  {
   "cell_type": "code",
   "execution_count": 27,
   "metadata": {},
   "outputs": [],
   "source": "def sidereal_day_seconds(civil_sec=86400.0, yuga_days=1577917828, yuga_years=4320000):\n    ratio = yuga_days / (yuga_days + yuga_years)\n    return civil_sec * ratio"
  },
  {
   "cell_type": "code",
   "execution_count": 28,
   "metadata": {},
   "outputs": [
    {
     "output_type": "stream",
     "name": "stdout",
     "text": "sidereal_day_seconds() → 86164.10120312205\n"
    }
   ],
   "source": "print('sidereal_day_seconds()', \"→\", repr(sidereal_day_seconds()))"
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": "**Recorded output (dataset `codeOutput`, verified against the run above):**\n```\nsidereal_day_seconds() → 86164.1012 seconds ≈ 23h 56m 4.10s\n(from the ratio 1,577,917,828 / (1,577,917,828 + 4,320,000) applied to 86,400 s)\nComputed by executing this snippet (Python 3).\n```"
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "name": "python",
   "version": "3.12"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}