This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] Optimize x*x*x*x*x*x using 3 multiplications.


> Indeed, very interesting! If you have got two more spare minutes, I 
> would be curious to know a sketch of the explanation of this.

Consider the simpler case

  a = x*x*x*x;

  a = (x**2)**2;

the second form has only two multiplications instead of three.

So casual intuition (your deadly enemy when it comes to floating-point)
expects less loss of accuracy with only two operations.

But a careful error analysis shows that the error bounds for the second
case can be larger than those for the first case (obviously this depends
on the value of x in general).

An intuitive understanding (which is only slightly misleading :-) is that
in the first case, for each of the three multiplications, at least one of
the operands is error-free, but in the second case, the second multiplication
is between two quantities, both of which have rounding "errors".


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]