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:
Substitute (x1,y1) with the coordinates of the first circle and r1 with its radius. Likewise, substitute x2, y2, and r2 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).
introduction
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.
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) and radius r1
Circle 2 with center C2=(x2,y2) and radius r2
r1≥r2
A line is drawn between the centers of the circles, called C(x), and both external tangent lines t1(x) and t2(x) are drawn. The points of intersection between the tangent lines and circle 1 are i1=(xi1,yi1) and i2=(xi2,yi2). The points of intersection on circle 2 are i3=(xi3,yi3) and i4=(xi4,yi4). All three lines intersect at point P. The angle between the first tangent line and the line that connects the centers of the circles is ∠C1Pi1.
slopes of the external tangents
Angle ∠C1i1P 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. Because these right angles are congruent, and because △C1Pi1 and △C2Pi2 share the angle ∠C1Pi1, this makes the triangles similar.
Because these triangles are similar, the ratio between corresponding sides is constant. Therefore,
r2r1=h2h1
We can substitute h1 with the two lengths that make it up: h2+d. Then, by rewriting the equation, we can solve for h2.
Now that h2 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, or θ.
Consider triangle △C2i3P:
Because of the definition of the sine of an angle (the ratio between the opposing side and the hypotenuse in a right triangle), sinθ=h2r2. By taking the inverse sine of each side, we can define θ:
θ=arcsin(h2r2)
To find the angle of the first external tangent line, we can add θ to the angle of C(x) with respect to the x-axis. Similarly, we can subtract θ from the angle of C(x) to find the angle of the second tangent line.
θt=θC±θ
But how do we know the angle of C(x)? The slope of 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.
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:
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(α±β)=1∓tan(α)tan(β)tan(α)±tan(β)
In this case,
α=arctan(x1−x2y1−y2)
and
β=arcsin((x1−x2)2+(y1−y2)2r1−r2)
.
For ease of explanation, we’ll first find tan(α) and tan(β) separately, then substitute them into the identity.
The tangent of α is simple to find, because the arctangent and the tangent functions cancel each other out:
However, the tangent of β 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.
In figure 5, the sine of angle θ is the ratio between the lengths of the opposite side and the hypotenuse, or 1x=x. Therefore, the arcsine of this ratio equals θ:
arcsin(x)=θ
The tangent of θ, or in other words, the tangent of 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: 1−x2. Therefore,
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:
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.
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 y, as it’s
based on the Pythagorean theorem.
(x−x1)2+(y−y1)2=r12
Implicit differentiation would not work in this case, so we need to rewrite the circle equation in terms of y before we differentiate it with respect to x.
This resulting equation gives the relationship between the slope of the tangent line (dxdy) and the x-coordinate of the point of tangency on circle 1.
We need to rewrite this equation in terms of x, because in this case, x is the x-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:
dxdy=Str1x=xix1=a=b=c=d
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 c, which represents xi.
We can now reverse the temporary substitutions to give us a definition of the x-coordinate of the point of tangency on circle 1.
a=Stb=r1c=xid=x1xi=x1∓St2+1Str1
This equation is in terms of the slope of the tangent line, the x-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 y, which allowed us to find its derivative with respect to x. We can substitute our definition of the x-coordinate of the point of tangency into this circle equation, allowing us to define the corresponding y-coordinate.
yi=±r12−(xi−x1)2+y1
final external tangent model
The slopes of the tangent lines, the x-coordinates of the points of tangency, and the y-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(x−x1)+y1, the final system of equations can be displayed:
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
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 and △C2Pi3 are similar because they share the vertical angle θ, and they both have a right angle. This allows us to equate the following ratios between corresponding sides:
r1r2=h1h2
We can rewrite h2 as d−h1 and then solve for h1:
This definition of h1 allows us to find θ using trigonometry. We can express the sine of θ as the ratio between the opposite side in the right triangle and the hypotenuse:
Just like the external tangents, the angle of the internal tangents is simply the angle of C(x), plus or minus the angle θ (see figure 4). Because we already found the angle of C(x) (called θC) when we modeled the external tangents, we can use a similar formula as before:
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.
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.
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 r1−r2 separated or
modified, which means that all we need to do to adapt our model to use
for the internal tangents is to replace r1−r2 with r1+r2. Or, to
represent both set of tangents in the same system of equations, we can
use r1±r2.
final model
If we rearrange the previous system of equations for external tangent
lines, as well as replace r1−r2 with r1±r2, 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:
Note that in each of the first three lines in the system of equations, there are one or more uses of the plus-or-minus or minus-or-plus operator. This means that there are 23=8 possible linear functions that this system could generate, depending on which option (plus or minus) one chooses for each line in the system. Only four of these functions, however, will represent actual tangents, internal or external, to the circles.
limitations of the model
As previously noted, the biggest limitation in this model is that it’s ambiguous: only half of the lines it produces are real tangent lines, so someone using the model would need to manually choose which set to use. There are some situations in which the model breaks — for example, when one or more of the tangent lines would be vertical, the model produces an undefined slope.