Post Reply 
(PC-12xx~14xx) qthsh Tanh-Sinh quadrature
04-15-2021, 07:02 PM
Post: #56
RE: (PC-12xx~14xx) qthsh Tanh-Sinh quadrature
(04-15-2021 05:14 PM)Albert Chan Wrote:  Nice, but we can do better ! (see previous post)

exp(0) = 1
exp(-0.01y) = 0.001       → -y/100 = ln(10^-3) = -3*ln(10) ≈ -3*2.3 ≈ -7

\(\int_0^∞ = \int_0^{700} + \int_{700}^∞ :\)

lua> Q.quad(Q.count(f2), 0, huge, 700), Q.n
100        71

Picking a smart "central point" 'd' in Exp-Sinh (the splitting point between the two quadratures) is advantageous.

A higher accuracy can also be accomplished by manually splitting up the integral into two parts by picking the splitting point smartly:

\(\int_0^∞ = \int_0^{700} + \int_{700}^{701} + \int_{701}^∞ \)

In this case we can also get a more accurate result, while keeping the default Exp-Sinh "central point" 700+1 (the default is d=1 versus d=700 in your example):

\( \int_0^{700} e^{-0.01y}\,dy \):
k=3 err=4.82092e-11 pts=58
quad = 99.9088118034444

\( \int_{700}^\infty e^{-0.01y}\,dy \):
k=5 err=8.41427e-09 pts=235
quad = 0.0911881965443389

Combined \( \int_0^\infty e^{-0.01y}\,dy \) = 99.9088118034444 + 0.0911881965443389 = 99.999999999988739

Thus we get three more digits (12 digits) compared to Exp-Sinh with the default d=1 splitting point:
\( \int_0^\infty e^{-0.01y}\,dy \):
k=5 err=8.41426e-09 pts=237
quad = 99.9999999878134


On the other hand, the splitting point d=700 gives the exact result as you point out, which is very nice indeed:

k=3 err=9.08301e-12 pts=71
quad = 100


The absolute error estimates (100*9e-12 ~ 9e-10) is in the same order (100*5e-11+0.09*8e-9 ~ 5e-9). So using this as a "black box" we won't be able to tell the difference, unless we can get the relative error further down, which seems really cheap to do as we only needed 71 points to get about 11 digits.

It makes sense to specify 'd' as an optional parameter or at least say something about it in the document.

Overall, these methods are interesting. But as always one needs to be smart about the type of integrand and consider splitting up integrals into parts. The 1084 integral tests to check these methods do none of that, obviously.

- Rob

"I count on old friends to remain rational"
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-15-2021 07:02 PM



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