by hinkley · 11y ago · 0 comments
mac >> clang++ -O3 -march=native main.cpp
mac >> ./a.out
3.1415926545880506
total time taken is: 4.3861569999999999s
Twice as slow as the fastmath version but still faster than the go version. 100,50,25,12,4,2,3,3.5
> 3.5
Or even: 100,90,80,70,60,50,40
> 40
I'm assuming you mean wrong as in the algorithm implemented with arbitrary precision would en up with a different set of digits for the number of iterations given? Or something along those lines?It's probably more a problem of the algorithm not calculating significant figures and truncating the answer.
This particular series, which comes from a series for the arctan of 1, has very slow convergence. An easily better one is Machin's formula, which converges faster than a geometric series (that is, the number of terms needed is at most linear in the number of wanted digits).
So is it possible that the algorithm doesn't converge to correct digits for so "few" iterations?