graphing tangent lines to two circles


In 2021 March, I had to write a paper called the “Extended Essay”, which was sort of the culminating work for the International Baccalaureate program at my high school. I was one of the 3.2% of candidates to write it under the “Mathematics” subject and one of 20% to earn an A for it!1 :D

I now look back and think it could have been more clearly written. However, I decided to put it up here anyway, with some of the cruft trimmed off.

The conclusion is that tangent lines to circles can be modeled by the following system of equations:

a=x1x2b=y1y2c=r1±r2\begin{aligned} a &= x_1-x_2 & b &= y_1-y_2 & c &= r_1 \pm r_2 \end{aligned} St=ba2+b2c2±acaa2+b2c2bc\begin{aligned} S_t = \frac{b \sqrt{a^2+b^2-c^2} \pm ac}{a \sqrt{a^2+b^2-c^2} \mp bc} \end{aligned} xi=x1Str1St2+1yi=±r12(xix1)2+y1\begin{aligned} x_i &= x_1 \mp \frac{S_t r_1}{\sqrt{S_t^2+1}} & y_i &= \pm \sqrt{r_1^2-(x_i-x_1)^2}+y_1 \end{aligned} y=St(xxi)+yi\begin{aligned} y &= S_t(x - x_i) + y_i \end{aligned}

Substitute (x1,y1)(x_1, y_1) with the coordinates of the first circle and r1r_1 with its radius. Likewise, substitute x2x_2, y2y_2, and r2r_2 for the second circle.

Use different states of the three plus–minus signs to generate eight different possible lines, and manually choose four from those eight as your four tangent lines (two internal and two external).


A couple years ago, I sometimes liked to make art in Desmos (an online graphing calculator), and one of my almost-finished pieces was a bicycle. I had written the equation for each line that made up the drawing of the bike, and I could even adjust the seat height and pedal lengths with variable sliders.

However, one feature of the bike was notably missing: the chain connecting the gears. This would have taken the form of lines tangent to the two circles representing the gears, but I didn’t know how to graph that precisely at the time.

a bicycle chain, resembling circles with tangent lines

I’ve since lost the original Desmos project, but my unsolved problem has tormented me ever since. How do you write the linear equation for each of the lines that are tangent to two circles if you know the radii and coordinates of those circles?

external tangent lines

There are two circles:

  • Circle 1 with center C1=(x1,y1)C_1=(x_1,y_1) and radius r1r_1
  • Circle 2 with center C2=(x2,y2)C_2=(x_2,y_2) and radius r2r_2
  • r1r2r_1\geq r_2
external tangents of two circles

A line is drawn between the centers of the circles, called C(x)C(x), and both external tangent lines t1(x)t_1(x) and t2(x)t_2(x) are drawn. The points of intersection between the tangent lines and circle 1 are i1=(xi1,yi1)i_1=(x_{i1},y_{i1}) and i2=(xi2,yi2)i_2=(x_{i2},y_{i2}). The points of intersection on circle 2 are i3=(xi3,yi3)i_3=(x_{i3},y_{i3}) and i4=(xi4,yi4)i_4=(x_{i4},y_{i4}). All three lines intersect at point PP. The angle between the first tangent line and the line that connects the centers of the circles is C1Pi1\angle C_1Pi_1.

slopes of the external tangents

Angle C1i1P\angle C_1 i_1 P is a right angle because it is the angle between a tangent to a circle and a radius that passes through the point of tangency, and the same is true for C2i3P\angle C_2 i_3 P⁠. Because these right angles are congruent, and because C1Pi1\triangle C_1 P i_1 and C2Pi2\triangle C_2 P i_2 share the angle C1Pi1\angle C_1 P i_1, this makes the triangles similar.

Because these triangles are similar, the ratio between corresponding sides is constant. Therefore,

r1r2=h1h2\frac{r_1}{r_2} = \frac{h_1}{h_2}

We can substitute h1h_1 with the two lengths that make it up: h2+dh_2+d. Then, by rewriting the equation, we can solve for h2h_2.

r1r2=h2+dh2 r1h2=r2(h2+d) r1h2=r2h2+r2d r1h2=r2h2+r2d r1h2r2h2=r2d h2(r1r2)=r2d h2=r2dr1r2\begin{aligned} \frac{r_1}{r_2} &= \frac{h_2+d}{h_2} \\\ r_1h_2 &= r_2(h_2+d) \\\ r_1h_2 &= r_2h_2+r_2d \\\ r_1h_2 &= r_2h_2+r_2d \\\ r_1h_2-r_2h_2 &= r_2d \\\ h_2(r_1-r_2) &= r_2d \\\ h_2 &= \frac{r_2d}{r_1-r_2} \end{aligned}

Now that h2h_2 is defined, we can use trigonometry to define the angle between the line that connects the circles’ centers and the first tangent line. This angle is C2Pi3\angle C_2 P i_3, or θ\theta.

Consider triangle C2i3P\triangle C_2 i_3 P:

triangle $\triangle C_2 i_3 P$

Because of the definition of the sine of an angle (the ratio between the opposing side and the hypotenuse in a right triangle), sinθ=r2h2\sin{\theta} =\frac{r_2}{h_2}. By taking the inverse sine of each side, we can define θ\theta:

θ=arcsin(r2h2)\theta =\arcsin{\left(\frac{r_2}{h_2}\right)}

To find the angle of the first external tangent line, we can add θ\theta to the angle of C(x)C(x) with respect to the xx-axis. Similarly, we can subtract θ\theta from the angle of C(x)C(x) to find the angle of the second tangent line.

θt=θC±θ\begin{aligned} \theta_t=\theta_C \pm \theta \end{aligned}
angles of external tangents and $C(x)$

But how do we know the angle of C(x)C(x)? The slope of C(x)C(x) can be found by using the slope formula and substituting with the coordinates of the centers of the circles. Then, we can convert this slope into an angle by finding its inverse tangent.

θC=arctan(SC) θC=arctan(ΔyΔx) θC=arctan(y1y2x1x2)\begin{aligned} \theta_C &= \arctan{\left( S_C \right)} \\\ \theta_C &= \arctan{\left( \frac{\Delta y}{\Delta x} \right)} \\\ \theta_C &= \arctan{\left( \frac{y_1-y_2}{x_1-x_2} \right)} \end{aligned}

Now, we can substitute the values of θC\theta_C and θ\theta:

θt=θC±θ θC=arctan(y1y2x1x2) θ=arcsin(r2h2) θt=arctan(y1y2x1x2)±arcsin(r2h2)\begin{aligned} \theta_t &= \theta_C \pm \theta \\\ \theta_C &= \arctan{\left( \frac{y_1-y_2}{x_1-x_2} \right)} \\\ \theta &= \arcsin{\left( \frac{r_2}{h_2} \right)} \\\ \theta_t &= \arctan{\left( \frac{y_1-y_2}{x_1-x_2} \right)} \pm \arcsin{\left( \frac{r_2}{h_2} \right)} \end{aligned}

Then, we can substitute for h2h_2 and simplify:

h2=r2dr1r2 θt=arctan(y1y2x1x2)±arcsin(r2r2dr1r2) θt=arctan(y1y2x1x2)±arcsin(r2(r1r2)r2d) θt=arctan(y1y2x1x2)±arcsin(r1r2d)\begin{aligned} h_2 &= \frac{r_2d}{r_1-r_2} \\\ \theta_t &= \arctan{\left(\frac{y_1-y_2}{x_1-x_2}\right)} \pm \arcsin{\left(\frac{r_2}{\frac{r_2d}{r_1 - r_2}}\right)} \\\ \theta_t &= \arctan{\left(\frac{y_1-y_2}{x_1-x_2}\right)} \pm \arcsin{\left(\frac{r_2(r_1 - r_2)}{r_2d}\right)} \\\ \theta_t &= \arctan{\left(\frac{y_1-y_2}{x_1-x_2}\right)} \pm \arcsin{\left(\frac{r_1 - r_2}{d}\right)} \end{aligned}

We can then substitute for dd. dd is the distance between the centers of the circles, so we can use the distance formula with C1C_1 and C2C_2 as points.

d=(x1x2)2+(y1y2)2 θt=arctan(y1y2x1x2)±arcsin(r1r2(x1x2)2+(y1y2)2)\begin{aligned} d &= \sqrt{(x_1-x_2)^2+(y_1-y_2)^2} \\\ \theta_t &= \arctan{\left( \frac{y_1-y_2}{x_1-x_2} \right)} \pm \arcsin{\left(\frac{r_1 - r_2}{\sqrt{(x_1-x_2)^2+(y_1-y_2)^2}}\right)} \end{aligned}

Because the tangent of the angle of a line produces its slope, we can take the tangent of both sides to generate an equation for both of the slopes of the external tangent lines:

St=tan(arctan(y1y2x1x2)±arcsin(r1r2(x1x2)2+(y1y2)2))S_t = \tan{\left(\arctan{\left(\frac{y_1-y_2}{x_1-x_2}\right)} \pm \arcsin{\left(\frac{r_1 - r_2}{\sqrt{(x_1-x_2)^2+(y_1-y_2)^2}}\right)}\right)}

This equation, which uses trigonometric functions inside of a trigonometric function, is not very elegant. To rewrite it, we can use a trigonometric identity for the tangent of a sum or difference:

tan(α±β)=tan(α)±tan(β)1tan(α)tan(β)\tan{(\alpha \pm \beta)}=\frac{\tan{(\alpha)} \pm \tan{(\beta)}}{1 \mp \tan{(\alpha)}\tan{(\beta)}}

In this case,

α=arctan(y1y2x1x2)\alpha = \arctan{\left(\frac{y_1-y_2}{x_1-x_2}\right)}


β=arcsin(r1r2(x1x2)2+(y1y2)2)\beta = \arcsin{\left(\frac{r_1 - r_2}{\sqrt{(x_1-x_2)^2+(y_1-y_2)^2}}\right)}


For ease of explanation, we’ll first find tan(α)\tan{(\alpha)} and tan(β)\tan{(\beta)} separately, then substitute them into the identity.

The tangent of α\alpha is simple to find, because the arctangent and the tangent functions cancel each other out:

tan(α)=tan(arctan(y1y2x1x2)) tan(α)=y1y2x1x2\begin{aligned} \tan{(\alpha)} &= \tan{\left( \arctan{\left(\frac{y_1-y_2}{x_1-x_2}\right)} \right)} \\\ \tan{(\alpha)} &= \frac{y_1-y_2}{x_1-x_2} \end{aligned}

However, the tangent of β\beta is trickier because the tangent function doesn’t cancel out the arcsine function. To remedy this, we can use an identity for the tangent of an arcsine, as demonstrated by figure 5.

right triangle demonstration of $\tan(\arcsin(x))$

In figure 5, the sine of angle θ\theta is the ratio between the lengths of the opposite side and the hypotenuse, or x1=x\frac{x}{1}=x. Therefore, the arcsine of this ratio equals θ\theta:


The tangent of θ\theta, or in other words, the tangent of arcsin(x)\arcsin{(x)}, is equal to the ratio between the opposite side and the adjacent side. The length of the adjacent side can be found using the Pythagorean theorem: 1x2\sqrt{1-x^2}. Therefore,


We can now use this identity to find tan(β)\tan{(\beta)}:

tan(β)=tan(arcsin(r1r2(x1x2)2+(y1y2)2)) tan(β)=r1r2(x1x2)2+(y1y2)21(r1r2(x1x2)2+(y1y2)2)2 tan(β)=r1r2(x1x2)2+(y1y2)21(r1r2)2(x1x2)2+(y1y2)2 tan(β)=r1r2(x1x2)2+(y1y2)2(x1x2)2+(y1y2)2(x1x2)2+(y1y2)2(r1r2)2(x1x2)2+(y1y2)2 tan(β)=r1r2(x1x2)2+(y1y2)2(x1x2)2+(y1y2)2(r1r2)2(x1x2)2+(y1y2)2 tan(β)=r1r2(x1x2)2+(y1y2)2(x1x2)2+(y1y2)2(r1r2)2(x1x2)2+(y1y2)2 tan(β)=r1r2(x1x2)2+(y1y2)2(r1r2)2\begin{aligned} \tan{(\beta)} &= \tan{\left(\arcsin{\left(\frac{r_1 - r_2}{\sqrt{(x_1-x_2)^2+(y_1-y_2)^2}}\right)}\right)} \\\ \tan{(\beta)} &= \frac{\frac{r_1 - r_2}{\sqrt{(x_1-x_2)^2+(y_1-y_2)^2}}}{\sqrt{1-\left(\frac{r_1 - r_2}{\sqrt{(x_1-x_2)^2+(y_1-y_2)^2}}\right)^2}} \\\ \tan{(\beta)} &= \frac{\frac{r_1 - r_2}{\sqrt{(x_1-x_2)^2+(y_1-y_2)^2}}}{\sqrt{1-\frac{(r_1 - r_2)^2}{(x_1-x_2)^2+(y_1-y_2)^2}}} \\\ \tan{(\beta)} &= \frac{\frac{r_1 - r_2}{\sqrt{(x_1-x_2)^2+(y_1-y_2)^2}}}{\sqrt{\frac{(x_1-x_2)^2+(y_1-y_2)^2}{(x_1-x_2)^2+(y_1-y_2)^2}-\frac{(r_1 - r_2)^2}{(x_1-x_2)^2+(y_1-y_2)^2}}} \\\ \tan{(\beta)} &= \frac{\frac{r_1 - r_2}{\sqrt{(x_1-x_2)^2+(y_1-y_2)^2}}}{\sqrt{\frac{(x_1-x_2)^2+(y_1-y_2)^2-(r_1 - r_2)^2}{(x_1-x_2)^2+(y_1-y_2)^2}}} \\\ \tan{(\beta)} &= \frac{\frac{r_1 - r_2}{\sqrt{(x_1-x_2)^2+(y_1-y_2)^2}}}{\frac{\sqrt{(x_1-x_2)^2+(y_1-y_2)^2-(r_1 - r_2)^2}}{\sqrt{(x_1-x_2)^2+(y_1-y_2)^2}}} \\\ \tan{(\beta)} &= \frac{r_1 - r_2}{\sqrt{(x_1-x_2)^2+(y_1-y_2)^2-(r_1 - r_2)^2}} \end{aligned}

Now that we know tan(α)\tan{(\alpha)} and tan(β)\tan{(\beta)}, we can return to rewriting the slope equation using the identity for the tangent of a sum or difference.

St=tan(arctan(y1y2x1x2)±arcsin(r1r2(x1x2)2+(y1y2)2)) tan(α±β)=tan(α)±tan(β)1tan(α)tan(β) St=y1y2x1x2±r1r2(x1x2)2+(y1y2)2(r1r2)21y1y2x1x2r1r2(x1x2)2+(y1y2)2(r1r2)2 St=y1y2x1x2±r1r2(x1x2)2+(y1y2)2(r1r2)21(y1y2)(r1r2)(x1x2)(x1x2)2+(y1y2)2(r1r2)2\begin{aligned} S_t &= \tan{\left(\arctan{\left(\frac{y_1-y_2}{x_1-x_2}\right)} \pm \arcsin{\left(\frac{r_1 - r_2}{\sqrt{(x_1-x_2)^2+(y_1-y_2)^2}}\right)}\right)} \\\ \tan{(\alpha \pm \beta)} &= \frac{\tan{(\alpha)} \pm \tan{(\beta)}}{1 \mp \tan{(\alpha)}\tan{(\beta)}} \\\ S_t &= \frac{\frac{y_1-y_2}{x_1-x_2} \pm \frac{r_1 - r_2}{\sqrt{(x_1-x_2)^2+(y_1-y_2)^2-(r_1 - r_2)^2}}}{1 \mp \frac{y_1-y_2}{x_1-x_2} \cdot \frac{r_1 - r_2}{\sqrt{(x_1-x_2)^2+(y_1-y_2)^2-(r_1 - r_2)^2}}} \\\ S_t &= \frac{\frac{y_1-y_2}{x_1-x_2} \pm \frac{r_1 - r_2}{\sqrt{(x_1-x_2)^2+(y_1-y_2)^2-(r_1 - r_2)^2}}}{1 \mp \frac{(y_1-y_2)(r_1 - r_2)}{(x_1-x_2)\sqrt{(x_1-x_2)^2+(y_1-y_2)^2-(r_1 - r_2)^2}}} \end{aligned}

We can rewrite each term with a common denominator.

St=(y1y2)(x1x2)2+(y1y2)2(r1r2)2(x1x2)(x1x2)2+(y1y2)2(r1r2)2±(x1x2)(r1r2)(x1x2)(x1x2)2+(y1y2)2(r1r2)2(x1x2)(x1x2)2+(y1y2)2(r1r2)2(x1x2)(x1x2)2+(y1y2)2(r1r2)2(y1y2)(r1r2)(x1x2)(x1x2)2+(y1y2)2(r1r2)2\begin{aligned} S_t &= \frac{\frac{(y_1-y_2)\sqrt{(x_1-x_2)^2+(y_1-y_2)^2-(r_1 - r_2)^2}}{(x_1-x_2)\sqrt{(x_1-x_2)^2+(y_1-y_2)^2-(r_1 - r_2)^2}} \pm \frac{(x_1-x_2)(r_1 - r_2)}{(x_1-x_2)\sqrt{(x_1-x_2)^2+(y_1-y_2)^2-(r_1 - r_2)^2}}}{\frac{(x_1-x_2)\sqrt{(x_1-x_2)^2+(y_1-y_2)^2-(r_1 - r_2)^2}}{(x_1-x_2)\sqrt{(x_1-x_2)^2+(y_1-y_2)^2-(r_1 - r_2)^2}} \mp \frac{(y_1-y_2)(r_1 - r_2)}{(x_1-x_2)\sqrt{(x_1-x_2)^2+(y_1-y_2)^2-(r_1 - r_2)^2}}} \end{aligned}

Finally, multiplying each side by the common denominator yields the final equation for the slopes of the external tangent lines:

St=(y1y2)(x1x2)2+(y1y2)2(r1r2)2±(x1x2)(r1r2)(x1x2)(x1x2)2+(y1y2)2(r1r2)2(y1y2)(r1r2)S_t = \frac{(y_1-y_2)\sqrt{(x_1-x_2)^2+(y_1-y_2)^2-(r_1 - r_2)^2} \pm (x_1-x_2)(r_1 - r_2)}{(x_1-x_2)\sqrt{(x_1-x_2)^2+(y_1-y_2)^2-(r_1 - r_2)^2} \mp (y_1-y_2)(r_1 - r_2)}

At first glance, this equation doesn’t appear any simpler than the one involving nested trigonometric functions. However, by applying the following substitutions, the symmetry and elegance of this equation becomes clear:

a=x1x2b=y1y2c=r1r2 St=ba2+b2c2±acaa2+b2c2bc\begin{gathered} a = x_1-x_2 \qquad b = y_1-y_2 \qquad c = r_1-r_2 \\\ S_t = \frac{b \sqrt{a^2+b^2-c^2} \pm ac}{a \sqrt{a^2+b^2-c^2} \mp bc} \end{gathered}

points on the external tangents

In order to define an exact equation for the external tangents, defining the slopes isn’t enough. We also need a point on each of the slopes, and the easiest points to use are the points of tangency on circle 1.

A point of tangency on circle 1 will have an instantaneous slope equal to that of the tangent line it corresponds to. Therefore, to figure out which points on circle 1 can qualify as points of tangency, we need to find the derivative (the slope at each point) of the equation of circle 1 and set it equal to the tangent’s slope, and then solve for the x-value of the point of tangency. This can then be fed back into the circle equation to define the other coordinate of the point of tangency, which would complete the definition of the tangent line function.

This method presents one key problem, however: a circle equation is not a function, and so its derivative would not be a function either. At each x-value in the domain of the graph of the circle, there are two possible y-values and two possible slopes, and as a result, there are two points on circle 1 that could qualify as points of tangency for each tangent line. Because there are two tangent lines, this makes four possible points of tangency, but only two of them are correct.

two points of tangency on a circle that have the same instantaneous slope

Ultimately, I decided to accept the fact that this approach would generate not two, but four possible external tangents, and someone using this equation would have to manually decide which definitions to use.

The first step is to find the derivative of the circle equation. However, this equation is not defined simply in terms of yy, as it’s based on the Pythagorean theorem.


Implicit differentiation would not work in this case, so we need to rewrite the circle equation in terms of yy before we differentiate it with respect to xx.

(xx1)2+(yy1)2=r12 (yy1)2=r12(xx1)2 yy1=±r12(xx1)2 y=±r12(xx1)2+y1\begin{aligned} (x-x_1)^2+(y-y_1)^2 &= r_1^2 \\\ (y-y_1)^2 &= r_1^2-(x-x_1)^2 \\\ y-y_1 &= \pm \sqrt{r_1^2-(x-x_1)^2} \\\ y &= \pm \sqrt{r_1^2-(x-x_1)^2}+y_1 \end{aligned}

Now, we can find the derivative of this equation to find the slope of any given point on circle 1.

ddx[y]=ddx[±r12(xx1)2+y1] dydx=±ddx[r12(xx1)2] dydx=±ddx[(r12(xx1)2)12]\begin{aligned} \frac{\mathrm{d}}{\mathrm{d}x} [y] &= \frac{\mathrm{d}}{\mathrm{d}x} \left[ \pm \sqrt{r_1^2-(x-x_1)^2}+y_1 \right] \\\ \frac{\mathrm{d}y}{\mathrm{d}x} &= \pm \frac{\mathrm{d}}{\mathrm{d}x} \left[ \sqrt{r_1^2-(x-x_1)^2} \right] \\\ \frac{\mathrm{d}y}{\mathrm{d}x} &= \pm \frac{\mathrm{d}}{\mathrm{d}x} \left[ \left( r_1^2-(x-x_1)^2 \right)^{\frac{1}{2}} \right] \end{aligned}

We can use the chain rule for derivatives to continue.

dydx=±12(r12(xx1)2)12(ddx[r12(xx1)2]) dydx=±12r12(xx1)2(ddx[(xx1)2]) dydx=±12r12(xx1)2(2(xx1)(1)) dydx=±2(xx1)2r12(xx1)2 dydx=±xx1r12(xx1)2\begin{aligned} \frac{\mathrm{d}y}{\mathrm{d}x} &= \pm \frac{1}{2} \left( r_1^2-(x-x_1)^2 \right)^{-\frac{1}{2}} \left( \frac{\mathrm{d}}{\mathrm{d}x} \left[ r_1^2-(x-x_1)^2 \right] \right) \\\ \frac{\mathrm{d}y}{\mathrm{d}x} &= \pm \frac{1}{2 \sqrt{r_1^2-(x-x_1)^2}} \left( -\frac{\mathrm{d}}{\mathrm{d}x} \left[ (x-x_1)^2 \right] \right) \\\ \frac{\mathrm{d}y}{\mathrm{d}x} &= \pm \frac{1}{2 \sqrt{r_1^2-(x-x_1)^2}} \left( 2(x-x_1)(1) \right) \\\ \frac{\mathrm{d}y}{\mathrm{d}x} &= \pm \frac{2(x-x_1)}{2 \sqrt{r_1^2-(x-x_1)^2}} \\\ \frac{\mathrm{d}y}{\mathrm{d}x} &= \pm \frac{x-x_1}{\sqrt{r_1^2-(x-x_1)^2}} \end{aligned}

This resulting equation gives the relationship between the slope of the tangent line (dydx\frac{\mathrm{d}y}{\mathrm{d}x}) and the xx-coordinate of the point of tangency on circle 1.

We need to rewrite this equation in terms of xx, because in this case, xx is the xx-coordinate of the point of tangency, which will be used in the tangent line equation. However, the algebra that enables us to do this is long and confusing. To help make the process easier to read, we will temporarily reassign each variable to a single letter each:

dydx=St=a r1=b x=xi=c x1=d\begin{aligned} \frac{\mathrm{d}y}{\mathrm{d}x} = S_t &= a \\\ r_1 &= b \\\ x = x_i &= c \\\ x_1 &= d \end{aligned}

Essentially, we can rewrite the equation as a sum of terms, which can be rearranged into a quadratic equation with multi-term coefficients. These can be plugged into the quadratic formula in order to solve for cc, which represents xix_i.

a=±cdb2(cd)2 ±ab2(cd)2=cd (±ab2(cd)2)2=(cd)2 a2(b2(cd)2)=(cd)2 a2(b2(c22cd+d2))=c22cd+d2 a2(b2c2+2cdd2)=c22cd+d2 a2b2a2c2+2a2cda2d2=c22cd+d2 a2b2a2c2+2a2cda2d2c2+2cdd2=0 a2c2c2+2a2cd+2cd+a2b2a2d2d2=0 c2(a21)+c(2a2d+2d)+(a2b2a2d2d2)=0\begin{aligned} a &= \pm \frac{c-d}{\sqrt{b^2-(c-d)^2}} \\\ \pm a \sqrt{b^2-(c-d)^2} &= c-d \\\ \left( \pm a \sqrt{b^2-(c-d)^2} \right)^2 &= (c-d)^2 \\\ a^2(b^2-(c-d)^2) &= (c-d)^2 \\\ a^2(b^2-(c^2-2cd+d^2)) &= c^2 - 2cd +d^2 \\\ a^2(b^2-c^2+2cd-d^2) &= c^2 - 2cd +d^2 \\\ a^2b^2-a^2c^2+2a^2cd-a^2d^2 &= c^2 - 2cd +d^2 \\\ a^2b^2 - a^2c^2 + 2a^2cd - a^2d^2 - c^2 + 2cd - d^2 &= 0 \\\ - a^2c^2 - c^2 + 2a^2cd + 2cd + a^2b^2 - a^2d^2 - d^2 &= 0 \\\ c^2(- a^2 - 1) + c(2a^2d + 2d) + (a^2b^2 - a^2d^2 - d^2) &= 0 \end{aligned}

Now that the equation is in the form of a quadratic, we can use the quadratic formula to determine the solutions for cc.

c=(2a2d+2d)±(2a2d+2d)24(a21)(a2b2a2d2d2)2(a21)c = \frac{-(2a^2d+2d) \pm \sqrt{(2a^2d+2d)^2-4(-a^2-1)(a^2b^2 - a^2d^2 - d^2)}}{2(-a^2-1)}

For readability, we’ll simplify the radicand in the quadratic formula separately:

(2a2d+2d)24(a21)(a2b2a2d2d2) 4a4d2+8a2d2+4d24(a4b2+a4d2+a2d2a2b2+a2d2+d2) 4a4d2+8a2d2+4d2+4a4b24a4d24a2d2+4a2b24a2d24d2 (4a4d24a4d2)+(8a2d24a2d24a2d2)+(4d24d2)+4a4b2+4a2b2 4a4b2+4a2b2\begin{gathered} (2a^2d+2d)^2-4(-a^2-1)(a^2b^2 - a^2d^2 - d^2) \\\ 4a^4d^2 + 8a^2d^2 + 4d^2 - 4(-a^4b^2 + a^4d^2 +a^2d^2 -a^2b^2 +a^2d^2 +d^2) \\\ 4a^4d^2 + 8a^2d^2 + 4d^2 + 4a^4b^2 - 4a^4d^2 - 4a^2d^2 + 4a^2b^2 - 4a^2d^2 - 4d^2 \\\ (4a^4d^2 - 4a^4d^2) + (8a^2d^2 - 4a^2d^2 - 4a^2d^2) + (4d^2 - 4d^2) + 4a^4b^2 + 4a^2b^2 \\\ 4a^4b^2 + 4a^2b^2 \end{gathered}

Then, we can substitute the radicand back into the quadratic formula and continue simplifying.

c=(2a2d+2d)±4a4b2+4a2b22(a21) c=2d(a2+1)±4a4b2+4a2b22(a2+1) c=2d(a2+1)±2aba2+12(a2+1) c=d(a2+1)aba2+1a2+1 c=d(a2+1)a2+1aba2+1a2+1 c=daba2+1a2+1 c=dab(a2+1)12(a2+1)1 c=dab(a2+1)12 c=dab1(a2+1)12 c=daba2+1\begin{aligned} c &= \frac{-(2a^2d+2d) \pm \sqrt{4a^4b^2 + 4a^2b^2}}{2(-a^2-1)} \\\ c &= \frac{-2d(a^2+1) \pm \sqrt{4a^4b^2 + 4a^2b^2}}{-2(a^2+1)} \\\ c &= \frac{-2d(a^2+1) \pm 2ab\sqrt{a^2+1}}{-2(a^2+1)} \\\ c &= \frac{d(a^2+1) \mp ab \sqrt{a^2+1}}{a^2+1} \\\ c &= \frac{d(a^2+1)}{a^2+1} \mp \frac{ab \sqrt{a^2+1}}{a^2+1} \\\ c &= d \mp \frac{ab \sqrt{a^2+1}}{a^2+1} \\\ c &= d \mp \frac{ab (a^2+1)^{\frac{1}{2}}}{(a^2+1)^1} \\\ c &= d \mp ab(a^2+1)^{-\frac{1}{2}} \\\ c &= d \mp ab \cdot \frac{1}{(a^2+1)^{\frac{1}{2}}} \\\ c &= d \mp \frac{ab}{\sqrt{a^2+1}} \end{aligned}

We can now reverse the temporary substitutions to give us a definition of the xx-coordinate of the point of tangency on circle 1.

a=Stb=r1c=xid=x1 xi=x1Str1St2+1\begin{gathered} a = S_t \qquad b = r_1 \qquad c = x_i \qquad d = x_1 \\\ x_i = x_1 \mp \frac{S_t r_1}{\sqrt{S_t^2+1}} \end{gathered}

This equation is in terms of the slope of the tangent line, the xx-coordinate of the center of circle 1, and the radius of circle 1. However, it’s important to note that the tangent’s slope is itself defined by other given values in the problem. Earlier, we manipulated the circle equation so that it was in terms of yy, which allowed us to find its derivative with respect to xx. We can substitute our definition of the xx-coordinate of the point of tangency into this circle equation, allowing us to define the corresponding yy-coordinate.

yi=±r12(xix1)2+y1y_i = \pm \sqrt{r_1^2-(x_i-x_1)^2}+y_1

final external tangent model

The slopes of the tangent lines, the xx-coordinates of the points of tangency, and the yy-coordinates of the points of tangency have all been defined in terms of the original parameters of the problem. By using the point-slope equation f(x)=m(xx1)+y1f(x) = m (x - x_1) + y_1, the final system of equations can be displayed:

St=(y1y2)(x1x2)2+(y1y2)2(r1r2)2±(x1x2)(r1r2)(x1x2)(x1x2)2+(y1y2)2(r1r2)2(y1y2)(r1r2) xi=x1Str1St2+1 yi=±r12(xix1)2+y1 y=St(xxi)+yi\begin{aligned} S_t &= \frac{(y_1-y_2)\sqrt{(x_1-x_2)^2+(y_1-y_2)^2-(r_1 - r_2)^2} \pm (x_1-x_2)(r_1 - r_2)}{(x_1-x_2)\sqrt{(x_1-x_2)^2+(y_1-y_2)^2-(r_1 - r_2)^2} \mp (y_1-y_2)(r_1 - r_2)} \\\ x_i &= x_1 \mp \frac{S_t r_1}{\sqrt{S_t^2+1}} \\\ y_i &= \pm \sqrt{r_1^2-(x_i-x_1)^2}+y_1 \\\ y &= S_t(x - x_i) + y_i \end{aligned}

Unfortunately, because of the ambiguity of the plus-or-minus operators in the system of equations, two of the possible equations generated are not correct, and so the correct equations must be chosen manually.

internal tangent lines

internal tangents of two circles

The process for modelling the internal tangents to two circles is very similar to the process for external tangents. In figure 2, two similar triangles were used to write a ratio involving the radii and the hypotenuses. In figure 8, triangles C1Pi1\triangle C_1 P i_1 and C2Pi3\triangle C_2 P i_3 are similar because they share the vertical angle θ\theta, and they both have a right angle. This allows us to equate the following ratios between corresponding sides:


We can rewrite h2h_2 as dh1d-h_1 and then solve for h1h_1:

r2r1=dh1h1 h1r2r1=dh1 h1r2=r1dr1h1 h1r2+r1h1=r1d h1(r2+r1)=r1d h1=r1dr2+r1\begin{aligned} \frac{r_2}{r_1} &= \frac{d-h_1}{h_1} \\\ \frac{h_1r_2}{r_1} &= d-h_1\\\ h_1r_2 &= r_1d-r_1h_1\\\ h_1r_2 +r_1h_1&= r_1d\\\ h_1(r_2 +r_1) &= r_1d\\\ h_1 &= \frac{r_1d}{r_2 +r_1} \end{aligned}

This definition of h1h_1 allows us to find θ\theta using trigonometry. We can express the sine of θ\theta as the ratio between the opposite side in the right triangle and the hypotenuse:


Then, we can substitute for h1h_1 and solve for θ\theta.

sin(θ)=r1r1dr2+r1 sin(θ)=r1(r2+r1)r1d sin(θ)=r2+r1d θ=arcsin(r2+r1d)\begin{aligned} \sin{(\theta)}&=\frac{r_1}{ \frac{r_1d}{r_2 +r_1}} \\\ \sin{(\theta)}&=\frac{r_1(r_2 +r_1)}{r_1d} \\\ \sin{(\theta)}&=\frac{r_2 +r_1}{d} \\\ \theta&=\arcsin{\left(\frac{r_2 +r_1}{d}\right)} \end{aligned}

Just like the external tangents, the angle of the internal tangents is simply the angle of C(x)C(x), plus or minus the angle θ\theta (see figure 4). Because we already found the angle of C(x)C(x) (called θC\theta_C) when we modeled the external tangents, we can use a similar formula as before:

θt=θC±θ θC=arctan(y1y2x1x2) θt=arctan(y1y2x1x2)±arcsin(r2+r1d)\begin{aligned} \theta_t &= \theta_C \pm \theta \\\ \theta_C &= \arctan{\left( \frac{y_1-y_2}{x_1-x_2} \right)} \\\ \theta_t &= \arctan{\left( \frac{y_1-y_2}{x_1-x_2} \right)} \pm \arcsin{\left(\frac{r_2 +r_1}{d}\right)} \end{aligned}

Then, because the tangent of the angle of a line equals the slope of the line, we can take the tangent of each side to find the slope of the internal tangent lines.

St=tan(arctan(y1y2x1x2)±arcsin(r2+r1d))S_t = \tan{\left(\arctan{\left( \frac{y_1-y_2}{x_1-x_2} \right)} \pm \arcsin{\left(\frac{r_2 +r_1}{d}\right)}\right)}

Finally, we can substitute dd with the formula for the distance between C1C_1 and C2C_2.

St=tan(arctan(y1y2x1x2)±arcsin(r1+r2(x1x2)2+(y1y2)2))S_t = \tan{\left(\arctan{\left(\frac{y_1-y_2}{x_1-x_2}\right)} \pm \arcsin{\left(\frac{r_1 + r_2}{\sqrt{(x_1-x_2)^2+(y_1-y_2)^2}}\right)}\right)}

This is very similar to the formula for the slope of the external tangent lines. In fact, the sole difference between the formulas is that the external tangent equation uses the difference between the circles’ radii, while the internal tangent equation uses the sum of the radii.

Souter tangents=tan(arctan(y1y2x1x2)±arcsin(r1r2(x1x2)2+(y1y2)2)) Sinner tangents=tan(arctan(y1y2x1x2)±arcsin(r1+r2(x1x2)2+(y1y2)2))\begin{aligned} S_{\text{outer tangents}} &= \tan{\left(\arctan{\left(\frac{y_1-y_2}{x_1-x_2}\right)} \pm \arcsin{\left(\frac{r_1 - r_2}{\sqrt{(x_1-x_2)^2+(y_1-y_2)^2}}\right)}\right)} \\\ S_{\text{inner tangents}} &= \tan{\left(\arctan{\left(\frac{y_1-y_2}{x_1-x_2}\right)} \pm \arcsin{\left(\frac{r_1 + r_2}{\sqrt{(x_1-x_2)^2+(y_1-y_2)^2}}\right)}\right)} \end{aligned}

Conveniently, this difference is consistent throughout the rest of the problem. At no point during the problem-solving process involving the external tangents was the term r1r2r_1-r_2 separated or modified, which means that all we need to do to adapt our model to use for the internal tangents is to replace r1r2r_1-r_2 with r1+r2r_1+r_2. Or, to represent both set of tangents in the same system of equations, we can use r1±r2r_1 \pm r_2.

final model

If we rearrange the previous system of equations for external tangent lines, as well as replace r1r2r_1-r_2 with r1±r2r_1 \pm r_2, the updated system of equations can be displayed. We can mathematically model tangent lines to two circles on the coordinate plane using the following system of equations:

a=x1x2b=y1y2c=r1±r2\begin{aligned} a &= x_1-x_2 & b &= y_1-y_2 & c &= r_1 \pm r_2 \end{aligned}