Floating point subtraction rounding error (NOT display error)
Carl Banks
pavlovevidence at gmail.com
Fri Dec 14 10:28:03 EST 2007
On Dec 13, 6:20 pm, Keflavich <keflav... at gmail.com> wrote:
> Solved: used round(number,12) in this case for all of the operands of
> my arcsines. Not pretty, but at least VIM made it easy...
>
> Thanks for the help,
> Adam
I suspect this could even fail in some circumstances. If it's for
school you're probably covered, but in real world, it would be better
to:
1. Rewrite calculation to avoid arccos and arcsin (using trigonometric
or geometric identities)
2. Clamp it to range [-1.0:1.0]. You can do this in numpy with
numpy.clip().
Carl Banks
More information about the Python-list
mailing list