Post Reply 
[wp34s] New integration program
04-04-2021, 05:09 PM (This post was last modified: 04-04-2021 05:16 PM by emece67.)
Post: #12
RE: [wp34s] New integration program
(04-04-2021 03:33 PM)Albert Chan Wrote:  To use tanh-sinh, just convert back intervals: [-∞,+∞] -> [0,1]

>>> def f01(t): y=t*t-t; return f((2*t-1)/y) * (2*y+1)/(y*y)
...
>>> quadde(f01, [0,1]) # method tanh-sinh
(mpf('0.81659478390520546'), mpf('1.0424940875997102e-5'), 77, 5, 0)

It seems exp-sinh does better than tanh-sinh, for interval [-∞,+∞]

I suppose it depends on the particular change of variable you use to get from [-∞, +∞] to [0, 1]. Maybe you can find cases when the tanh-sinh method behaves better in [0, 1] than transforming the problem to the exp-sinh case.

(04-04-2021 03:33 PM)Albert Chan Wrote:  >>> quadde(f, [-40,40])
(0, mpf('0.83732598514658618'), 87, 5, 0)

A bit unexpected, getting area of 0.0, with huge error estimate.

This implementation of the double-exponential algorithm is aimed at a handheld calculator, so it uses simple heuristics in some places. Here you are fooling one of such heuristics (related to the fact that the function vanishes rapidly away from 0). The first iterations of the algorithm "doesn't see" the interesting part of the function, and when later iterations find something, the algorithm thinks it is round-off noise. In some way this function is "bell-shaped", and this algorithm concentrates the sampling points at the extremes of the integration interval, so caution is advised for cases such this one. Integrating exp(-x^2) in [-10, 10] or [-inf, +inf] gives good results, but in [-20, 20] triggers the heuristic.

You have found a way to circumvent this, though.

Regards.
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
[wp34s] New integration program - emece67 - 03-08-2017, 05:46 PM
RE: [wp34s] New integration program - nova - 08-11-2019, 05:33 AM
RE: [wp34s] New integration program - emece67 - 04-04-2021 05:09 PM



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