TITLE: How to find the equation of a line, tangent to a circle, that passes through a given external point
QUESTION [12 upvotes]: I am given the equation of a circle: $(x + 2)^2 + (y + 7)^2 = 25$. The radius is $5$. Center of the circle: $(-2, -7)$.
Two lines tangent to this circle pass through point $(4, -3)$, which is outside of said circle. How would I go about finding one of the equations of the lines tangent to the circle?
I haven't started calculus, so I ask for advice fitting for someone starting a topic like this.

REPLY [7 votes]: Without any loss of generality we can draw a tangent to a circle
with centre $C\equiv(C_x,C_y)$ and radius $r$ and choose a point
$P\equiv(P_x,P_y)$ on the tangent so that its distance from the centre is
$\overline{CP}\equiv d$ with $d \ge r$.

From the sketch above we recognize that the tangency points can be
described as the sums of vectors, i.e.,
$$ \overrightarrow{OT_1} = \overrightarrow{OC}+
  \frac{a}{d}\,\overrightarrow{CP}+
  \frac{b}{d}\,\overrightarrow{CP}',\qquad
  \overrightarrow{OT_2} = \overrightarrow{OC}+
  \frac{a}{d}\,\overrightarrow{CP}-
  \frac{b}{d}\,\overrightarrow{CP}'$$
where the prime in $\overrightarrow{CP}'$ represents a 90⁰
anticlockwise rotation of the vector.
Because our task is now to determine $a/d$ and $b/d$, we observe that
the triangles $CT_1C'$ and $CPT_1$ are similar so that, with the position
$\rho=r/d$, we have
$$\frac{a}{r} = \frac{r}{d} \implies \frac{a}{d}=\left(\frac{r}{d}\right)^2 =\rho^2$$
and
$$\frac{b}{r} = \frac{R}{d} \implies \frac{b}{d}=\frac{rR}{d^2}
=\rho\frac Rd$$
but $R=\sqrt{d^2-r^2}$ and eventually we can write
$$ \frac{b}{d}= \rho\sqrt{1-\rho^2}.$$
From the last relation we recognize 1) that a real solution requires
$\rho\le1$ (i.e., $P$ is not inside the circle) and 2) that for
$\rho=1$ the point $P$ is on the circumference and the tangency points
degenerate into $P$.
The OP can now compute the tangency points, etc.
E.g., in Python 3 (that is as close to pseudo-code as it could possibly be...)
from math import sqrt
# Data Section, change as you need #
Cx, Cy = -2, -7                    #
r = 5                              #
Px, Py =  4, -3                    #
# ################################ #
dx, dy = Px-Cx, Py-Cy
dxr, dyr = -dy, dx
d = sqrt(dx**2+dy**2)
if d >= r :
    rho = r/d
    ad = rho**2
    bd = rho*sqrt(1-rho**2)
    T1x = Cx + ad*dx + bd*dxr
    T1y = Cy + ad*dy + bd*dyr
    T2x = Cx + ad*dx - bd*dxr
    T2y = Cy + ad*dy - bd*dyr

    print('The tangent points:')
    print('\tT1≡(%g,%g),  T2≡(%g,%g).'%(T1x, T1y, T2x, T2y))
    if (d/r-1) < 1E-8:
        print('P is on the circumference')
    else:
        print('The equations of the lines P-T1 and P-T2:')
        print('\t%+g·y%+g·x%+g = 0'%(T1x-Px, Py-T1y, T1y*Px-T1x*Py))
        print('\t%+g·y%+g·x%+g = 0'%(T2x-Px, Py-T2y, T2y*Px-T2x*Py))
else:
    print('''\
Point P≡(%g,%g) is inside the circle with centre C≡(%g,%g) and radius r=%g.
No tangent is possible...''' % (Px, Py, Cx, Cy, r))

Executing the program yields
The tangent points:
    T1≡(-1.1139,-2.07914),  T2≡(2.88314,-8.0747).
The equations of the lines P-T1 and P-T2:
    -5.1139·y-0.920857·x-11.6583 = 0
    -1.11686·y+5.0747·x-23.6494 = 0