Post Reply 
(PC-12xx~14xx) qthsh Tanh-Sinh quadrature
04-02-2021, 05:04 PM
Post: #13
RE: (PC-12xx~14xx) qthsh Tanh-Sinh quadrature
(04-02-2021 04:20 PM)emece67 Wrote:  Then I used a battery of 140 integrals (now 161, after adding your 21 functions) for tests. Maybe this set is useful to you.

Thanks for contributing. That would be nice to look at. Eventually I may run the 1200 integrals in the VB spreadsheet. However, it is not about the number of functions per se (though the more the better), the variety matters too, i.e. include non-holomorphic functions, periodic, step functions, etc. Testing these can help to determine if the error estimate is usable, not only accurate. Tanh-Sinh is also not "symmetric", meaning that integrating 1/sqrt(-log(x)) over [0,1] should be the same as integrating 1/sqrt(-log(1-x)). Except for mpmath, that is not the case with the VB article code and Boost Math due to the singularities occurring earlier that apparent to be fatal.

I've used the default mpmath Tanh-Sinh parameters with mp.dps=15 in order to compare to C/C++ double fp. Levels is 6 (default) and eps is 1e-9.

Some observations:

- mpmath Tanh-Sinh appears to run up to 427 evaluations, never more with these settings and often too many than necessary. Something might be amiss with the convergence test?

- mpmath Tanh-Sinh sometimes produces error estimates that are a mystery when compared to the other Tanh-Sinh implementations. I could be mistaken, but the error estimate is performed in the same way as Gausss-Legendre in the code. Both methods produce node sets which are used for the quadrature and error estimation.

- Boost Math Tanh-Sinh explodes the number of points close to the zero endpoint (that's also one reason to include the zero endpoint in the tests to compare behaviors, not only the integral and error estimates.) For example, f(x)=4/(1+x*x) produces 147 points with a large number close to the 0 and 1 endpoints. See my draft article's graph on this function with Boost Math, and a lot that are very close to the 0 endpoint:

1.69367010239342e-108
7.55408323550392e-123
4.13900004783521e-139
1.55080149097904e-157
2.04586734643622e-178
4.47908407247427e-202
6.93948438714987e-229
2.89628710646752e-259

Of course, we expect points to be distributed towards the endpoints with Tanh-Sinh, but this is far more than necessary. The weights there are minuscule and negligible.

PS. Just to clarify: I am not really biased toward any integration method. They all have strengths and weaknesses that can favor one over the other depending on what the goal is (e.g. CPU time versus accuracy). The best integration results are obtained by applying a transformation when necessary, change variable when helpful, consider integration domain splitting, and then select the method to apply that works best for the integrand. A usable error estimate is just as important (if not more) than the integration result, unless we seek a rough estimate (e.g. 1e-3) that is good enough.

- Rob

"I count on old friends" -- HP 71B,Prime|Ti VOY200,Nspire CXII CAS|Casio fx-CG50...|Sharp PC-G850,E500,2500,1500,14xx,13xx,12xx...
Visit this user's website Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
RE: (PC-12xx~14xx) qthsh Tanh-Sinh quadrature - robve - 04-02-2021 05:04 PM



User(s) browsing this thread: 3 Guest(s)