computing expontential as repeated multiplication for small integer exponent



On 7/30/07, Raymond Toy <raymond.toy at ericsson.com> wrote:

> Why is this so important?  What if sin(1.23456789101112d0) returns
> different results from different lisps?  Are you going to add a
> floating-point sin implementation to maxima just so they all agree?
> And what about the Lisp reader?  There are lots of floating-point
> coefficients in the Lisp source.  Are you going to force all lisps to
> use the same reader to produce the same numbers?

You're right, EXPT itself is not very important. Any other float
function could produce similarly-different results. I just got
hung up on quieting the complaint from rtest8 #69.

> But doesn't this mean that either your problem is ill-conditioned,
> or your algorithm is unstable?  Do you know the analytical solution?
> If not how to you know which one is "correct"?

For numerical problems without known exact results, the best
I can do is inspect a solution to see if it seems correct.
If numerical results differ, I'll have to inspect each distinct
result in the same way. If they agreed, at least they are
all equally correct or incorrect.

> But we can't guarantee that FP operations will come out the same
> unless maxima implements them all.  I don't think we want to do that.
> The best we can do is assume IEEE arithmetic and assume the 4 basic
> ops plus sqrt are correct.

I think we could do better by importing GNU Scientific Library or
something like that. (Although GSL would require CFFI, which
GCL doesn't support ... sigh.)

> Don't get me wrong.  I understand your desire to have all Lisps
> produce the same result.  I just don't think making things less
> accurate is the way to go.  (I have asserted that sbcl has an accurate
> expt.  I haven't proven it, though.)

I don't really accept this argument. If different implementation
disagree, one is more accurate than the others. If we always
had to preserve the most accurate one, we could never force
them to agree. But that's really beside the point, which is that
EXPT is not really very important.

best
Robert