# Geometry Puzzle: Tangent Circles with Integer Radii

Take as a semi-related example a series of circles with radii 10, 9, 8, ..., 2, 1. Place the first (largest) circle in the center and subsequent circles around it, keeping tangency between subsequent circles and the central circle. It would look like this:

The puzzle prompt is this: Find a sequence (any length, not necessarily 10) of strictly decreasing (strictly because otherwise you can pick seven 1s and pack a hex lattice) integer radii such that the final circle perfectly covers the central one. In other words, such that it is also tangent to the second circle (the first non-central). It might look like this:

I ended up posting this over at math SE as well.

• This is totally fine as Puzzling, as similar mathematics-related puzzles have been accepted before. Do you have an answer or a set of answers in mind, or is this problem possibly unsolvable?
– Sny
Commented May 1 at 0:19
• I have no idea if there is a solution. Commented May 1 at 4:22
• A necessary condition for this to have a solution is the existence of a set of angles adding up to 2pi whose cosines are all rational. Commented May 2 at 5:53
• answer for exactly 3 circles surrounding the central circle: en.wikipedia.org/wiki/Apollonian_gasket Commented May 3 at 15:35
• But the central circle is not the largest. Commented May 8 at 17:04

I can do it with eight circles:

r0 = 1346015551088116451588241696826457667928305
r1 = 1285983548348276483652942082564013466760320
r2 = 1238768816482055499967626824541529444769070
r3 = 1156239292571620556013720831252688362612000
r4 = 990358148968489476126926154954692437512561
r5 = 961539350943357825433592453776542736631070
r6 = 908374343417739169873995450234402764477000
r7 = 780821295607168322239085153945384792689735


Unfortunately I'm not well-versed in the technology to render beautiful pictures as the OP did, so I'll stick to the numbers for now.

Explanation:

Tom Sirgedas' answer on MSE has set up some key variables for the problem.

Here we use $$r_0$$ to mean the radius of the center circle, and $$r_1>\ldots>r_n$$ to mean the surrounding ones, in decreasing order although the ordering is not important.

By Tom's calculation, the central circle's central angle between directions towards two neighboring circles $$r_i,r_{i+1}$$ is given by $$\theta_i=\arccos\left(1-2s_is_{i+1}\right)=2\arcsin\left(\sqrt{s_i}\sqrt{s_{i+1}}\right),$$ where $$s_i=\frac{r_i}{r_0+r_i}$$.

Since $$r_i=\frac{s_i}{1-s_i}r_0$$, we know the radii $$r_0,\ldots,r_n$$ can all be integers as long as $$s_1,\ldots,s_n$$ take rational values. We name some new variables $$t_1,\ldots,t_n$$ whose values shall be determined, such that they satisfy the property $$\sqrt{s_i}\sqrt{s_{i+1}}=\frac{2t_i}{1+t_i^2}$$ and moreover $$t_1,\ldots,t_n$$ are rational.

Then we derive $$\theta_i=2\arcsin\left(\frac{2t_i}{1+t_i^2}\right)=4\arctan\left(t_i\right).$$ In other words, the rational numbers $$t_1,\ldots,t_n$$ will need to satisfy the properties \left\{\begin{aligned}&0 to ensure that the corresponding values $$\theta_i$$ are less than $$60^\circ$$ each and at the same time sum up to $$2\pi$$.

For example, a brute-force search might easily help one come up with the combination $$\begin{gathered}\arctan\frac{1}{5}+\arctan\frac{4}{19}+\arctan\frac{2}{9}+\arctan\frac{3}{13}+{}\\\arctan\frac{7}{29}+\arctan\frac{9}{37}+\arctan\frac{1}{4}=\frac{\pi}{2},\end{gathered}$$ but these values do not yet guarantee that the radii $$r_1,\ldots,r_n$$ will be in decreasing order. So I used Python to generate about a hundred groups of values of $$t_i$$, and found the solution $$(t_1\ldots t_7)=\left(\frac{8}{31},\frac{1}{4},\frac{7}{30},\frac{13}{59},\frac{3}{14},\frac{1}{5},\frac{2}{9}\right)$$ which happens to work out.

Then we can plug in the values of $$t_i$$ back to solve for $$s_i$$, thus for example $$s_1=\frac{2t_1}{1+t_1^2}\cdot\frac{1+t_2^2}{2t_2}\cdot\frac{2t_3}{1+t_3^2}\cdots\frac{2t_7}{1+t_7^2}=\frac{15748992}{32233175},$$ and after that use the formula $$r_1=\frac{s_1}{1-s_1}r_0$$ from the beginning to get $$r_1=\frac{15748992}{16484183}r_0$$, and then finally clear the common denominators of $$\frac{r_1}{r_0},\ldots,\frac{r_7}{r_0}$$ to get $$r_0$$.

Edit from OP:

It looks like this:

• I can confirm that the list works.
– Sny
Commented May 10 at 8:21
• The resulting t and r lists look good to me, too! The explanation is very lucid; only, would it help to say at the very beginning "WLOG let's set $r_0=1$", so that you didn't have that extra factor of $r_0$ floating around, and didn't have to worry about why there's an $s_1$ but no $s_0$? Actually I'm confused why we never need to think about the "wraparound" where circle $r_n$ touches circle $r_1$. I think that's because your first block formula says $s_{i+1}$ when it really means s[i+1 if i < n else 1] and then everything after that works out fine, but I'm not 100% sure. Commented May 10 at 14:29
• Does your formula for $s_i$ imply that the number of circles around the outside must invariably be odd? and/or that this method will only find solutions where the number of outside circles is odd? Commented May 10 at 14:40
• Incredible result! The only part I don't understand is how you included the angle between the r7 and r1... The leftover/last angle. Commented May 10 at 15:38
• To expand on that: IIUC, $t_{1..6}$ must be strictly decreasing, but $t_7$ is allowed to be (and in fact must be) bigger than $t_6$. I wrote up a Python version of @EdwardH's algorithm that I don't mind sharing, here. Using that algorithm I've found a solution with radii somewhat smaller than Edward's (see that repo's README), but nothing to write home about yet. Commented May 10 at 18:32

This puzzle has already been solved using 30-digit numbers, but I'm interested in using smaller numbers.

I wrote some code to start with a central unit circle and the loop over values for the next-largest circle. Then I do a depth-first search, picking decreasing radii, and keeping track of the remaining angle and the least-common-multiple of denominators. The search is surprisingly narrow when the denominator is constrained and the tangent of all half-angles is required to be rational (update: or a rational multiplied by the root of some fixed integer). The search allows for an unlimited number of circles. The last radius in a valid configuration can be calculated instead of searched.

I found dozens of 6-digit solutions (see edit history for a few). But this 4-digit solution with fifteen circles is the best by far, and only barely avoids an overlap:

Zoomed view:

## Other solutions

Here's 5-digit solution with central radius $$42120$$:

• This last solution is incredible. Thanks for sharing! Commented Jul 4 at 6:03

edwardh's answer above gives eight circles with radii circa $$10^{42}$$:

rs = [
1346015551088116451588241696826457667928305,
1285983548348276483652942082564013466760320,
1238768816482055499967626824541529444769070,
1156239292571620556013720831252688362612000,
990358148968489476126926154954692437512561,
961539350943357825433592453776542736631070,
908374343417739169873995450234402764477000,
780821295607168322239085153945384792689735,
]


I coded up his approach in Python and threw a lot of laptop time at it. Today the computer finally found two smaller solutions, involving radii circa $$10^{30}$$:

rs = [
3351747005653424648383741138532,
3205723049598255148555654977125,
2775693993058987197622141299968,
2750071286250985696293256343360,
2576265167388890063586881775735,
2355770023351368908545664347968,
2298393837394654407377433698465,
2168159590729803674819757284343
]

# The corresponding t values are:
ts = [1/4, 16/67, 7/30, 2/9, 3/14, 39/187, 3/13]


and slightly smaller:

rs = [
2941564115506288009572255050208,
2641663701806844064724293810176,
2588185711710249680183593951791,
2354857694119310401212561211842,
2236188368634576996067318957950,
2089644243395382075169644129792,
1996023217448211952755320125300,
1967470772556389886966582369792
]
ts = [1/4, 7/29, 3/13, 2/9, 3/14, 29/138, 11/48]


They look like this:

r0 = 3351747005653424648383741138532 r0 = 2941564115506288009572255050208

I made the above images as SVG using this script. Sadly, StackExchange doesn't support rendering the SVG directly, so the images you see above are PNG screenshots.

I've blogged about this in "Tangent circles of integer radius" (2024-06-10), and updated the post to include Tom's much much smaller answers too (although I still don't know precisely how he's finding them).

• That's a great improvement! You might be interested in also exploring solutions with 8 surrounding circles. IIRC, a new constraint is that the odd and even $\theta_i$ need to add to the same value, but then you can multiply/divide the even/odd $s_i$ values by an arbitrary constant. Commented May 23 at 20:11
• @TomSirgedas: I'd certainly be interested to know if there's any relationship between the size/structure of the t fractions and the magnitude of the rs. There is certainly a smallest possible r0, and it would be cool to know how much we'd have to search to find it. (Very very naïvely: We know that there are only $2^{r_0}$ possible sets of decreasing-integer-radius circles for any given $r_0$. So there are only $\sum_{r_0=7}^{R-1}{2^{r_0}}\approx 2^{R}$ arrangements with $r_0 < R$, only some of which will be solutions. One of that finite number of solutions must be the smallest.) Commented May 24 at 15:07
• I'm also really curious about adding more circles... There's a tension between using more bases for the LCM and the flexibility of the increased degrees of freedom. Commented May 24 at 17:28
• I made a chat room: chat.stackexchange.com/rooms/153335/puzzling-tangent-circles Commented May 25 at 21:22

The closest I've got so far with some very brute force searching is this sequence of radii: 20, 19, 18, 17, 16, 14, 8, 5, 4, 3, 2. The final circle overlaps with the rightmost one by about 5.39x10e-6. I think I'll close this and post a similar question over in math.

• Computer says (2, 3, 6, 7, 9, 10, 11, 13, 14, 17, 20, 23) is better: an overlap of only 7.09e-8 radians. And (1, 2, 4, 8, 10, 15, 16, 17, 18, 20, 23, 26) is closer yet, with a gap of 1.48e-8. But I have no insights, just brute force and Python. :) If you do post on math.SE, please remember to post the link here! Commented May 8 at 23:03
• Edited the question to include a link. Great finds! Commented May 9 at 0:21
• Actually, both of my solutions (and maybe yours too) are already down in the noise of IEEE doubles, or very close to it, where the additions involved might not be associative, and the difference with 2pi might just be garbage. That said, here's my latest: (46, 36, 31, 30, 26, 21, 18, 15, 11, 10, 7, 6, 5). I'd be interested to hear from anyone who can do the computation more precisely than IEEE double. My program claims that the overlap there is 7.73426e-11 and that to close the loop perfectly the smallest circle's radius should be about 4.99999999866 instead of 5. Commented May 9 at 16:03

In Figure 12, one possible solution is depicted, with radii $$1/146$$, $$1/27$$, $$1/23$$, and $$1/18$$, respectively. This can easily be scaled by $$90666$$ times (the LCM) to become integers, namely $$621$$, $$3358$$, $$3942$$, $$5037$$. Judging from the magnitude of the numbers, its no wonder brute force computer search wasn't fruitful.

• I think OP specifically wants the central circle to be the biggest whereas in this example it is the smallest. Commented May 9 at 11:13