Your second picture has the answer.
The lowest right triangle formed with (x + x') as hypotenuse, and with (ht +hr) and d as perpendicular sides gives
x + x' = sqrt ( (ht +hr)^2 + d^2 )
Another right angled triangle is the top one with l as hypotenuse and d and ht -hr as perpendicular sides. This gives
l = sqrt ( (ht-hr)^2 + d ^2 )
subtracting gives you the reqd result.
And the second results comes from using (1 +x )^n = 1 +nx when x << 1. Here we have x = ((ht ± hr)/d)^2
- b