I'm no good at maths. I found this graphic. If it isn't too much trouble, could you tell us if it is accurate:
User Name, thanks for the graphic. I have no issues with the math, except for one minor (but important) note. To use the equations as written, the heights of the ship’s mast and the height of the tower must be measured in meters. I hope that is explicitly stated somewhere on the site you extracted the graphic from.
If you want to use different units (miles, or feet, etc) then some adjustments to the equations would be required.
In more detail, notice the radius of the earth is given in megameters (millions of meters), and the answer is supposed to come out in Km (kilometers). But nowhere in the diagram do they explicitly say what units the “h” values must be expressed in. Dimensional analysis (keeping track of what units things are expressed in at every stage of the mathematics) shows that the ship and tower heights must be entered in meters.
The equations are essentially the same as I used, just applications of the Pythagorean Theorem (in a right triangle, the square of the length of the hypotenuse is equal to the sum of the squares of the lengths of the other two sides).
In my analysis of Daniel’s Bear Mountain view of NYC, I only needed to find one of the “D” distances shown in the figure, so that simplified the diagram and math.
Want more detail, ask.