There are $2$ non-overlapping circles $A$ and $B$ with radius $r_1$ and $r_2$, respectively. The distance between $A$ and $B$ is $d$. A shared tangent is drawn, with the points of tangency being $C$ and $D$, for circles $A$ and $B$, respectively. What is the length of $\overline{CD}$?
I have a solution for this but I just wanted to make sure that it is correct.
MY SOLUTION:
(Pretend that the purple line is tangent to both circle $A$ and $B$)
(Link to graph)
Let $E$ be the intersection point of $\overline{AB}$ and $\overline{CD}$. We are trying to find the length of $\overline{CD}$, which I will split into $\overline{CE}$ and $\overline{DE}$. Because $C$ is tangent to circle $A$, we know that $m\angle ACE=90^\circ$. Similarly, $m\angle BCE=90^\circ$. $m\angle CEA=m\angle BED$, because they are vertical angles. By AA similarity, $\triangle ACE\sim\triangle BDE$. We can now write the following ratio:$$\frac{AC}{BD}=\frac{AE}{BE}\\\frac{r_1}{r_2}=\frac{AE}{BE}$$I then split $AB=d$ into $r_1+r_2$ pieces. $AE$ would take up $r_1$ of the pieces, so $AE=\frac{d*r_1}{r_1+r_2}$. $BE$ would take up $r_2$ pieces so $BE=\frac{d*r_2}{r_1+r_2}$. Because $ACE$ is a right triangle, I can use Pythagorean Theorem to say that:$$\begin{align}(CE)^2&=(AE)^2-(AC)^2\\&=\left(\frac{dr_1}{r_1+r_2}\right)^2+r_1^2\\&=\frac{d^2r_1^2}{\left(r_1+r_2\right)^2}-r_1^2\\&=\frac{d^2r_1^2-r_1^2(r_1+r_2)^2}{\left(r_1+r_2\right)^2}\\&=\frac{r_1^2(d^2-(r_1+r_2)^2)}{\left(r_1+r_2\right)^2}\\CE&=\sqrt{\frac{r_1^2(d^2-(r_1+r_2)^2)}{\left(r_1+r_2\right)^2}}\\&=\frac{\sqrt{r_1^2(d^2-(r_1+r_2)^2)}}{r_1+r_2}\\&=\frac{r_1\sqrt{d^2-(r_1+r_2)^2}}{r_1+r_2}\\&=\frac{r_1\sqrt{(d+r_1+r_2)(d-r_1-r_2)}}{r_1+r_2}\end{align}$$
With similar steps, we can compute that:$$DE=\frac{r_2\sqrt{(d+r_1+r_2)(d-r_1-r_2)}}{r_1+r_2}$$
With these information, we can solve the problem:$$\begin{align}CD&=CE+DE\\&=\frac{r_1\sqrt{(d+r_1+r_2)(d-r_1-r_2)}}{r_1+r_2}+\frac{r_2\sqrt{(d+r_1+r_2)(d-r_1-r_2)}}{r_1+r_2}\\&=\frac{(r_1+r_2)\sqrt{(d+r_1+r_2)(d-r_1-r_2)}}{r_1+r_2}\\&=\boxed{\sqrt{(d+r_1+r_2)(d-r_1-r_2)}}\end{align}$$Did I do this problem correcly? Is there an easier/alternate method to solving this problem?
EXTRA(you don't need to solve but you can): Does the answer change if the circles were overlapping?
Thanks in advance.
