240
edits
Changes
→Pi
std::cout << "Pi: " << std::fixed << pi << std::endl;
}
4 digits are correct at 10K iterations:
> time ./leibniz 10000
Arctangent(1) - took - 0 millisecs
Pi: '''3.1415'''4265358982449354505184224706226814305409789085388183593750
real 0m0.016s
user 0m0.004s
sys 0m0.008s
7 digits are correct at 10M iterations:
> time ./leibniz 10000000
Arctangent(1) - took - 171 millisecs
Pi: '''3.1415926'''0358979321929411010483335076060029678046703338623046875
real 0m0.187s
user 0m0.172s
sys 0m0.012s
No difference at 100M iterations:
> time ./leibniz 100000000
Arctangent(1) - took - 1708 millisecs
Pi: '''3.1415926'''4858979533105269588144636827564681880176067352294921875
real 0m1.725s
user 0m1.704s
sys 0m0.008s
Monte-Carlo algorithm implementation: