On a circle with diameter $A B$, points $C$ and $D$ are taken. The line $C D$ and the tangent to the circle at point $B$ intersect at point $X$. Express $B X$ in terms of the radius of the circle $R$ and the angles $\varphi=\angle B A C$ and $\psi=\angle B A D$.
By the Law of Sines, $B X / \sin B D X = B D / \sin B X D = 2 R \sin \psi / \sin B X D$. Moreover, $\sin B D X = \sin B D C = \sin \varphi$; the measure of angle $B X D$ is easily calculated: if points $C$ and $D$ lie on the same side of $A B$, then $\angle B X D = \pi - \varphi - \psi$, and if on opposite sides, then $\angle B X D = |\varphi - \psi|$. Therefore, $B X = 2 R \sin \varphi \sin \psi / \sin |\varphi \pm \psi|$.