# Apollonian Packing of Circles within Ellipses
## 2 Materials and Methods
### Tangent Circles in the Elliptic Domain
#### 2.3.1 The Search for the Solution by Means of Menaechmics  
A specific algorithm must be devised for the search for sprout circles of the packing that are externally tangent to two stem circles and internally tangent to elliptic boundary \(\mathcal{E}\). Figure 4a depicts a typical geometric layout resulting from the packing procedure applied to the scaffolding shown in Figure 1b. The search for a circle \(\mathcal{C}_{t}\) that is externally tangent to circles \(\mathcal{C}_{1}\) and \(\mathcal{C}_{2}\) and tangent to elliptic boundary \(\mathcal{E}\) may be reduced to the problem of constructing a point \(P\) that is internal to the arbelos-shaped curvilinear triangle \(\mathcal{T}_{1}\) and placed at equal distance from the boundaries of \(\mathcal{C}_{1}\), \(\mathcal{C}_{2}\) and \(\mathcal{E}\). By identifying the centers and radii of circles \(\mathcal{C}_{1}\), \(\mathcal{C}_{2}\) by means of symbols \(C_{1}\), \(r_{1}\), \(C_{2}\) and \(r_{2}\), respectively, such properties may be translated into the following relation:  
\[\overline{PT_{2,t}}=\overline{PT_{1,t}}=d(P,\mathcal{E}) \tag{5}\]  
where \(T_{1,t}\) and \(T_{2,t}\) are the tangency point between circles \(\mathcal{C}_{1}\) and \(\mathcal{C}_{2}\), and circle \(\mathcal{C}_{t}\).  
By expressing distances in terms of radii,  
\[\overline{PT_{2,t}}=\overline{PC}_{2}-r_{2}\qquad\overline{PT_{1,t}}= \overline{PC}_{1}-r_{1} \tag{6}\]  
By separating the two equalities in Equation (5) and rearranging the terms, we obtain  
\[\frac{\overline{PC}_{1}-\overline{PC}_{2}}{\overline{PC}_{2}}-r_{2}=d(P, \mathcal{E}) \tag{7a}\] \[\frac{\overline{PC}_{1}-r_{1}}=d(P,\mathcal{E}) \tag{7b}\]  
Equations (7a)-(7c) imply the following conditions, illustrated in Figure 4:  
* Center \(P\) belongs to hyperbola \(\mathcal{I}_{1,2}\) defined by Equation (7a) having foci \(C_{1}\) and \(C_{2}\), and a minor semi-axis length \(r_{1}-r_{2}\).
* Point \(P\) must be placed at a known distance from ellipse \(\mathcal{E}\), defined by Equation (7b) or Equation (7c). It is easy to observe that tangency point \(T_{1,2}\) of circles \(\mathcal{C}_{1}\) and \(\mathcal{C}_{2}\) belongs to hyperbola \(\mathcal{I}_{1,2}\). In fact, \(\overline{T_{1,2}C_{1}}=r_{1}\) and \(\overline{T_{1,2}C_{2}}=r_{2}\), and by subtracting these two relations, \[\overline{T_{1,2}C_{2}}-\overline{T_{1,2}C_{1}}=r_{1}-r_{2}\,\] (8) thus \(T_{1,2}\) satisfies Equation (7a).  
A purely numerical approach to the solution of the tangency problem under analysis may be easily accomplished. Point \(P\) belongs to an hyperbola branch; thus, its coordinates  
Figure 4: (**a**) Equidistance condition of point \(P\) from the surrounding boundaries. (**b**) Hyperbola expressing the condition of equidistance of point \(P\) from circles \(\mathcal{C}_{1}\) and \(\mathcal{C}_{2}\).  
may be expressed in dependence of a single real parameter \(t\). The desired solution may be achieved by varying \(P(t)\) according to a convergent algorithm until the condition  
\[\overline{PC_{2}}-r_{2}=\overline{PC_{1}}-r_{1}=d(P,\mathcal{E}) \tag{9}\]  
is satisfied.