Given two touching circles, find position of a third circle of known radius so that it touches them To give an idea of what my end goal looks like visually:

You start with one circle. You add a second circle, making it touch the first circle at some point. For each successive circle (for which we know the radius) to be added, there should be exactly two ways for it to touch the previous two (for which we know the coordinates of their centers and their radii). Is there a formula that expresses these solutions?
 A: We have two circles, with radii $r_1$ and $r_2$ and centres $(x_1,y_1)$ and $(x_2 ,y_2)$ respectively. These two circles touch, so we can say that the distance between the two centres is $$\sqrt{(x_1-x_2)^2+(y_1-y_2)^2} =r_1+r_2$$
We have a third circle with known radius $r_3$ and we want to find its possible centres $(x_3,y_3)$.
We know that the distance between the centre of circle $1$ and $3$ will be $$\sqrt{(x_1-x_3)^2+(y_1-y_3)^2} = r_1+r_3$$ and the distance between the centre of circle $2$ and $3$ will be $$\sqrt{(x_2-x_3)^2+(y_2-y_3)^2} = r_2+r_3$$
We can see this in the below diagram:

We can the use these two equations to solve for $(x_3,y_3)$
\begin{align}\sqrt{(x_1-x_3)^2+(y_1-y_3)^2} &= r_1+r_3\tag{1}\\
\sqrt{(x_2-x_3)^2+(y_2-y_3)^2} &= r_2+r_3\tag{2}\end{align}
as we know the values of all the other variables, $x_1,y_1,r_1,x_2,y_2,r_2,r_3$

Example:
We have a circle centre $(1,1)$, radius $2$, and a circle centre $(4,5)$, radius $3$. We want to add another circle of radius $1$. 
We input all these values into the formulae above:
\begin{align}\sqrt{(1-x_3)^2+(1-y_3)^2} &= 3\tag{1}\\
\sqrt{(4-x_3)^2+(5-y_3)^2} &= 4\tag{2}\end{align}
We can solve these for $(x_3,y_3)$ to find that the two possible centres are $$(4,1)\text{ and }\left(\frac 4{25},\frac {97}{25}\right)$$
I'll leave it to you to plot these $4$ circles and see that it works!
A: Let $C_1$, $r_1$ and $C_2$, $r_2$ be the centers and radii of the two existing circles, and $r$ the radius of the tangent circles. We want to find the center $C$ of the tangent circle that’s counterclockwise from $\overrightarrow{C_1C_2}$.
Consider the triangle $\triangle{C_1C_2C}$. Let $B$ be the foot of the altitude from $C$.

By the Pythagoran theorem, $CC_1^2-BC_1^2=CC_2^2-BC_2^2$. Setting $d=BC_1$ and substituting the known side lengths, this equation becomes $$(r+r_1)^2-d^2=(r+r_2)^2-(r_1+r_2-d)^2.$$ Solving this for $d$ gives $$d={r_1(r+r_1)-r_2(r-r_1)\over r_1+r_2}\tag1$$ and the altitude $BC=h=\sqrt{(r+r_1)^2-d^2}=\sqrt{(r+r_2)^2-d^2}$. Set $\vec u={C_2-C_1\over r_1+r_2}$ (the unit vector that points from $C_1$ to $C_2$) and $\vec v=\operatorname{rot}(\vec u)=\langle -u_y,u_x\rangle$ ($\vec u$ rotated 90° counterclockwise). Then $$C=C_1+d\vec u+h\vec v.\tag2$$ If you’re coding this up, it might be more convenient to absorb the normalization factor $r_1+r_2$ into the triangle side lengths, i.e., $C=C_1+{d\over r_1+r_2}(C_2-C_1)+{h\over r_1+r_2}\operatorname{rot}(C_2-C_1)$.
