# Optimum number of cog teeth for two step helical gearbox

Note: Cross-posted at http://community.wolfram.com/groups/-/m/t/137895?p_p_auth=8QnKtT9I.

I am to design a two step gearbox. The first step is to choose the number of teeth in each cog wheel in order to achieve a gear ratio of 17.3. In other words:

 (N1 N2)/(n1 n2) == 17.3


where N1 and N2 are the number of teeth in gear 1 and 2, and n1 and n2 are the number of teeth in pinion 1 and 2. Is it possible to get Mathematica to "guess" the lowest number of teeth possible and still get as close as possible to 17.3? The number of teeth in the pinions must not be lower than 20. In addition, the number of cog teeth in the gears must not be divisible, i.e. only common factor has to be 1.

-
Is this a question about the software Mathematica? It looks like you might have intended to post this at our sister site, math.SE – Verbeia Oct 12 '13 at 20:24

I think in general you might have to enforce the gcd (divisibility) constraint after the fact. For this particular example I get a result on the first try that has those numbers relatively prime, so we can accept that solution.

Anyway, here is the code. For objective function I sum the teeth and add a penalty term for that ratio straying (discrepancing itself?) from 17.3.

obj = c1 + c2 + p1 + p2 + (c1*c2 - 17.3*p1*p2)^2;
cs1 = {p1 >= 20, p2 >= 20, c1 >= 2, c2 >= 2};

In[368]:= {min, vals} =
NMinimize[{obj,
Flatten[{cs1, Element[{c1, c2, p1, p2}, Integers]}]}, {c1, c2, p1,
p2}]

Out[368]= {223., {c1 -> 91, c2 -> 76, p1 -> 20, p2 -> 20}}


As 91 is prime, it is of course relatively prime to 76, so this set of values appears to suit the requirements.

-
Adding MaxIterations -> 500 comes up with a superior solution: {c1 -> 79, c2 -> 92, p1 -> 21, p2 -> 20}; delta -0.0047619 – Mr.Wizard Oct 12 '13 at 21:57
Actually in v7 I get that result anyway. – Mr.Wizard Oct 12 '13 at 21:59

Another approach is to use FindInstance:

FindInstance[(172/10 <= (N1 N2)/(n1 n2) <= 174/10) &&
(n1 >= 20) && (n2 >= 20) && (N1 > 10) && (N2 > 10), {n1, n2, N1, N2}, Integers]

{{n1 -> 20, n2 -> 20, N1 -> 11, N2 -> 630}}


By playing around with the exact criteria used, it is possible to find many answers

FindInstance[(Abs[(N1 N2)/(n1 n2) - 17.3] <= 0.02) && (n1 >= 25) && (n2 >= 25)
&& (N1 > 10) && (N2 > 10) && (n1 + n2 + N1 + N2 < 300), {n1, n2, N1, N2}, Integers]

{{n1 -> 25, n2 -> 25, N1 -> 56, N2 -> 193}}

-