Melkar Muallem
Melkar Muallem

Reputation: 433

computing pi to the millionth digit.

Computing PI to millions of digits is a way to check the stability and performance of a CPU, especially after over clocking. I am trying to write this code myself, basically all it does it computer PI to the millionth digit and return the time taken to do so. I have researched a lot about it, found different equations, but didn't know which is the most efficient to be used for computing. could you please provide me with you ideas on the best one, and if possible the code or steps of how to do it. Thank you.

Upvotes: 0

Views: 204

Answers (3)

JimmyB
JimmyB

Reputation: 12610

Be aware that any CPU contains different sub-units working only more or less losely interconnected.

You will want to burn-in test as many of the sub-units as you can at the same time.

Specifically, your code may need to include:

  • Integer calculations of appropriate word size (32/64bit)
  • Floating point calculations
  • SIMD operations
  • Heavy cache usage
  • Heavy memory bus usage

Plus: Current CPUs have more than one core so you need to keep all those cores busy. Multi-threading or multiple processes are needed.

Only when putting load on all units of the CPU ("worst case scenario") you will get reliable results as to its stability.

Upvotes: 1

rwst
rwst

Reputation: 2675

In Macsyma:

py(x) := if equal(6, 6+x^2) then 2*x else (py(x:x/3), 3*%%-4*(%%-x)^3); py(3.);py(dfloat(%)); block([bfprecision:35], py(bfloat(%))) 

where x is the index of your digit. (This is from the OEIS http://oeis.org/A000796 )

Upvotes: 0

Joey
Joey

Reputation: 354496

If you're just out to test your CPU, then you don't need an efficient way. Just implement one algorithm and be done with it.

Upvotes: 2

Related Questions