见维基百科
https://en.m.wikipedia.org/wiki/Tanh-sinh_quadrature
见Tanh-sinh quadrature numerical integration method converging to wrong value
https://www.e-learn.cn/topic/2848897
见Stackoverflow
https://stackoverflow.com/questions/24986588/tanh-sinh-quadrature-numerical-integration-method-converging-to-wrong-value
参考文献
参考文献
测试如下(采用Python高精度浮点算法包 mpmath)
# -*- coding: utf-8 -*-
"""
Created on Fri Oct 22 20:14:43 2021
I=Int_{a}^{b} f(z)dz
其中
a
"""
from mpmath import mp,mpf,cosh,sinh,pi,tanh,sqrt
if(1):
mp.dps = 100
h = mpf(2**-12);#
def weights(k):
num = mpf(0.5)*h*pi*cosh(k*h)
den = cosh(mpf(0.5)*pi*sinh(k*h))**2
return (num/den)
def abscissas(k,a,b):
f=((b-a)/2)*(tanh(mpf(0.5)*pi*sinh(k*h)))+(b+a)/2
return f
def f(x):
return 1/sqrt(1 - mpf(x)**2)
N = 20000
#通过作线性变换,求任意区间的数值积分
a=0
b=1
result = 0
for k in range(-N, N+1):
result = result + weights(k)*f(abscissas(k,a,b))*(b-a)/2
print(result)
print(result - pi)
'''```
#可以发现对N的要求很高,且很慢
#N=20000
3.141592653589793238462643383279502884197169395623305210054471789091557055855748154170301951289498386
-3.751800610920472803216259350430460844457732874052618682441090144344372471319795201134275503228835472e-45
#N=2000
1.449489205637340355829215405535223522203982454439832629403540056142008755610237611478998353099179717
-1.692103447952452882633427977744279361993186944935273191571404536165807650675971387149036472242937351
#N=200
0.1536915064631849189177884604412165536645462018136925450754802115004847789524209471365251505235660057
-2.987901147126608319544854922838286330532623197561413275899464380807331627333788051491509674818551062
'''



