Gear Train Calculator

Here’s a Gear Train Calculator that can come up with gear trains of varying complexity to approximate arbitrary ratios from input to output. This is a problem of unbounded difficulty; it is NP-hard. Therefore, this tool is heuristic.

For reasonable inputs, it is practically instantaneous.

Let’s look at an unreasonable example, approximating pi (in particular, the approximation 3.141592653589793; which is the default example) with two stages:

Even four stages calculates almost instantaneously (though slowly enough that I briefly saw an intermediate result flash before being replaced by a final result), and gets twice as many digits of accuracy:

Going to six stages explodes in complexity. It takes a while even to find an intermediate result (less accurate than four stages):

After about a minute, it finally finds something more accurate than four stages:

After maybe another minute, 11 decimal digits of accuracy:

A few minutes later, it still has the same result after covering 1% of its search space. I’ll leave this running for a while! :smiling_face:

2 Likes

Nice find.

1 Like

Firefox seems to have decided that it should throttle the script when the tab is in the background, or the screen saver is up, so it’s hard to keep making progress here, but here’s one that’s closer though still 11 decimal digits:

I would like to see you machine within the degree of error! :astonished:

1 Like

Sometimes if I leave that tab open while doing something else, it makes progress! I now have a solution to my entirely theoretical problem that is within one part in 23.6 trillion, 12 decimal digits…

2 Likes

At first I was surprised it’s taking it that long to calculate this. But then I did the math for your hypothetical 90 options for each gear, and 12 gears to try… 90^12 = 2.82429536481 x 10^23 possible combinations so I guess that makes more sense. :sweat_smile:

2 Likes

He cuts out a lof of equivalent possibilities rather than the brute-force permutations. I found out about his tool from his replies on a Physics Forums post from someone asking for help computing gear ratios for making an orrery, where he goes into detail on how he constructed his algorithm.

Fortunately the Gear Train Calculator performs the calculation in much less time. It does not try out all permutations in the manner suggested.

But it’s still a lot of work! :smiling_face:

1 Like

Yeah, I figured it’s optimizing some (remove duplicates, rule out edge cases) but still a lot.

1 Like

By leaving my personal computer on the calculator tab while working on my work computer during the day, this finished, and it never found a better match than it found somewhere in the first 8% of the search space.