Make EXPT use double-precision throughout in more cases
authorLutz Euler <lutz.euler@freenet.de>
Fri, 1 Jul 2011 16:06:17 +0000 (18:06 +0200)
committerChristophe Rhodes <csr21@cantab.net>
Sun, 20 Nov 2011 15:50:17 +0000 (15:50 +0000)
commitb90e13dea92ee66f06f66baf17c3e3e23c89575f
tree6f67c71f2112eb93969a9ad6233565346b6c6dc9
parent6f9469ddc38dc4d25b0fcc3988d55a9dbef6e2b8
Make EXPT use double-precision throughout in more cases

lp#741564 notes that a Maxima test case fails because the result of
(EXPT <fixnum> <(complex double)>) is much less precise than expected.
This is caused by EXPT using an intermediate single-float value here.

This behaviour actually occurs for all the following combinations
of argument types:

  (EXPT <(or rational single-float)> <(complex double-float)>)

  (EXPT <(or (complex rational) (complex single-float))>
        <(or (complex double-float) double-float)>)

In all these cases the first step EXPT does is to calculate (LOG BASE)
in single precision.

Refine the type dispatch clauses in EXPT to separate these cases
and coerce BASE to DOUBLE-FLOAT or (COMPLEX DOUBLE-FLOAT) there,
as appropriate, before applying LOG. Add tests.

Fixes lp#741564.

Signed-off-by: Christophe Rhodes <csr21@cantab.net>
NEWS
src/code/irrat.lisp
tests/arith.pure.lisp