I've been recently fascinated by the beauty, symmetry and mathematical richness of the Apollonian gaskets.
So I felt myself challenged to see if it was possible to generate one in Mathematica with a very short code, guided by the belief that "Beautiful math can often also be very simple".
The result I came up with is the following code:
Graphics[{Purple ,Circle[],Disk@@@Flatten[Table[1/(k^2+2) {{(-1)^r (-k^2+1), -2 (-1)^j k},1}, {k,0,9}, {j,0,1}, {r,0,1}],2]}]
Not bad for a minimalistic code, also considering that I found a simpler/shorter translation of Descartes formula to be used in my case.
Above code was short enough (124 characters) to be accepted and published as a tweet by Tweet-a-Program @wolframtap (here's the link).
Anyway the Apollonian gasket produced by the short code quoted above is not complete, as it only produces the circles tangent to the outer circle and not the inner ones.
It's surely possible to realize some longer code to produce a full Apollonian gasket (with a parameter to set the limit for the number of iterations) drawing also the inner circles. There are good examples of full programs already done by others (like this)
But my question is whether such program can be reduced to a minimum length (I suppose it could be done with about 500 characters or less).
Amongst all the possible variations I'm interested on the basic Apollonian gasket generated by the outer circle (curvature -1) and 2 congruent inner circles with curvature 2 (model -1, 2, 2 as in the image above). That initial condition could generate, in sequence, the other circles with curvatures 3, 6, 15, 11, 14, 23, 38, 35.... using the Descartes' theorem formula.
My guess is that a very smart program (probably based on a Nest command) could be used in a very condensed code, also taking advantage of the symmetries of the gasket.
Any suggestion for the shortest possible code?