I'm assuming that "touches" means tangent to the circle.
Your line has the equation y = mx + c
Your circle has the equation x2 + y2 - 2ax = 0
If we substitute the line's equation into the circle's equation, we get:
x2 + (mx + c)2 - 2ax = 0
(1+m2)x2 + 2(cm-a)x + c2 = 0
We can use the quadratic formula to solve this equation. Since the line is tangent, the quadratic formula must have one solution and thus the discriminant is 0. So the quadratic formula simplifies to:
x = -b/2a
(Note that this is the quadratic formula. The a here is the leading coefficient and not the a of the formulas above.)
x = -2(cm-a) / 2(1+m2) = (a-cm) / (1+m2)
We put this solution back into our circle's equation. After simplification, it becomes:
m = (a2-c2) / 2ac

Louis-Dominique D.
07/06/24