Wednesday, 14 August 2013

Fastest possible method for the arcsin function on small, arbitrary floating-point values

Fastest possible method for the arcsin function on small, arbitrary
floating-point values

I need to calculate the arcsine function of small values that are under
the form of mpmath's "mpf" floating-point bignums.
What I call a "small" value is for example e/4/(10**7) =
0.000000067957045711476130884...
Here is a result of a test on my machine with mpmath's built-in asin
function:
import gmpy2
from mpmath import *
from time import time
mp.dps = 10**6
val=e/4/(10**7)
print "ready"
start=time()
temp=asin(val)
print "mpmath asin: "+str(time()-start)+" seconds"
>>> 155.108999968 seconds
This is a particular case: I work with somewhat small numbers, so I'm
asking myself if there is a way to calculate it in python that actually
beats mpmath for this particular case (= for small values).
Taylor series are actually a good choice here because they converge very
fast for small arguments. But I still need to accelerate the calculations
further somehow.
Actually there are some problems:
1) Binary splitting is ineffective here because it shines only when you
can write the argument as a small fraction. A full-precision float is
given here.
2) arcsin is a non-alternating series, thus Van Wijngaarden or sumalt
transformations are ineffective too (unless there is a way I'm not aware
of to generalize them to non-alternating series).
https://en.wikipedia.org/wiki/Van_Wijngaarden_transformation

The only acceleration left I can think of is Chebyshev polynomials. Can
Chebyshev polynomials be applied on the arcsin function? How to?

No comments:

Post a Comment