How to determine that 2.0 == (float) 2 in a front-end.
Erik Schnetter
schnetter@uni-tuebingen.de
Sun Jun 30 12:46:00 GMT 2002
Robert Dewar wrote:
>
> x**6.0 can be rendered as x**6 (which is y=x*x, z=y*y, z=z*y).
>
> Note that this is liikely less accurate than calling a well written
> pow routine.
>
> Note that for example x*x*x*x is generally more accurate than x**2**2
Why is that? Naively, I would think that x*x*x*x (evaluated left to right)
has 3 multiplications in a row, while (x**2)**2 has only two. So, from an
error propagation point of view, the latter should be more accurate.
Wrt your first statement: I assume that a "well written pow routine" would
calculate that as or similar to exp(6.0 * log(x)). This surely involves many
more floating point operations. Is it really more accurate? [Checking
glibc... Moving on to to http://oss.software.ibm.com/mathlib/...] Okay, it
seems to be. I'm impressed.
-erik
--
Erik Schnetter <schnetter@uni-tuebingen.de>
Web: http://www.tat.physik.uni-tuebingen.de/~schnette/
More information about the Gcc
mailing list