2
0
mirror of https://github.com/boostorg/math.git synced 2026-02-24 04:02:18 +00:00
Commit Graph

152 Commits

Author SHA1 Message Date
Evan Miller
d7141cd353 Jacobi Theta functions (#394)
* Jacobi Theta functions

Implementations, tests, and ULP plotting programs are provided for the
four Jacobi Theta functions per #373. Twenty-four public C++ functions
are provided in all, covering various precision-preserving scenarios.

Documentation for collaborators is provided in the code comments. Proper
documentation for end users will be provided when the implementation and
APIs are finalized.

Some tests are failing; this implementation is meant to start a
conversation. The core dilemma faced by the author was that large values
of |q| resulted in slow convergence, and sometimes wildly inaccurate
results. Following the implementation note in DLMF 20.14, I added code
to switch over to the imaginary versions of the theta functions when |q|
> 0.85.  This restored accuracy such that all of the identity tests
passed for a loose-enough epsilon, but then lost precision to the point
that the Wolfram Alpha spot checks failed. It is the author's hope that
someone with floating-point experience can tame the exponential dragons
and squeeze the ULPs back down to a reasonable range when |q| is large.

When #392 is merged I will add more thorough value tests, although I
fully expect them to fail until the underlying precision issues are
resolved.

As a final note, the precision issues do not affect the z=0 case - the
ULP plots indicate these return values within 2 ULP across all valid
|q|. So that's a start.

* [CI SKIP] Jacobi theta: Add special-value tests and more

* Add tests covering z=0 special values from MathWorld

* Add missing real_concept header

* Replace M_PI and friends with constants::pi etc

* Use BOOST_MATH_STD_USING in more places

* Jacobi theta: Test two more of Watson's identities [CI SKIP]

See https://mathworld.wolfram.com/JacobiThetaFunctions.html

(Equations 48 and 49)

* Improve precision of Jacobi theta functions [CI SKIP]

Rewrite the private imaginary versions to use double-sided summations
following DLMF 20.13.4 and 20.13.5. This cuts down the worst of the
precision issues by a factor of 10, and gets more of the tests to pass.

I am confident enough in the code path to eliminate the compile-time
__JACOBI_THETA_USE_IMAGINARY flag. In fact the imaginary-z code paths
are now enabled for all |q| > 0.04, i.e. most legal values of q.

More extensive tests will be needed to illuminate any remaining
precision issues.

* Jacobi theta: Make changes suggested in #394 [CI SKIP]

* Add LICENSE notice to main file

* Document convergence criteria

* Eliminate eps*eps = 0 logic. This causes some disagreement with the
zero returned by Wolfram Alpha for z=0, q > 0.99 in the fourth function.
Mathematically, the fourth function is never exactly zero, so I don't
trust Wolfram here.

* Per code-review comments, remove multiplications by floating-point 2.

* Tweak the plotting programs to display their titles, and to uniformly
use `float` as their CoarseType and `long double` as their
`PreciseType`.

* Add quadrature tests to Jacobi theta functions [CI SKIP]

The quadrature tests revealed a problem in the m1 functions: they too
should switch to the _IMAGINARY logic for q > exp(-pi), or will suffer
from slow convergence. Fix them.

Also tighten tolerances for many tests from sqrt(eps) to 100 * eps.

* Test Jacobi thetas against elliptic functions and elliptic integrals [CI SKIP]

See:

* https://dlmf.nist.gov/22.2
* https://dlmf.nist.gov/20.9#i

* Test Jacobi Thetas against their Laplace transforms [CI SKIP]

See:

* https://dlmf.nist.gov/20.10#ii

I did find some disagreement, and dropped the negative sign from the
theta1 equation. DLMF's theta2 and theta3 Laplace transform equations do
not agree at all with the computed values - will need to investigate.

In the meantime, the two implemented equations agree to 4 EPS so I am
keeping them.

* Add a note on using log1p with Jacobi theta functions [CI SKIP]

See discussion:

* https://github.com/boostorg/math/pull/394#issuecomment-655871762

* Add random data tests to Jacobi Theta functions [CI SKIP]

Add a test data generator program for the Jacobi theta functions.
This program will produce data for the tau parameterization, so that
precision isn't lost during the log-transformation. This distinguishes
it from the Wolfram Alpha data, which is parameterized by q.

A few of these new random-data tests are failing, but not by obscene
margins (< 100 EPS). These failures will be addressed when the test
tolerances are finalized.

* Add small-tau tests and simplify Jacobi Theta code [CI SKIP]

Add tests for small tau (i.e. large q). The tests are failing with mean
~ 200 EPS and max ~ 800 EPS. These look like worst-case input, and
should be the focus of future accuracy improvements.

This commit also simplifies the _IMAGINARY code by abstracting all of
the loops into a single svelte function.

* Add user documentation for Jacobi Theta functions [CI SKIP]

* Add function graphs to Jacobi Theta docs [CI SKIP]

* Define Jacobi Theta test tolerances [CI SKIP]

* Add implementation note on Jacobi theta functions [CI SKIP]

* Consolidate Jacobi Theta ULPs plotting programs [CI SKIP]

* Fix q domain checking of jacobi_theta4 [CI SKIP]

* Add ULPs plots to Jacobi Theta docs [CI SKIP]

Also add the built HTML files for easy evaluation. A full rebuild is
needed for the new docs to appear in the indexes.

* Add missing Jacobi Theta ULPs plots [CI SKIP]

* Add LaTeX source for Jacobi Theta equations [CI SKIP]

* Remove unused Jacobi Theta PNG equations [CI SKIP]

* Add Jacobi Theta performance script [CI SKIP]

Provided by @NAThompson.

* Remove vestigial eps*eps check from jacobi_theta3 [CI SKIP]

* Update Jacobi Theta docs per code review comments [CI SKIP]

* Enable arg promotion for Jacobi Theta functions [CI SKIP]

Add Jacobi theta functions to the instantiation tests and fix up
everything needed to make them pass. This changes the function
signatures to use promote_args.

* Fix Jacobi Theta plotting script [CI SKIP]

This script broke when the promote_args API was added.

* Change Jacobi Theta convergence criterion [CI SKIP]

Compare the non-oscillating part of the delta to the previous one.
This avoids some headaches comparing the delta to the partial sum,
because the partial sum can be a small number due to the oscillating
component alternating signs.

Because successive terms involve either q^n^2 or exp(-(pi*n)^2),
convergence should still happen pretty quickly. Graphs have been updated
and tests still passs with no noticeable difference.
2020-08-15 18:51:47 -04:00
jzmaddock
e9b93b1587 Instantiate.hpp: fix for using TEST_GROUP_5/6 alone. 2020-07-09 19:06:09 +01:00
NAThompson
17c9912aba Attempt to fix compilation error of Windows. Add compiler tests for Daubechies scaling. 2020-03-06 06:33:59 -05:00
jzmaddock
dc52a787c8 daubechies.hpp: simplify header and reduce dependencies. 2020-02-28 17:24:38 +00:00
jzmaddock
2d6cd609c9 Autodiff: minimise #includes and change type_traits usage to the std versions.
Update tests to match.
2020-01-25 18:41:40 +00:00
jzmaddock
1e0179c883 Remove dispatching via mpl and stick to boost::integral_constant.
Simplify the dispatching logic to use mpl::if_ and broken compiler workarounds less often.
Fixes: https://github.com/boostorg/type_traits/issues/133.
2020-01-13 15:14:48 +00:00
NAThompson
869949a657 Cut down on the warnings that I've introduced slowly over time 2019-10-25 08:49:36 -04:00
jzmaddock
1ef7307577 1F1: make PP logic consistent. 2019-08-01 21:48:04 +01:00
jzmaddock
233bcfe1d8 pFq: simplify Jamfile. Fix instantiate.hpp. 2019-08-01 19:21:32 +01:00
jzmaddock
d0bdc5300b Hypergeometrics: Update to fix test failures, and improve reporting of compiler requirements. 2019-07-28 17:49:37 +01:00
jzmaddock
1511ec4d35 Merge branch 'develop' into hypergeometric_soc_2014 2019-07-19 18:55:27 +01:00
jzmaddock
0275428d5a Catmull_rom: fix vc12 and vc14 errors highlighted by the new tests. 2019-07-06 20:29:11 +01:00
jzmaddock
ed38d8f556 catmull_rom.hpp: Added missing include.
Fix concept tests and add them to the Jamfile.v2
Fixes: https://github.com/boostorg/math/issues/226
2019-07-06 09:00:50 +01:00
jzmaddock
472e34efc4 Merge branch 'develop' into hypergeometric_soc_2014 2019-07-02 18:12:43 +01:00
jzmaddock
e415650f86 prime: Correct value of max_prime and add test.
Fixes https://github.com/boostorg/math/issues/214.
2019-05-26 11:45:35 +01:00
jzmaddock
332fb32919 Merge branch 'develop' into hypergeometric_soc_2014
[CI SKIP]
2019-02-21 13:03:04 +00:00
jzmaddock
c603bf78a7 Hypergeometrics: Fix up some testing and conceptual errors flagged up by first CI run. 2019-02-06 18:42:09 +00:00
jzmaddock
695486b1ce hypergeometrics: Correct all the conceptual errors, fix up concept tests and generally test many more types.
[CI SKIP]
2019-01-18 19:31:50 +00:00
Nick Thompson
bf7b29f13c Fix typo. 2018-12-29 18:41:38 -07:00
Nick Thompson
a27c4bc96c Also change concept and include test [CI SKIP] 2018-12-27 20:38:27 -07:00
Nick Thompson
381f663517 Merge and run CI 2018-10-28 23:27:41 -06:00
jzmaddock
424eeffdd3 LambertW: Add max_digits10 to numeric_limits specialization in std_real_concept_check.cpp. 2018-08-30 19:16:14 +01:00
jzmaddock
bed980e202 Merge branch 'develop' into lambertw 2018-08-30 10:17:19 +01:00
jzmaddock
3abd04ce50 LambertW: Hook up concept checks, and fix failures. 2018-08-30 08:57:35 +01:00
jzmaddock
177c642cbc Big GCC warning fix - see https://github.com/boostorg/math/issues/136 2018-07-28 11:33:41 +01:00
jzmaddock
ed79dd53f0 Try not to break std lib code when concept testing are own.
See: https://github.com/boostorg/math/issues/126.
2018-06-01 09:18:07 +01:00
jzmaddock
f73932460a Merge branch 'develop' into warning_removal_2
Restrict warning suppression to gcc > 4.8.
2018-05-04 19:27:47 +01:00
Nick Thompson
babead7504 Remove pile of warnings so that the build log is easier to search through. 2018-03-17 16:39:17 +08:00
Nick Thompson
cfd81335e9 [ci skip] Fix merge conflict from develop 2018-02-17 18:05:02 -06:00
Nick Thompson
d30f2d5927 [ci skip] Remove gcd tests from boost.math 2018-02-16 12:43:15 -06:00
jzmaddock
073e7a7196 Merge branch 'develop' into naive_monte_carlo 2018-02-16 17:59:00 +00:00
jzmaddock
9d5ac9143b naive_monte_carlo: suppress known test failures, and fix lots of warnings. 2018-02-15 20:11:23 +00:00
jzmaddock
c6b734a791 Merge pull request #110 from boostorg/pr64
Integration test PR64
2018-02-13 19:47:54 +00:00
jzmaddock
7403cbbd43 Make table driven functions constexpr:
unchecked_factorial, unchecked_bernoulli_b2n and prime.
2018-02-11 19:59:26 +00:00
jzmaddock
f4dfb9088f Merge branch 'numerical_differentiation_2' of https://github.com/NAThompson/math into pr64
Fixed Conflicts:
   include/boost/math/concepts/std_real_concept.hpp
   test/Jamfile.v2

Changes:
   Minor changes to get things compiling with msvc.
2018-02-11 16:33:41 +00:00
Nick Thompson
1781d47b78 [ci skip] Clarify conditions on the template point type. Add include and concept test. 2018-01-27 14:44:15 -06:00
Nick Thompson
e83284d482 Add more feature flags. Think I still need to link pthread. 2017-11-27 22:40:28 -06:00
Nick Thompson
67578ce12b Naive Monte-Carlo integration. Still needs to handle exceptions in threads. 2017-11-21 18:49:14 -07:00
jzmaddock
a1c18789a0 Math.chebyshev: Hook up conceptual tests and fix resulting errors. 2017-09-21 11:52:59 +01:00
jzmaddock
d9893f5e01 Quadrature: update conceptual tests for Gauss (Kronrod) quadrature. 2017-09-06 19:53:10 +01:00
jzmaddock
5e3fd1574e Merge branch 'double_exponential' of https://github.com/NAThompson/math into pr66 2017-06-17 18:10:25 +01:00
jzmaddock
9a8324c989 Merge pull request #71 from boostorg/pr65
PR based on #65 prepared for CI testing
2017-06-17 09:02:56 +01:00
jzmaddock
fdd959a32f Merge branch 'cleanup' of https://github.com/NAThompson/math into pr65.
Also made a couple of  minor modifications.
2017-06-16 19:35:13 +01:00
jzmaddock
34d413e830 trapezoidal: More fixes prior to merging:
Add new documentation section for integrators.
Remove isfinite from std_real_concept.hpp - it's not part of our conceptual requirements.
Add workarounds for older compilers that can't handle the default arguments to the function.
Restrict testing test_trapezoidal.cpp to compilers that handle lambdas.
Make the concept checks C++03.
Make test_trapezoidal.cpp compile with VC11's broken lambda support.
2017-06-16 18:13:42 +01:00
Nick Thompson
23403b61a1 Add concept test and include test. 2017-05-18 19:02:29 -06:00
Nick Thompson
a980bd8af3 Add concept and include test. 2017-05-18 18:23:01 -06:00
Nick
1753d6e9e4 Merge branch 'develop' into romberg 2017-05-18 17:34:52 -06:00
Nick Thompson
7660162d41 Add concept and include test. 2017-05-18 17:33:45 -06:00
jzmaddock
5db9e8870b Legendre_stieltjes: hook up tests.
Add concept checks.
Fix some warnings, and reduce dependencies.
2017-05-09 19:13:44 +01:00
jzmaddock
97a4184df9 Hook up concept checks for legendre_p_prime.
Fix errors from above, add domain-error handling to the function.
2017-05-08 19:47:02 +01:00