Given an acceleration structure like binary splitting, how well do acceleration transformations like Euler-Wijngaarden or sumalt perform when used side-by-side with it?
https://en.wikipedia.org/wiki/Van_Wijngaarden_transformation
The sumalt estimation is said to be much faster that Euler's method:
- https://projecteuclid.org/journals/experimental-mathematics/volume-9/issue-1/Convergence-acceleration-of-alternating-series/em/1046889587.full
- http://cestmal.in/Books/people.zoy.org/~sam/private/jnat/Programming/Algorithms%20For%20Programmers-%20Ideas%20And%20Source%20Code.pdf (section 19.2)
In particular, we want to calculate the cosine of an angle as fast as possible.
I have this binary splitting structure for the cosine that works well with GMPY and mpmath libraries:
def fcosine_bs(terms,u,v):
u=-mpz(u)**2
v=mpz(v)**2
def bs(a, b):
if b - a == 1:
if a == 0:
Pab = Qab = mpz(1)
else:
Pab = u
Qab = (4*a-2)*a*v
Tab = Pab
else:
m = (a + b) // 2
Pam, Qam, Tam = bs(a, m)
Pmb, Qmb, Tmb = bs(m, b)
Pab = Pam * Pmb
Qab = Qam * Qmb
Tab = Qmb * Tam + Pam * Tmb
return Pab, Qab, Tab
P, Q, T = bs(0, terms)
return mpf(T)/Q
I just want to know what would be the boost in performance if used together with Euler's/Van Wijngaarden's/sumalt transformations, if there actually is a gain.
I'm afraid to write unoptimal code, so I'm also asking for an effective python implementation of some of the methods optionally.