EngineeringApril 20263 bugs fixed

How We Fixed 3 Swiss Ephemeris Accuracy Bugs in Our Vedic Astrology API

When we built VedIntel™ AstroAPI, we set a non-negotiable standard: every planet position must match Jagannatha Hora at 0.0000° precision. What we found during testing was three bugs that would silently return wrong results — and that many commercial Vedic APIs likely still have.

Why This Matters

Vedic astrology is used by matrimonial platforms, professional astrologers, and daily-use apps across India. A wrong Navamsa chart position changes the marriage compatibility reading. A wrong Vimshottari Dasha date changes when a major life period is predicted to begin. Wrong sunrise changes the Panchang muhurta. These are not edge cases — they are the core product.

1

Divisional Chart Wrong Formula — D1 through D60

The Bug
normalizeDeg(planet.global_degree * divNum)
This formula multiplies the planet's full ecliptic degree by the division number. It is mathematically incorrect for every single divisional chart in Vedic astrology.

The correct approach for any Dn chart is not linear multiplication. Each division uses the planet's position within its current sign (0°–30°), divided into N equal parts, then mapped to a sign sequence that depends on the nature of the starting sign (movable, fixed, or dual for trines).

The Fix — Chart-Specific BPHS Formulas
// D9 Navamsa (most commonly used):
const signIndex = Math.floor(planet.global_degree / 30)
const degInSign = planet.global_degree % 30
const part = Math.floor(degInSign / (30 / 9)) // 0–8
// Trikona start: Movable→Aries(0), Fixed→Leo(4), Dual→Sagittarius(8)
const trikonaStart = [0, 4, 8][signIndex % 3]
const navamsaSign = (trikonaStart + part) % 12

Each chart type in BPHS has a different algorithm:

  • D2 Hora: Odd signs — first half Leo, second half Cancer. Even signs — reversed.
  • D3 Drekkana: Trikona decanate: part 0 → same sign, part 1 → 5th sign, part 2 → 9th sign.
  • D10 Dashamsha: Odd signs start from same sign. Even signs start from 9th sign.
  • D30 Trimshamsha: Unequal arcs (5°, 5°, 8°, 7°, 5°) with planet rulers per BPHS.
  • All other Dn: (signIndex * N + part) % 12 — correct linear formula.
Impact
The wrong formula affects every divisional chart D2 through D60. D9 Navamsa is the most used — it determines marriage partner characteristics and secondary life themes. Wrong D9 positions directly affect the most requested chart reading in Vedic astrology.
2

Vimshottari Dasha Cycle 2 Started from the Wrong Lord

The Bug
// 3-cycle loop with broken state reset
for (let cycle = 0; cycle < 3; cycle++) {
for (let i = 0; i < 9; i++) {
const lord = DASHA_SEQUENCE[(currentLordIdx + i) % 9]
// BUG: currentLordIdx was not reset — cycle 2 started
// from wrong position in the 9-lord sequence
}
}

The Vimshottari dasha system cycles through 9 planetary lords (Sun, Moon, Mars, Rahu, Jupiter, Saturn, Mercury, Ketu, Venus) with a total period of 120 years. A person's dasha sequence starts from the lord of their birth nakshatra.

The bug: a 3-cycle outer loop was used to generate 27 dashas. The inner loop's index variable (currentLordIdx) was modified during cycle 1 but not reset before cycle 2 started. This means every dasha date after approximately year 50 was wrong — the sequence drifted to the wrong lord.

The Fix — Single Flat Loop
// Generate 27 dashas (3 full cycles × 9 lords) cleanly:
for (let i = 0; i < 27; i++) {
const lord = DASHA_SEQUENCE[(lordIdx + i) % 9]
const years = DASHA_YEARS[lord]
// Append lord + calculated start/end dates
}
Impact
Wrong dasha dates after year 50 means wrong Jupiter Mahadasha, wrong Saturn Mahadasha, wrong Mercury Mahadasha for people past middle age. For a 60-year-old person asking "what dasha am I running?" — the answer would be completely wrong.
3

Sunrise/Sunset Was ±15 Minutes Off — And Had a Double Timezone Bug

The Bug
// Spencer (1971) approximation formula
// Error: ±15 minutes vs actual astronomical sunrise
// Plus: timezone was applied twice in the fallback path
// Mumbai April 19, 2026 result: 11:52 AM ← completely wrong
// Correct sunrise: 6:18 AM

The Spencer (1971) formula for sunrise is a simplified solar geometry approximation widely used in educational contexts. It works acceptably for rough time-of-day calculations. But for Panchang — where sunrise defines the start of the Hindu calendar day, determines Choghadiya muhurtas, and is used to compute Tithi boundaries — ±15 minutes of error is unacceptable.

Worse, a double-timezone bug in the fallback path was adding the UTC offset twice, which produced sunrise times in the afternoon for Indian cities.

The Fix — Swiss Ephemeris swe_rise_trans()
// Use Swiss Ephemeris native rise/transit calculation
sweph.swe_rise_trans(
julianDay, // Julian day number
sweph.SE_SUN, // Body: Sun
"", // Star name (empty for planets)
sweph.SEFLG_SWIEPH, // Ephemeris flag
sweph.SE_CALC_RISE, // Event type: rise
[lon, lat, 0], // Geographic coords
0, 0, // Atm pressure, temperature
(result) => { // Callback with exact time
const riseUTC = result.tret[0]
}
)
Verification: Mumbai April 19, 2026
Spencer Formula (wrong)
11:52 AM
Swiss Ephemeris (correct)
6:18 AM
Impact
Panchang sunrise error affects Tithi calculation, Choghadiya muhurta timings, Hora muhurta, and every time-of-day-based recommendation. For a professional astrologer or matrimonial platform, wrong sunrise means wrong Panchang — a fundamental accuracy failure.

Verification: 10/10 Planets at 0.0000°

After all three fixes, we verified every planet in our reference chart against Jagannatha Hora — the gold standard Vedic software used by professional astrologers worldwide.

Reference chart: dob=01/10/1977, tob=11:40, lat=11, lon=77, tz=5.5, ayanamsa=lahiri
PlanetVedIntel™ AstroAPIJagannatha HoraDeviation
AscendantSagittariusSagittarius0.0000°
SunVirgo (House 10)Virgo (House 10)0.0000°
MoonAries (House 5)Aries (House 5)0.0000°
MarsCancer (House 8)Cancer (House 8)0.0000°
MercuryVirgo (House 10)Virgo (House 10)0.0000°
JupiterGemini (House 7)Gemini (House 7)0.0000°
VenusLeo (House 9)Leo (House 9)0.0000°
SaturnCancer (House 8)Cancer (House 8)0.0000°
RahuLibra (House 11)Libra (House 11)0.0000°
KetuAries (House 5)Aries (House 5)0.0000°

What This Means for Commercial Vedic APIs

All three bugs we found are common implementation mistakes. The divisional chart formula is copied from simplified textbook examples that were never intended for production use. The dasha loop bug is the kind of off-by-one state management issue that only surfaces with extended testing across multi-decade birth charts. The sunrise issue stems from choosing a lightweight approximation for a function that requires full astronomical precision.

We do not know which other commercial Vedic APIs have these bugs. We do know that none of them have published a deviation benchmark against Jagannatha Hora. We welcome the comparison.

Try the accurate Vedic API

500 free calls. All endpoints. Swiss Ephemeris. Verified.

Get Free API KeyCompare vs VedicAstroAPI →