# Planetary gearbox speed calculation - Simultaneous equations

I'm looking to calculate the ratio of a planetary gear train. With the ultimate goal of producing a spreadsheet/calculator to show the state of the gearbox (i.e. all shaft speeds) based on applied constraints. A gear set consists of Ring Gear, Planet Gear, Sun Gear. The sick diagram is the easiest way to show the interactions and constraints. The rotational speed of any part can be found by:

(R+S)*ωp=R*ωr + S*ωs
R - Number of teeth on ring
S - Number of teeth on sun
ωr = Ring gear speed
ωp = Planet rotational speed
ωs = Sun gear rotational speed

Single Planet Case This is the type of thing you'll find with a generic google. Output speed can be directly calculated based on the constraints. In this case we have three states, two constraints and one gear equation to find the output. Easy peasy.

Multiple Planets This case is an example of a more tricky case. 6 unknowns, 4 constraints, 2 gear equations. This has to be solved simultaneously due to the interactions between the gear sets:
Sun Gear 1 = Sun Gear 2 = intermediate
Planet Carrier 1 = Ring Gear 2 = output.

I can do this by hand with substitution. I'd like to automate it as the cases become more complicated very quickly.

Eg 4 gear sets = 12 unknowns
4 gear equations
5 fixed constraints (due to gearbox architecture)
3 variable constraints (used to select different gears)
So there is enough information to solve it. It's just a pain doing it by hand.

What's the best way to automate this using Excel or similar?