Why I built this
The Surya Siddhanta is a Sanskrit astronomy treatise. Its received text dates to somewhere between the fifth and tenth centuries CE, and its fourteen chapters give complete procedures for planetary positions, eclipses, conjunctions, heliacal risings, the lunar crescent and the calendar. Ebenezer Burgess translated it into English in 1860, and panchang makers relied on it for centuries.
People have read it closely for a long time. Far fewer have run it. You can understand a rule in words and still have no idea how to execute it for a particular date, because programming it forces you to decide on constants, units, the clock you are counting in and the order the corrections are applied. I wanted to make those decisions explicit, put them in code, and then measure how far the results sit from modern astronomy.
This became my M.Tech project in the Department of Computer Science and Engineering at IIT Jodhpur, supervised by Dr. Dinesh Mohan Joshi, under the title “Surya Siddhanta Computational Library with AI-Powered Query Interface”. The objectives were:
- implement the computable methods across all fourteen chapters,
- make every calculation inspectable, down to the verse that authorises it,
- evaluate the planetary longitudes against a modern reference under clearly stated conventions,
- give people who will never call a Python function a way in, through a web app and a chat assistant.
What it is
At the centre is a Python library, published on PyPI as surya-siddhanta and imported as suryasiddhanta. It has one module per chapter of the book (ch01_mean_motions.py through ch14_reckoning_time.py), so a function’s place in the code maps to a section of the text. The only runtime dependency is NumPy. No modern ephemeris feeds the historical calculations; everything comes from the text’s own revolution counts, epicycles and sine table.
There are 224 public functions and 1,256 tests. Every function cites the verses it implements, and wherever the text leaves a step unstated and I had to fill it from commentary, the result carries a source label saying so. Many tests are pinned to a specific verse or to a worked example printed in Mahavir Prasad Shrivastava’s Hindi Vigyan Bhashya, which I used as the second textual source next to Burgess.
If you only care about one body, there is a planet-wise view on top of the chapters:
| |
These call the same chapter functions underneath, so both imports give identical results.
The web app
The live site has a React frontend over a FastAPI backend, and it is organised into three areas.
The explorer pages cover each chapter group: planet positions, panchanga, lunar and solar eclipses, conjunctions, stars, heliacal events, the Moon, the patas, cosmography, instruments (with an interactive 3D armillary sphere) and place and time. There is also a daily panchanga and a reader for all fourteen chapters that walks through each calculation step by step.
The learning section has guided lessons for the Sun, Moon, Mars, Mercury, Venus, Jupiter, Saturn and Rahu. Each one ties a date, a diagram and a historical rule together. The Mars lesson, for example, takes you through the five positions of the correction sequence (mean place, half sighra, half manda, whole manda, whole sighra) and shows on a dial how each step moves the planet.
The Universe Explorer is a 3D scene built with three.js. You can step through time, follow four short guided tours and switch between the historical model and modern JPL positions to see how the two pictures of the sky differ.
There is also an assistant called “Surya” you can ask in plain language, such as “where was Jupiter on 1 January 628 CE?”. It answers by calling the library’s functions and searching the verse corpus, so its numbers come from the code and its quotes come from the text.
Measuring it against NASA JPL
The Research Explorer page holds the part I find most interesting. I compared the library’s longitudes for the Sun, Moon, Mercury, Venus, Mars, Jupiter, Saturn and Rahu with JPL’s DE440 ephemeris at 40,176 ten-day epochs from 1550 to 2649 CE.
Through 2249 CE, the per-century RMS longitude error is 1.14 to 1.93 degrees for the Sun, 1.69 to 2.29 degrees for the Moon, and 1.88 to 9.45 degrees for the five planets. A good share of the solar drift traces back to one number: the text’s sidereal year is about 3.4 minutes too long, so every longitude tied to the Sun falls behind by 8.5 arcseconds a year. Over the 1,100-year window that adds up to 2.6 degrees.
The clock matters as much as the formulas. The text counts days from midnight at Ujjain in local mean time, while DE440 runs on Terrestrial Time. The longitude offset alone is 5.05 hours, and the Moon moves about 0.55 degrees an hour. For the Moon in 1550 to 1649, aligning the clocks brings the RMS error down from 3.99 degrees to 1.69 degrees without changing a single formula. The text’s precession model is also worth watching: it is an oscillation rather than a steady drift, it reverses in 2299 CE, and after that the errors for every body from the Sun through Mars climb past 11 degrees by the last century in the window.
What running the text taught me
Turning verses into code that has to produce a number exposed places where a perfectly reasonable reading gives a wrong answer. I documented nine of them. The most dramatic is the mean place of Mercury and Venus: read verse i.29 without i.31-32 and Mercury ends up 153 degrees from the Sun, which it never is. Another is the epoch. If you confuse the text’s day count with Universal Time, sidereal time rotates by about 76 degrees. Once I kept the two apart, a printed parallax example moved from 3.83 ghatikas to 1.16, against the book’s 1.06.
Both write-ups, the DE440 accuracy study and the computational edition, are in the repository along with the code, data and reproduction steps.
Tech stack
- Calculation core: Python 3.9+, NumPy, pytest
- Backend: FastAPI, Pydantic, Uvicorn
- Frontend: React 18, TypeScript, Vite, React Router, three.js with React Three Fiber and Drei, KaTeX, react-markdown
- AI assistant: OpenAI-compatible tool-calling agent (OpenRouter or DeepSeek by default, or any compatible endpoint such as Ollama), with one shared tool registry behind both the chat route and the MCP server
- Retrieval: SQLite FTS5 search over the 500 Burgess verses, and BM25 over the Vigyan Bhashya commentary
- MCP server: the same calculation and corpus tools served over stdio for clients such as Claude Desktop and Claude Code
- Evaluation: Skyfield with the JPL DE440 kernel
- Deployment: Docker, nginx, Render
- Browser checks: Playwright
Try it
The app is live at surya-siddhanta-latest.onrender.com. It runs on Render’s free tier, so the first load can take a little while if the service has been asleep. To use the library directly:
| |
The source code, tests and papers are on GitHub at github.com/mrashutoshnigam/Surya_Siddhanta.






