Sunrise/sunset: definition and errors

The common definition is that sunrise or sunset happens when the upper limb of the apparent image (corrected for atmospheric refraction) of the sun touches the astronomical horizon.

Unfortunetately, this not the same as the apparent horizon (curvature of the Earth is exaggerated for clarity):

When the persons eyes are 2 m above sea level, the angle v is small, about 0.044 degrees, and the apparent horizon line is 5 km away.

But, unless you are standing on a very flat shore (or on a very wide plain), this error could be considerably higher, as shown here (drag the slider for different elevations) - the graph shows the situation at the predicted set/rise time: