0

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:

http://projecteuclid.org/DPubS?service=UI&version=1.0&verb=Display&handle=euclid.em/1046889587
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.

user2464424
  • 1,466
  • 1
  • 12
  • 26
  • Try CPython (convert Python code into C code = much faster) – Cactus Libidineux Aug 14 '13 at 15:39
  • [CPython](http://fr.wikipedia.org/wiki/CPython) does **not** compile to C code. –  May 14 '15 at 13:50
  • You probably mean *[Cython](http://cython.org/)*, and not CPython. – helmbert May 14 '15 at 15:59
  • CPython is the alternative name for the original Python implementation; see [Python vs Cpython](https://stackoverflow.com/a/17130986). You almost certainly meant *Cython* instead. – Martijn Pieters May 14 '15 at 17:35
  • 1
    The link to `projecteuclid.org` is broken. It should point to Henri Cohen. Fernando Rodriguez Villegas. Don Zagier. "[Convergence acceleration of alternating series.](https://projecteuclid.org/journals/experimental-mathematics/volume-9/issue-1/Convergence-acceleration-of-alternating-series/em/1046889587.full)" Experiment. Math. 9(1), 3–12, 2000. – The Amplitwist May 02 '22 at 13:54
  • 1
    The link to `cestmal.in` is also broken, but I'm unable to find a copy of (presumably) the book titled "Algorithms for Programmers — Ideas and Source Code". – The Amplitwist May 02 '22 at 13:55

0 Answers0