Post Reply 
(PC-12xx~14xx) qthsh Tanh-Sinh quadrature
04-06-2021, 11:36 PM
Post: #30
RE: (PC-12xx~14xx) qthsh Tanh-Sinh quadrature
(04-06-2021 04:19 PM)Albert Chan Wrote:  Default 0.0 + ArithmeticError + Inf/NaN test, we get this:

(mpf('0.69314718055994518'), mpf('2.7138055025410779e-8'), 47, 3, 0)       # uf
(mpf('0.69314718055994484'), mpf('4.525002594846228e-11'), 71, 4, 0)       # uuf

Previous Point + ArithmeticError + Inf/NaN test, we get this:

(mpf('0.69314718055995395'), mpf('2.713805868914676e-8'), 49, 3, 0)         # uf
(mpf('0.69314725666345778'), mpf('7.6148712890855563e-8'), 83, 4, 0)       # uuf

It may not be necessarily the case that choosing zero as default is better than reusing the previous point, or vice versa. However, I suspect that if a function in the limit approaches a nonzero finite value, then reusing previous points as an approximation of that value could be more accurate, if these weighted values contributes to the sum.

Among the 818 integrations with qthsh, I found that almost all of them produced the same integral regardless of the choice of zero or reuse by default. There are only 8 integrals that differ (I've added the limits):

When fp=0 and fm=0 is better as default for f on [a,b]:
Code:
LN(COS(x))        [0,1.570796327]    lim x->pi/2+ f(x)=-inf
LN(COS(x))^2        [0,1.570796327]    lim x->pi/2+ f(x)=+inf
(x-SIN(x))/(1-COS(x))    [0,3.141592654]    lim x->0- f(x)=0
LN(2*TAN(x))        [0,1.570796327]    lim x->0- f(x)=-inf   lim x->pi/2+ f(x)=undefined
SQRT(TAN(x))        [0,1.570796327    lim x->pi/2+ f(x)=undefined

When reusing previous points is better as default for f on [a,b]:
Code:
1/(1+COS(x)^x)        [-1.570796327,1.570796327]    lim x->pi/2+ f(x)=1       lim x->-pi/2- f(x)=0
x^2/(1-COS(x))        [0,1.570796327]        lim x->0- f(x)=0
x*SIN(x)/(1-COS(x))    [0,3.141592654]        lim x->0- f(x)=0

To determine these 8 integrals and categorize them I've used the absolute error of the method compared to the exact result, i.e. NOT the estimated error by the method.

When reusing previous points by default is better, then the absolute error with the exact value is substantially better by several orders in magnitude:

Code:
1/(1+COS(x)^x) 4.44E-16 versus 6.89E-11
x^2/(1-COS(x)) 6.27E-10 versus 1.76E-08
x*SIN(x)/(1-COS(x)) 5.24E-11 versus 3.41E-08

For the other default case of zero being better, the absolute error difference is small, mostly by a factor of about 2, so this looks more like noise.

Not a formal proof, but the empirical support appears somewhat convincing.

- 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-06-2021 11:36 PM



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