See Deriving Equations for Atmospheric Refraction for how terrestrial atmospheric refraction is calculated from basic physical laws and how the equations and constants used in refraction equations are derived.
See Method to calculate the Radius of the Earth from 3 Points for how the GNSS Data Viewer calculates the radius from 3 selected GPS Vectors.
See WGS84 Coordinate System for how vectors can be transformed between ECEF Cartesian coordinates and Geodetic Ellipsoidal coordinates.
The triangle c, b, R is a right angle triangle. We can use trigonometry to express c:
(1) 
The angle φ can be calculated from the distance d:
(2) 
The line c extended to the horizontal tangent line is also R. So x is the difference R − c:
(3) 
(4) 

exact  
(5) 

good approximation if d ≪ R  
where^{'} 

Approximation: We can use the Taylor series of the cosine function up to the quadratic term cos(φ) ≈ 1 − φ^{2}/2 to get an approximation for small angles:
(6) 
If we use miles for d and 8 inches/miles^{2} for 1/2R we get the famous approximation "8 inches per miles squared".
Drop x is h + c. The blue dash line is a symmetry line. So we can find the height h on the right side too, building the hypotenuse of a right angle triangle with angle φ. With trigonometry we find c = h · cos(φ). So we have:
(7) 
We have another right angle triangle with angle φ: R+h, b, R. In this triangle is R = (R+h) · cos(φ). So we can solve for cos(φ):
(8) 
and replace the cosine of (7):
(9) 
(10) 

exact  
(11) 

good approximation if h ≪ R  
where^{'} 

Approximation: for h ≪ R we can approximate R + h ≈ R:
(12) 
We can find the drop angle φ also at the not visible corner of the right angle triangle R+h, b, R. The cosine of this triangle is:
(13) 
Solving for φ yields:
(14) 

exact  
(15) 

good approximation if h ≪ R  
where^{'} 

Approximation: The angle φ can also be expressed by an asin function if we use the third side b of the triangle, which is b = √ (R + h)^{2} − R^{2} . So φ = asin( b / (R+h) ). The asin function can be approximated to asin(φ) ≈ φ for small angles φ and R + h ≈ R for h ≪ R, so we can make multiple simplifications without loosing much accuracy:
(16)  
(17) 
The angle φ = d / R is one of the angles of the right angle triangle R+h_{O}, R+h_{T}+x, b. The cosine of this angle is the adjacent R+h_{O} divided by the hypotenuse R+h_{T}+x:
(18) 
We can solve for the denominator, which contains our unknown x:
(19) 
And rearranging for x yields:
(20) 
 
where^{'} 

Note, for small angles φ, i.e. if h_{O} ≪ R and h_{T} ≪ R, then y ≈ x. y is the adjecent of a similar right angle triangle with the hypotenuse x. So we can get the exact value for y by multiplying (20) with cos(d/R):
(21) 
 
where^{'} 

(22) 

exact  
(23) 

good approximation if s ≪ d  
where^{'} 

Approximation: For small angle φ we can approximate atan(φ) ≈ φ. The angle φ is small if s ≪ d. If this is the case we get:
(24) 
The magenta line is the direct line of sight from the observer to a target. The orange arc is the corresponding refracted light ray with radius of curvature r. The refraction angle is ρ.
We have a right angle triangle r, d/2, b with an angle ρ. We can use trigonometry to calculate the sine of ρ:
(25) 
The curvature 1/r of the light ray is defined by the refraction coefficient:
(26) 
So we get:
(27) 
For small angles ρ, that is if d ≪ R, we can approximate sin(ρ) ≈ ρ, and using the equation for Angular Size we can calculate the apparent lift due to refraction l to get:
(28) 
 
(29) 
 
where^{'} 

We can simply apply Pythagoras to the right angle triangle R+h, d, R to get our unknown:
(30) 

exact  
(31) 

good approximation if h ≪ R  
where^{'} 

Approximation: We can approximate (R+h)^{2} − R^{2} ≈ 2·R·h if h ≪ R:
(32) 
The expression 2·R·h is much greater than h^{2} if h ≪ R. So we can neglegt h^{2}.