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:

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.

Glorfindel
  • 21,988
  • 13
  • 81
  • 109
user2464424
  • 1,536
  • 1
  • 14
  • 28
  • 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 `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". –  May 02 '22 at 13:55

0 Answers0