Solution (source code)

= Solution

Use the small-angle, <thin gravitational lens equation> geometry. An undeflected ray seen at angular position $\theta$ would have transverse source position $D_s\theta$. Bending that ray through physical angle $\hat\alpha$ at the lens changes its source intercept by $D_{ds}\hat\alpha$. Thus
$$
\eta=D_s\theta-D_{ds}\hat\alpha,\qquad \xi=D_d\theta,
$$
and the required physical deflection is
$$
\boxed{\hat\alpha=\frac{D_s\xi/D_d-\eta}{D_{ds}}.}
$$
Also $\beta=\eta/D_s$. Define the reduced deflection $\alpha$ as the angular difference $\theta-\beta$. Dividing the first equation by $D_s$ gives
$$
\boxed{\alpha=\frac{D_{ds}}{D_s}\hat\alpha.}
$$
These are <angular diameter distances>; in a cosmological <spacetime> one must not replace $D_s$ by $D_d+D_{ds}$ as if the distances were ordinary collinear Euclidean lengths.