Q:

Calculate the circle that touches three other circles

Given three circles on a cartesian grid (with centres and radii known), how would you calculate the centre of the circle that touches those three?
The three known circles may have any radius length, and may touch or cross each other (but not have overlapping centres), but the calculated circle must lie externally to the three known circles.
See this online graphing tool for an example of how this looks:
https://www.desmos.com/calculator/lf1q90ymrh
Note: Imagine we have the first 3 circles as given (two red ones, plus a black one). The question is: how can we mathematically deduce the formula of the fourth circle - the purple one - that just touches the first three? In this example I added the purple circle by trial-and-error, and it is only approximate.
There is one answer against this question already. It might be correct but I don't understand how to start with 3 concrete circles - like in the link above - and then work out the fourth. I think I need someone to take that linked example, use the numbers there, and explain how to perform the maths to calculate the fourth.

A:

Updated Post
Imagine three circles that are offset by the same value $r$ concentric to the three generating circles. 

For a special value of $r$ the three circles meet, at the center of the tangent circle you want to find.

This can be used to set up three non-linear equation for three unknowns: The circle center $(x,y)$ and the radius $r$. 
$$\begin{aligned}
  (x-x_1)^2 + (y-y_1)^2 & = (r_1 + r)^2 \\
  (x-x_2)^2 + (y-y_2)^2 & = (r_2 + r)^2 \\
  (x-x_3)^2 + (y-y_3)^2 & = (r_3 + r)^2 \\
\end{aligned} \; \tag{1} $$
The three generating circles have centers $(x_1,y_1)$, $(x_2,y_2)$, and $(x_3,y_3)$, and radii $r_1$, $r_2$ and $r_3$.
To solve the above, subtract the 2nd equation from the 1st, and the 3rd equation from the 1st to generate two linear equations in terms of $x$ and $y$, but still dependent linearly on $r$.
$$\begin{aligned}
  2 x (x_2-x_1) + 2 y (y_2-y_1) = r (2 r_1 -2 r_2 ) + K_a \\
  2 x (x_3-x_1) + 2 y (y_3-y_1) = r (2 r_1 -2 r_3 ) + K_b
\end{aligned} \; \tag{2} $$
with known constants $$\begin{aligned}
 K_a & = r_1^2-r_2^2-x_1^2+x_2^2-y_1^2+y_2^2 \\
 K_b & = r_1^2-r_3^2-x_1^2+x_3^2-y_1^2+y_3^2 \end{aligned}$$
The solution to the above system of equations is of the form
$$\begin{aligned}
  x & = A_0 + A_1 r \\
  y & = B_0 + B_1 r
\end{aligned} \; \tag{3} $$
with known constants 
$$\begin{aligned} 
  D & = x_1(y_2-y_3)+x_2(y_3-y_1)+x_3(y_1-y_2) \\
\\
  A_0 &= \frac{K_a(y_1-y_3)+K_b(y_2-y_1)}{2 D} \\
  B_0 &= -\frac{K_a(x_1-x_3)+K_b(x_2-x_1)}{2 D}  \\
  A_1 &= -\frac{r_1(y_2-y_3)+r_2(y_3-y_1)+r_3(y_1-y_2)}{D}\\
  B_1 &= \frac{r_1(x_2-x_3)+r_2(x_3-x_1)+r_3(x_1-x_2)}{D}
\end{aligned}$$
Finally, take the equation of the first circle, and substitute $(x,y)$ from above in order to solve for $r$
$$ ( A_0 + A_1 r-x_1)^2 + (B_0 + B_1 r-y_1)^2 = (r_1+r)^2 $$
The above is a single quadratic equation to be solved for $r$. Expand into
$$ C_0 + 2 C_1 r + C_2 r^2 =0 \; \tag{4}$$
with known constants
$$\begin{aligned}
  C_0 &= (A_0-x_1)^2 + (B_0-y_1)^2 - r_1^2 \\
  C_1 & =  A_1 ( A_0-x_1) + B_1 (B_0-y_1) -r_1 \\
  C_2 & = A_1^2+B_1^2-1
\end{aligned}$$
and solutions
$$ \boxed{ r = \frac{-C_1 \pm \sqrt{C_1^2-C_0 C_2}}{C_2} } \; \tag{5}$$
Once you have the radius $r$ use Equation $(3)$ to find the center $(x,y)$.

A numerical example with MATLAB is below
%Three circles
x_1=10; y_1=10; r_1 = 2.5;
x_2=4; y_2=3; r_2 = 3;
x_3=3; y_3=7; r_3 = 5;

draw_circle(x_1,y_1,r_1);
draw_circle(x_2,y_2,r_2);
draw_circle(x_3,y_3,r_3);

% Find constant of circle #2- cirlce #1
K_a = -r_1^2+r_2^2+x_1^2-x_2^2+y_1^2-y_2^2
% Find constant of circle #3- cirlce #1
K_b = -r_1^2+r_3^2+x_1^2-x_3^2+y_1^2-y_3^2

% Find constants of [x=A_0+A_1*r, y=B_0+B_1*r]
D = x_1*(y_2-y_3)+x_2*(y_3-y_1)+x_3*(y_1-y_2)
A_0=(K_a*(y_1-y_3)+K_b*(y_2-y_1))/(2*D)
B_0=-(K_a*(x_1-x_3)+K_b*(x_2-x_1))/(2*D)
A_1=-(r_1*(y_2-y_3)+r_2*(y_3-y_1)+r_3*(y_1-y_2))/D
B_1=(r_1*(x_2-x_3)+r_2*(x_3-x_1)+r_3*(x_1-x_2))/D

% Find constants of C_0 + 2*C_1*r + C_2^2 = 0
C_0=A_0^2-2*A_0*x_1+B_0^2-2*B_0*y_1-r_1^2+x_1^2+y_1^2
C_1=A_0*A_1-A_1*x_1+B_0*B_1-B_1*y_1-r_1
C_2=A_1^2+B_1^2-1

% Solve for r
r=(-sqrt(C_1^2-C_0*C_2)-C_1)/C_2
% Solve for [x,y]
x = A_0+A_1*r
y = B_0+B_1*r

%Check results
draw_circle(x,y,r);

function h = draw_circle(x,y,r)
    hold on
    t = 0:pi/50:2*pi;
    x_p = r*cos(t)+x;
    y_p = r*sin(t)+y;
    h = plot(x_p,y_p);
    hold off
end

Output:

NOTE: The other solution with r=(+sqrt(C_1^2-C_0*C_2)-C_1)/C_2 is

A:

WLOG, one of the given circles is centered at the origin.
Express that the distance between the center of the searched circle and the other centers is the difference of the respective radii.
$$\begin{cases}(r-r_0)^2=x^2+y^2\\(r-r_1)^2=(x-x_1)^2+(y-y_1)^2\\(r-r_2)^2=(x-x_2)^2+(y-y_2)^2.\end{cases} \tag1$$
Now, subtracting these equations in pairs,
$$\begin{cases}2r(r_1-r_0)+(r_1^2-r_0^2)=2xx_1+2yy_1 -x_1^2-y_1^2\\2r(r_2-r_0)+(r_2^2-r_0^2)=2xx_2 +2yy_2-x_2^2-y_2^2.\end{cases} \tag2$$
This system is linear and you can solve for $x,y$ in terms of $r$,
$$\begin{cases}x=ar+b\\y=cr+d.\end{cases} \tag3$$
Plug this in the first equation and get the quadratic
$$(r-r_0)^2=(ar+b)^2+(cr+d)^2. \tag4$$

Note that this gives you for the same "price" the construction of the circumcircle of three points, by setting $r_0=r_1=r_2=0$.
$$\begin{cases}0=2xx_1+2yy_1 -x_1^2-y_1^2\\0=2xx_2 +2yy_2-x_2^2-y_2^2.\end{cases}$$
$$r^2=b^2+d^2=x^2+y^2.$$

