Nathaniel Trellice <naptrel@yahoo.co.uk> writes:
> My guess would be that due to rounding errors, the argument passed to
> acos() is outwith the interval [-1,1] and acos() is only defined
> within this interval (for reals).
Yeah. It's not helping any that you've defined geo_deg2rad() to do its
arithmetic in float (that is float4) precision. Making it work in
float8 would probably improve matters. Still, I agree that switching to
a more numerically stable distance calculation would be a good idea.
regards, tom lane