SageMath, Cython and Julia: BBP algorithm
Kernel: SageMath 7.2.rc2
SageMath version of BBP
Experiments with BBP algorithm in Sage.
First version
In [16]:
The -th hexadecimal digit of .
In [17]:
Out[17]:
8
Let us measure the elapsed time.
In [18]:
Out[18]:
1 loop, best of 3: 2.3 s per loop
Is it possible to make this run faster?
Second version (changes)
In [21]:
Speed test.
In [22]:
Out[22]:
1 loop, best of 3: 2.26 s per loop
Cython version
Load and compile the Cython code (inspect the file).
In [28]:
Does it work?
In [29]:
Out[29]:
2
How fast is it?
In [30]:
Out[30]:
10 loops, best of 3: 23.9 ms per loop
Compare this with the previous result! This is faster by factor 10.
Does it really compute what we think it computes?
In [32]:
Out[32]:
0.141592653589214