cppalliance / decimal

A C++14 implementation of IEEE 754 decimal floating point numbers
https://cppalliance.org/decimal/decimal.html
Boost Software License 1.0
17 stars 1 forks source link

elliptic integral improvements #624

Closed ckormanyos closed 2 weeks ago

ckormanyos commented 1 month ago

The purpose of this PR is to get the C++17 elliptic integral functions working and tested.

ckormanyos commented 1 month ago

Might stop at ellint_1 and ellint_2 complete and postpone ellint_3. I'll need a few days for this state anyway.

codecov[bot] commented 1 month ago

Codecov Report

Attention: Patch coverage is 96.70330% with 15 lines in your changes missing coverage. Please review.

Project coverage is 98.5%. Comparing base (80060d2) to head (54fa90a).

Additional details and impacted files [![Impacted file tree graph](https://app.codecov.io/gh/cppalliance/decimal/pull/624/graphs/tree.svg?width=650&height=150&src=pr&token=drvY8nnV5S&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=cppalliance)](https://app.codecov.io/gh/cppalliance/decimal/pull/624?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=cppalliance) ```diff @@ Coverage Diff @@ ## develop #624 +/- ## ========================================= + Coverage 98.5% 98.5% +0.1% ========================================= Files 221 223 +2 Lines 15673 16048 +375 Branches 1727 1774 +47 ========================================= + Hits 15428 15807 +379 + Misses 245 241 -4 ``` | [Files](https://app.codecov.io/gh/cppalliance/decimal/pull/624?dropdown=coverage&src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=cppalliance) | Coverage Δ | | |---|---|---| | [include/boost/decimal/cmath.hpp](https://app.codecov.io/gh/cppalliance/decimal/pull/624?src=pr&el=tree&filepath=include%2Fboost%2Fdecimal%2Fcmath.hpp&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=cppalliance#diff-aW5jbHVkZS9ib29zdC9kZWNpbWFsL2NtYXRoLmhwcA==) | `100.0% <ø> (ø)` | | | [...lude/boost/decimal/detail/cmath/impl/atan\_impl.hpp](https://app.codecov.io/gh/cppalliance/decimal/pull/624?src=pr&el=tree&filepath=include%2Fboost%2Fdecimal%2Fdetail%2Fcmath%2Fimpl%2Fatan_impl.hpp&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=cppalliance#diff-aW5jbHVkZS9ib29zdC9kZWNpbWFsL2RldGFpbC9jbWF0aC9pbXBsL2F0YW5faW1wbC5ocHA=) | `100.0% <100.0%> (ø)` | | | [...st/decimal/detail/cmath/impl/riemann\_zeta\_impl.hpp](https://app.codecov.io/gh/cppalliance/decimal/pull/624?src=pr&el=tree&filepath=include%2Fboost%2Fdecimal%2Fdetail%2Fcmath%2Fimpl%2Friemann_zeta_impl.hpp&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=cppalliance#diff-aW5jbHVkZS9ib29zdC9kZWNpbWFsL2RldGFpbC9jbWF0aC9pbXBsL3JpZW1hbm5femV0YV9pbXBsLmhwcA==) | `100.0% <ø> (ø)` | | | [include/boost/decimal/detail/cmath/sin.hpp](https://app.codecov.io/gh/cppalliance/decimal/pull/624?src=pr&el=tree&filepath=include%2Fboost%2Fdecimal%2Fdetail%2Fcmath%2Fsin.hpp&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=cppalliance#diff-aW5jbHVkZS9ib29zdC9kZWNpbWFsL2RldGFpbC9jbWF0aC9zaW4uaHBw) | `100.0% <ø> (ø)` | | | [test/test\_atan.cpp](https://app.codecov.io/gh/cppalliance/decimal/pull/624?src=pr&el=tree&filepath=test%2Ftest_atan.cpp&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=cppalliance#diff-dGVzdC90ZXN0X2F0YW4uY3Bw) | `100.0% <100.0%> (ø)` | | | [test/test\_ellint\_1.cpp](https://app.codecov.io/gh/cppalliance/decimal/pull/624?src=pr&el=tree&filepath=test%2Ftest_ellint_1.cpp&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=cppalliance#diff-dGVzdC90ZXN0X2VsbGludF8xLmNwcA==) | `100.0% <100.0%> (ø)` | | | [test/test\_ellint\_2.cpp](https://app.codecov.io/gh/cppalliance/decimal/pull/624?src=pr&el=tree&filepath=test%2Ftest_ellint_2.cpp&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=cppalliance#diff-dGVzdC90ZXN0X2VsbGludF8yLmNwcA==) | `100.0% <100.0%> (ø)` | | | [test/test\_log10.cpp](https://app.codecov.io/gh/cppalliance/decimal/pull/624?src=pr&el=tree&filepath=test%2Ftest_log10.cpp&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=cppalliance#diff-dGVzdC90ZXN0X2xvZzEwLmNwcA==) | `100.0% <100.0%> (ø)` | | | [test/test\_tgamma.cpp](https://app.codecov.io/gh/cppalliance/decimal/pull/624?src=pr&el=tree&filepath=test%2Ftest_tgamma.cpp&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=cppalliance#diff-dGVzdC90ZXN0X3RnYW1tYS5jcHA=) | `100.0% <ø> (ø)` | | | [include/boost/decimal/detail/cmath/log10.hpp](https://app.codecov.io/gh/cppalliance/decimal/pull/624?src=pr&el=tree&filepath=include%2Fboost%2Fdecimal%2Fdetail%2Fcmath%2Flog10.hpp&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=cppalliance#diff-aW5jbHVkZS9ib29zdC9kZWNpbWFsL2RldGFpbC9jbWF0aC9sb2cxMC5ocHA=) | `94.5% <75.0%> (+2.6%)` | :arrow_up: | | ... and [4 more](https://app.codecov.io/gh/cppalliance/decimal/pull/624?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=cppalliance) | | ... and [1 file with indirect coverage changes](https://app.codecov.io/gh/cppalliance/decimal/pull/624/indirect-changes?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=cppalliance) ------ [Continue to review full report in Codecov by Sentry](https://app.codecov.io/gh/cppalliance/decimal/pull/624?dropdown=coverage&src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=cppalliance). > **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=cppalliance) > `Δ = absolute (impact)`, `ø = not affected`, `? = missing data` > Powered by [Codecov](https://app.codecov.io/gh/cppalliance/decimal/pull/624?dropdown=coverage&src=pr&el=footer&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=cppalliance). Last update [80060d2...54fa90a](https://app.codecov.io/gh/cppalliance/decimal/pull/624?dropdown=coverage&src=pr&el=lastupdated&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=cppalliance). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=cppalliance).
ckormanyos commented 1 month ago

OK I got ellint_1 and ellint_2 and also handled with series approximation the regions ${\phi}~{\approx}~0$. Also $128$-bit tests are running.

ckormanyos commented 1 month ago

Hi Matt (@mborland)

I still need a day or two on this one, ... but...

This one makes a pretty good start at elliptix_x. I'll handle either all or 2/3 of the points above and then hammer this one in within a day or so. This is a cool function to compute since it is one of the epic examples of actually using AGM-iteration to get numerical answers.

ckormanyos commented 1 month ago

Thanks for getting this working properly!

Sure thing Matt (@mborland).

It's not quite yet done. In the 32-bit case, I still have a few convergence misses (like one in a few million). I still need to fully fix the iteration parameters and see why some extreme cases don't converge. I might just use Taylor series or Pade for a sub-class of 32-bit cals.

Anyway, I need still a day or two to get this thing into develop.

ckormanyos commented 1 month ago

Still getting tiny fuzz at ${\approx}~{1}/{1,000,000}$ rate. The answer for sporadic points is a factor of $2$ too large. Re-convert PR to draft.

ckormanyos commented 2 weeks ago

Hi Matt (@mborland) this one took a while. I finished ellint_1() and ellint_2() and also improved tan() and a few other problem-ettes along the way.

ckormanyos commented 2 weeks ago

Thanks Matt. This wqas a challenging one. I ended up using some old code and the fundamental AGM equations found in the NIST DLMF here. It is always fun to derive an algorithm directly from the literature.

I'll move on to ellint_3(), probably sticking with AGM methods.