A yoga in a birth chart is a fixed pattern of planets that tradition gives a name. Because the pattern is fixed, a program can test for it with a few lines of code. This post covers two of them, Gajakesari yoga and raj yoga. Both come down to counting signs.

Gajakesari yoga forms when Jupiter sits 1, 4, 7 or 10 signs from the Moon. The Moon's own sign counts as 1.

Raj yoga forms when the ruler of house 4, 7 or 10 is joined with the ruler of house 5 or 9. Joined means they sit in the same sign, sit in each other's signs, or aspect each other.

We ran 2,000 random births through our API's POST /v1/yogas route. Gajakesari yoga formed in 662 of them, or 33.1%. Raj yoga formed in 1,254, or 62.7%.

The tests are simple, but the settings around them are not fixed. Some apps count house 1 for raj yoga, and some add extra conditions on Jupiter. Each choice moved our counts by a wide margin, from 14.1% to 95.9% across the readings we tried. This post shows the code, John Doe's real result and those counts.

What a yoga is to a program

To a program, a yoga is a yes or no question about where the planets sit. It needs three facts you already have from a chart. They are each planet's sign, the lagna (the sign rising in the east at birth) and the ruler of each sign.

Houses come from the lagna. Our API uses whole-sign houses, under rule CH-06. The rising sign is house 1, the next sign is house 2, and so on around the zodiac. So a planet's house is just a count of signs from the lagna.

Two planets count as "together" when they share a sign, however many degrees apart they are. That is rule GAP-07. An aspect (drishti) is a planet's influence on another house. Every planet aspects the 7th house from itself. Mars also aspects the 4th and 8th, Jupiter the 5th and 9th, and Saturn the 3rd and 10th, as rule AS-03 states. The drishti glossary entry has the counting in more detail.

The API answers every yoga it checks in one of two lists. The formed list holds the yogas found in the chart. The not_formed list holds the ones it checked and did not find, with the reason. Each item carries the rule it tested in plain words. In our survey, the formed list held from 4 to 29 entries per chart, 13.0 on average.

Gajakesari yoga: the rule as code

Gajakesari means "elephant and lion". The test looks only at two planets. Start at the Moon's sign as 1 and count forward until you reach Jupiter's sign. If the count is 1, 4, 7 or 10, the yoga is formed. Those four places are the kendras (the angles) counted from the Moon.

// Signs are numbered 1 (Aries) to 12 (Pisces).
const KENDRA = [1, 4, 7, 10];

// Count the signs from one sign to another, with the first sign as 1.
function countFrom(startSign, sign) {
  return ((sign - startSign + 12) % 12) + 1;
}

function hasGajakesari(signs) {
  return KENDRA.includes(countFrom(signs.Moon, signs.Jupiter));
}

The count starts from the Moon, not from the lagna. Our rulebook says so in rule YG-12. In our survey, 695 births had Jupiter in a kendra counted from the lagna. Counted from the Moon, the number was 662. The two groups were far from the same: only 233 births were in both.

Raj yoga: the rule as code

Raj yoga needs more steps, because it is about house rulers, not planets in fixed places. Each sign has a ruling planet. Mars rules Aries, Venus rules Taurus, and so on. So the ruler of a house depends on the lagna.

The kendras are houses 1, 4, 7 and 10. The trikonas (the trines) are houses 1, 5 and 9. House 1 is in both groups, so its ruler could pair with every other ruler on the list. Our API leaves house 1 out of both sides, under rule YG-30. The survey below shows how much that choice changes the count.

const SIGN_LORD = {
  1: "Mars", 2: "Venus", 3: "Mercury", 4: "Moon", 5: "Sun", 6: "Mercury",
  7: "Venus", 8: "Mars", 9: "Jupiter", 10: "Saturn", 11: "Saturn", 12: "Jupiter",
};
const ASPECTS = {
  Sun: [7], Moon: [7], Mars: [4, 7, 8], Mercury: [7],
  Jupiter: [5, 7, 9], Venus: [7], Saturn: [3, 7, 10],
};

function lordOfHouse(lagnaSign, house) {
  return SIGN_LORD[((lagnaSign - 1 + house - 1) % 12) + 1];
}

function aspects(planet, fromHouse, toHouse) {
  return ASPECTS[planet].some((n) => ((fromHouse - 1 + n - 1) % 12) + 1 === toHouse);
}

function howJoined(a, b, signs, lagnaSign) {
  const houseA = countFrom(lagnaSign, signs[a]);
  const houseB = countFrom(lagnaSign, signs[b]);
  if (signs[a] === signs[b]) return "conjunct";
  if (SIGN_LORD[signs[a]] === b && SIGN_LORD[signs[b]] === a) return "in exchange";
  if (aspects(a, houseA, houseB) && aspects(b, houseB, houseA)) return "in mutual aspect";
  return null;
}

function rajYogaLinks(signs, lagnaSign) {
  const kendraLords = new Set([4, 7, 10].map((h) => lordOfHouse(lagnaSign, h)));
  const trikonaLords = new Set([5, 9].map((h) => lordOfHouse(lagnaSign, h)));
  const links = [];
  for (const a of kendraLords) {
    for (const b of trikonaLords) {
      if (a === b) continue; // one planet ruling both is a yogakaraka, not a pair
      const how = howJoined(a, b, signs, lagnaSign);
      if (how) links.push(`${a} and ${b} ${how}`);
    }
  }
  return links;
}

The API makes two more choices. First, the rulers of houses 9 and 10 get their own name, dharma-karmadhipati yoga, under rule YG-13. When that pair is joined, the API reports it there and not again under raj yoga. Second, a single planet that rules a kendra as well as a trikona is not a pair. The API names it as the yogakaraka instead, under rule CH-09. In our survey, 993 of 2,000 births had one.

We ran both code blocks above on our 2,000 survey births and compared them with the API. The hasGajakesari function agreed with the API on all 2,000. The rajYogaLinks function found a link in exactly the charts where the API reported raj yoga or dharma-karmadhipati yoga, again all 2,000.

A worked example: John Doe

John Doe was born on Aug 15, 1990, at 10:30 AM in New York. His lagna is Virgo. His Moon is in Taurus and his Jupiter is in Cancer.

Gajakesari. Counting from Taurus, Cancer is the 3rd sign. A count of 3 misses all four kendra places, so John has no Gajakesari yoga. Jupiter is in house 11 from his lagna, so it is not in a kendra from there either. This holds even though his Jupiter is exalted, in its strongest sign. The test asks only where Jupiter sits, not how strong it is.

Raj yoga. For a Virgo lagna, Jupiter rules houses 4 and 7, and Mercury rules house 10. Saturn rules house 5, and Venus rules house 9. Jupiter and Venus both sit in Cancer, so they are conjunct. That one link forms the yoga. No other pair is joined.

This is the API's answer, shortened. John Doe, born Aug 15, 1990, at 10:30 AM in New York:

{
  "formed": [
    {
      "name": "Raja",
      "category": "raja yoga",
      "rule": "a lord of a kendra (4, 7, 10) and a lord of a trikona (5, 9) are conjunct, in exchange, or in mutual aspect",
      "detail": "Jupiter and Venus conjunct"
    }
  ],
  "not_formed": [
    {
      "name": "Gajakesari",
      "rule": "Jupiter in a kendra (1,4,7,10) counted FROM THE MOON",
      "reason": "Jupiter is 3 from the Moon"
    }
  ],
  "lagnesh": "Mercury",
  "yogakaraka": null
}

The call is POST /v1/yogas with the birth date, time and place. The full response listed 15 formed yogas for John. One of them is Rahu-Ketu Raja yoga, a separate rule for Rahu and Ketu (YG-97). This post counts only the entry named Raja. The field list is in the API reference.

How common each yoga is

We picked 2,000 random birth moments between 1950 and 2009. Each one was in New York, Chicago, Houston or Los Angeles. For each birth, we called POST /v1/yogas and POST /v1/planets, then counted.

Result under the API's rules

Births

Share

Gajakesari yoga formed (YG-12)

662

33.1%

Raj yoga formed (YG-30)

1,254

62.7%

Dharma-karmadhipati yoga formed (YG-13)

436

21.8%

Raj yoga or dharma-karmadhipati yoga

1,451

72.5%

Both Gajakesari and raj yoga

437

21.9%

Neither Gajakesari nor raj yoga

521

26.1%

Gajakesari is close to one in three. That follows from the rule. Jupiter can be 1 to 12 signs from the Moon, and 4 of the 12 places count. In our births, each of the 12 places held between 137 and 194 charts. The four kendra places held 168, 164, 167 and 163. One site counted the charts its own users entered and also landed near one in three. Another page gives about 25%.

Raj yoga formed in most charts. Under the API's rule, 62.7% of births had it. Of the 746 births where the API reported no raj yoga, 197 had only the 9th and 10th rulers joined. Those charts got dharma-karmadhipati yoga instead.

The lagna moves the raj yoga count. The rulers of each house change with the rising sign, so some lagnas link up more often. A Capricorn lagna formed raj yoga in 66 of 134 births, or 49.3%. A Taurus lagna formed it in 127 of 148, or 85.8%.

Across all charts, we found 2,227 joined pairs of a kendra ruler and a trikona ruler. Sitting together was the most common link, with 1,299 pairs. Mutual aspect gave 705, and an exchange of signs gave 223.

To see the planets and houses behind any of these counts, open a chart in our free kundli tool. It shows each planet's sign and house for the birth place.

Banner inviting readers to open the free kundli tool and see the sign and house of every planet in a chart

Gajakesari under five readings

Not every source uses the short rule. One translation of Parashara's classic text adds three conditions. Jupiter may sit in a kendra from the lagna or from the Moon. It must not be debilitated (in its weakest sign), combust (too close to the Sun) or in an enemy's sign. It must also be joined or aspected by a helpful planet. Another site says the count runs only from the Moon.

We scored the same 2,000 births under each reading. For the last row, we counted Venus, Mercury and the Moon as the helpful planets. That is our own simple choice for this test.

Reading

Births

Share

Our API: a kendra from the Moon (YG-12)

662

33.1%

A kendra from the lagna only

695

34.8%

A kendra from the Moon or the lagna

1,124

56.2%

From the Moon, with Jupiter not debilitated, combust or in an enemy's sign

372

18.6%

From the Moon or the lagna, Jupiter passing those checks, and joined or aspected by Venus, Mercury or the Moon

281

14.1%

The extra Jupiter checks cut the count from 662 to 372. Of the 662 charts the API flagged, 220 had Jupiter in an enemy's sign. Jupiter was combust in 45, and debilitated in 44.

The API keeps those checks out of the yes or no. It still gives you the facts. POST /v1/planets returns each planet's dignity and a combust flag. So you can show "Gajakesari, with Jupiter in an enemy's sign" next to the result.

Raj yoga under six readings

Raj yoga splits even more. Several sites we read count house 1 on both sides. We also tried a looser test that accepts a one-way aspect, where only one of the two planets looks at the other. Our API needs a mutual aspect.

Reading

Births

Share

Our API: the Raja entry only (YG-30)

1,254

62.7%

Any 4, 7 or 10 ruler joined with a 5 or 9 ruler, the 9th and 10th pair included

1,451

72.5%

The same, joined only by sitting in one sign

1,006

50.3%

The same, with a one-way aspect also counted

1,775

88.8%

House 1 counted on the kendra side and the trikona side

1,717

85.8%

House 1 counted, and a one-way aspect also counted

1,918

95.9%

Bar chart of 2,000 random births scored under several readings of each yoga: Gajakesari from 14.1% to 56.2% with the API's rule at 33.1%, and raj yoga from 50.3% to 95.9% with the API's rule at 62.7%

With house 1 counted, only 283 of 2,000 births had no joined pair. Six charts in the survey had 9 pairs each. So when a user says "the other app found five raj yogas in my chart", check the house 1 setting.

What to show your users

Show the rule next to the result. Every item from POST /v1/yogas carries its rule text, so your screen can say exactly what was tested. For a missing yoga, show the reason from not_formed. John's answer, "Jupiter is 3 from the Moon", explains itself.

Show the pair, not just the name. The raj yoga detail field names the planets and how they are joined, such as "Jupiter and Venus conjunct". If a user's chart has a yogakaraka, the response names it in its own field.

Keep the tone calm. A yoga is a pattern that tradition names, not a promise of fame or money. Our counts show how ordinary these two are: about one chart in three for Gajakesari, and more than half for raj yoga. Present each one as a small strength, and avoid "you will be rich" language. Our yogas and doshas feature page shows the full response for yogas and for the dosha checks.

Banner for the yogas and doshas API page, which lists each yoga found or not found with the rule it tested

The short definitions live in the glossary entries for raj yoga and Gajakesari yoga. For a check where apps disagree for the same reasons, see our post on how the kaal sarp dosh check works.

In our survey, every reading used the same planet positions. Gajakesari ran from 14.1% to 56.2%, and raj yoga from 50.3% to 95.9%. The planets stayed the same in every row. So choose your rule with care, and show it to your users.