This is an interesting problem, and the anwers given may really help. But I miss a procedure to obtain definite answers.
Someone said, that is a trivial problem, middle-high-school level. I found that it is quite complicated if one tries to find general expressions. These get very quickly very complicated due to square-root terms and so on, so best is to treat it numerically.
Define two circles, a straight line and the slope of the tangent at circle 1
k1 = Sqrt[r1^2 - x^2];
k1n = -Sqrt[r1^2 - x^2];
k2 = Sqrt[r2^2 - (x - d)^2];
k2n = -Sqrt[r2^2 - (x - d)^2];
g = a x + b;
rul1 = a -> D[k1, x] /. x -> x1
The line must have the same value as the circle1 at position x1. This gives b
eq1 = k1 == g /. rul1 /. x -> x1
rul2 = Solve[eq1, b][[1, 1]]
and at x2 the line must have the same values as circle2
eq21 = k2 == g /. x -> x2 /. rul1 /. rul2
eq22 = k2n == g /. x -> x2 /. rul1 /. rul2
The slopes of the line at x1 and x2 must be equal to those of the circles (to get rid of the square-roots I square them)
eq3 = (D[k1, x] /. x -> x1)^2 == (D[k2, x] /. x -> x2)^2
Now define values for the problem
vals = {r1 -> 2.5, r2 -> .9, d -> 4.2};
and solve it
sol1 = NSolve[
{eq21, eq3} /. vals,
{x1, x2}
]
sol2 = NSolve[
{eq22, eq3} /. vals,
{x1, x2}
]
sol1a = sol1 /. (u_ -> v_) :> v
sol2a = sol2 /. (u_ -> v_) :> v
Multiple solutions are possible, so define a test to find appropriate solutions
tst[y1_, y2_] := Module[{},
aa1 = -(y1/Sqrt[r1^2 - y1^2]) /. vals;
aa2 = -((y2 - d)/Sqrt[r2^2 - (y2 - d)^2]) /. vals;
bb = r1^2/Sqrt[r1^2 - y1^2] /. vals;
{aa1, aa2, bb}
]
and apply the test
pp1 = tst @@@ sol1a
param1 = Select[pp1, Abs[#[[1]] - #[[2]]] < .0001 &] // Flatten
pp2 = tst @@@ sol2a
param2 = Select[pp2, Abs[#[[1]] + #[[2]]] < .0001 &] // Flatten
and see what you have got
Plot[
{
k1, k1n,
k2, k2n,
param1[[1]] x + param1[[3]] /. vals,
param2[[1]] x + param2[[3]] /. vals,
-param1[[1]] x - param1[[3]] /. vals,
-param2[[1]] x - param2[[3]] /. vals
} /. vals,
{x, 0, 6},
AspectRatio -> Automatic
]
There is another somewhat shorter approach due to the fact that the straight line is given by the value of circle 1 and its tangent at x1
aa = -x1/Sqrt[r1^2 - x1^2]
bb = Sqrt[r1^2 - x1^2]
gg = aa (x - x1) + bb
At x2 the straight line must have the same value as circle 2
gla = (gg /. x -> x2) == Sqrt[r2^2 - (x2 - d)^2]
Solve for x2
lsgx2 = Flatten[ FullSimplify[Solve[gla, x2], And[r1 > 0, r2 > 0, d > 0]]]
x2 shall be unique, therefore the argument of the square-root has to vanish, giving possible values of x1
z1 = Cases[x2 /. lsgx2[[1]], Sqrt[x__] :> x, Infinity][[1]]
z2 = Cases[x2 /. lsgx2[[2]], Sqrt[x__] :> x, Infinity][[1]]
z1 - z2 // FullSimplify
lsgx1 = Solve[z1 == 0, x1]
with this x1 we can determine x2 (the solutions r1 and - r1 are obviously not appropriate)
lsgx2a = Flatten[FullSimplify[lsgx2 /. Take[lsgx1, -2]]] // DeleteDuplicates
calculate the appropriate x1 and x2 and get the straight lines
lsgx1num = Take[lsgx1, -2] /. vals
lsgx2num = lsgx2a /. vals
sL1 = gg /. lsgx1num[[1]] /. vals
sL2 = gg /. lsgx1num[[2]] /. vals
and plot it
Plot[
{
k1, k1n,
k2, k2n,
sL1,
sL2
} /. vals,
{x, 0, 6},
AspectRatio -> Automatic
]
I tested only a few combinations of vals. The methods worked, but it is possible that there are combinations of circles where it may fail.