-
Notifications
You must be signed in to change notification settings - Fork 2
Implement powi without using MPFR #106
Description
I've implemented powi without the use of MPFR, using repeated squaring (distinguishing cases according to the sign of the interval bounds). It is 4.5–5 times faster than the MPFR version — something that may matter when powi is a building block of code that will be run millions of times. However, the returned intervals are a few ulp larger so the tests no longer pass. One example is tests/itf1788_tests/libieeep1788_elem.rs:3567:5:
assert_eq2!(
n2i(13.1, 13.1).powi(8),
n2i(867302034.6900622, 867302034.6900623)
);where I get (with the new Debug printing):
thread 'itf1788_tests::libieeep1788_elem::minimal_pown_test' panicked at tests/itf1788_tests/libieeep1788_elem.rs:3567:5:
assertion failed: `(left == right)`
left: `Interval [867302034.6900619, 867302034.6900629]`,
right: `Interval [867302034.6900622, 867302034.6900623]`
How important is it for the intervals to be tight? If it is, one may locally use double-doudle arithmetic to get the rounding correct. There is the qd crate that can serve as an inspiration. I think however it is better to implement the operations (we need very few of them) ourselves to
- get upward rounding;
- use
__m256dto process two double-double simultaneously.
Before doing the work, I'd like to have your opinion about this endeavor.