Skip to content

Implement powi without using MPFR #106

@Chris00

Description

@Chris00

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 __m256d to process two double-double simultaneously.

Before doing the work, I'd like to have your opinion about this endeavor.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions