[Math] How to calculate the diameter of a bicycle chainring from the number of teeth

geometry

One of the requirements when designing a bicycle frame is clearance between the chainstay and the teeth of the chain ring.

This question was asked on bicycles.se, and the answers have me interested in the math behind it.
https://bicycles.stackexchange.com/questions/5264/how-do-i-calculate-the-diameter-of-a-chainring-from-the-number-of-teeth

(In the case of bicycle chain rings, there is a fixed size for the tooth, and a fixed distance between teeth related to the pitch of the chain. I suspect that other gear system designs would have a fixed tooth size/spacing as well.)

Does someone here have either a verification of the answers given here, with a more detailed explanation as to why they work or don't work, or a better solution to the problem?

Since the frame design is using a theoretical chainring, simple measurement is not an option, except in test cases to determine a practical solution to the question.

Best Answer

The math in lantius' answer is correct, and your comment underneath that is spot on: The difference between lantius' answer and yours arises from the fact that your solution assumes a circle, which contains an arc between two teeth instead of the straight line of the $n$-gon. Since you presumably measured the distance of $12.75$mm between the tips of the teeth along a straight line, the $n$-gon gives the correct solution. As lantius already pointed out, the difference this makes in the circumference is quite small in this case, only $.005$ inches, compared to the $.05$ inches discrepancy with the value calculated from the diameter. Since the error in your measurement of the distance between adjacent teeth is multiplied by $53$, a discrepancy of only $.05$ inches is very good; it means the error in your distance measurement for the teeth was only about $.001$ inches, or about $.025$ mm, which seems almost a bit too good to be true.

The difference between the $1/2$ inch chain standard and your $12.75$mm measurement is due to the fact that the centres of the chain pins sit slightly below the tips of the teeth, and the $1/2$ inch standard refers to the distance between the centres of adjacent chain pins (see here and here).

There's actually a further potential source of error that hasn't been mentioned yet in the other thread. You didn't specify how you measured the diameter. Since it's a 53-tooth chain ring, there are no opposite teeth to measure it at. Assuming that you measured between the tip of one tooth and the tip of either or both of the teeth almost but not quite opposite to it, what you would then actually measure is not the diameter, but slightly less. By the law of cosines, this distance is

$$\sqrt{r^2+r^2-2rr\cos\frac{52}{53}\pi}=r\sqrt{2-2\cos\frac{52}{53}\pi}=2r\sin\frac{26\pi}{53}\approx0.99956d\;,$$

where $r$ is the radius and $d$ is the diameter. So that makes a difference of around one twentieth of a percent in the diameter, or about $.1$mm, which is about one tenth of the discrepancy of $.05$ inches. However, this goes in the "wrong" direction; to correct for it, you'd have to add that difference to the measured diameter, which would move it very slightly away from the one calculated from the tooth tip distance.

Here's something fun you could do: For each number $k$ between $1$ and $26$, measure the distance between the tips of a tooth and another tooth $k$ teeth along the ring. By the law of cosines, the values you get should be

$$a_k=\sqrt{r^2+r^2-2rr\cos\frac{2k\pi}{53}}=r\sqrt{2-2\cos\frac{2k\pi}{53}}=d\sin\frac{k\pi}{53}\;,$$

so

$$d=\frac{a_k}{\sin\frac{k\pi}{53}}$$

in each case. Note that this establishes a connection between lantius' calculation of the diameter from a measurement of the distance between adjacent tooth tips ($k=1$) and my calculation of the diameter from a measurement of the distance between almost opposite tooth tips ($k=26$); they're both special cases of the same thing. You can make all $26$ measurements and see how the values scatter. You should be able to see that the scatter decreases with increasing $k$, since the measurement error is being magnified less. If you want to go the whole cog, you can do a least-squares fit on these measurements to get a more accurate estimate of the diameter. In doing that, you shouldn't just take the average, but weight the measurements according to their precision (see here for an explanation), so your best estimate for the diameter would be

$$d\approx\frac{\sum_{k=1}^{26}d_k\sin^2\frac{k\pi}{53}}{\sum_{k=1}^{26}\sin^2\frac{k\pi}{53}}=\frac4{53}\sum_{k=1}^{26}\frac{a_k}{\sin\frac{k\pi}{53}}\sin^2\frac{k\pi}{53}=\frac4{53}\sum_{k=1}^{26}a_k\sin\frac{k\pi}{53} \;. $$

[Edit in response to the comment:]

I'll break down some of the things I'm guessing you might be having trouble with; let me know specifically if you want anything else explained.

The law of cosines states that if $a$, $b$ and $c$ are the sides of a triangle and $\gamma$ is the angle opposite $c$, then

$$c^2=a^2+b^2-2ab\cos\gamma\;.$$

I applied this to triangles formed by two tips and the centre; two sides $a$ and $b$ are the distance from the tips to the centre, which is the radius of the circle, and the third side $c$, the distance between the two tips, is determined by taking the square root of the above equation. When the teeth are $k$ teeth apart, the angle is $k$ times one $n$-th of a full circle, where $n$ is the number of teeth; since a full circle is $2\pi$, this is $2\pi k/n$.

I then used the trigonometric identity $\sqrt{2-2\cos\gamma}=2\left|\sin\frac\gamma2\right|$; since all our angles are positive, I dropped the absolute value.

At the end, I simplified the denominator in the least-squares result as follows:

$$ \begin{eqnarray} \sum_{k=1}^m\sin^2\frac{2k\pi}{2m+1} &=& \sum_{k=1}^m\left(\frac1{2\mathrm i}\left(\mathrm e^{\mathrm i\frac{2k\pi}{2m+1}}-\mathrm e^{-\mathrm i\frac{2k\pi}{2m+1}}\right)\right)^2 \\ &=& -\frac14\sum_{k=1}^m\left(\mathrm e^{2\mathrm i\frac{2k\pi}{2m+1}}+\mathrm e^{-2\mathrm i\frac{2k\pi}{2m+1}}-2\right) \\ &=& -\frac14\left(\sum_{k=1}^m\left(\mathrm e^{2\mathrm i\frac{2k\pi}{2m+1}}+\mathrm e^{-2\mathrm i\frac{2k\pi}{2m+1}}\right)-\sum_{k=1}^m2\right) \\ &=& -\frac14(-1-2m) \\ &=& \frac{2m+1}4\;, \end{eqnarray} $$

where $n=2m+1$ is the odd number of teeth, $53$, so $m=26$, and the left-hand sum evaluates to $-1$ because the $(2m+1)$-th roots of unity sum to $0$ and the sum contains all of them exactly once, except $1$. I suspect you might not understand that last part; alternatively, you can just ask Wolfram|Alpha.

Regarding your measurement of the diameter: Yes, that does affect the conclusions. The distance between a tooth and the almost opposite teeth is already a bit shorter than the diameter; the distance from a tooth to the line between the almost opposite teeth is a bit shorter yet; the difference is roughly twice as much. The distance you measured is one radius plus the distance from the centre to the line connecting two teeth, which is the cosine of half the angle between two teeth times the radius, so you measured

$$r+\cos\frac\pi{53}r=\left(1+\cos\frac\pi{53}\right)r=\frac{1+\cos\frac\pi{53}}2d\approx0.99912d\;,$$

compared to $0.99956d$ above, so this would add about $.2$mm instead of $.1$mm to the discrepancy.