Skip to content
This repository has been archived by the owner on Feb 2, 2022. It is now read-only.

Quexint/compute-pi

 
 

Repository files navigation

採用離散積分的方法求圓周率,並著手透過 SIMD 指令作效能最佳化

Authored by Lee Chao Yuan <[email protected]>

相關連結

Baseline 版本

double computePi_v1(size_t N)
{
    double pi = 0.0;
    double dt = 1.0 / N;                // dt = (b-a)/N, b = 1, a = 0
    for (size_t i = 0; i < N; i++) {
        double x = (double) i / N;      // x = ti = a+(b-a)*i/N = i/N
        pi += dt / (1.0 + x * x);       // integrate 1/(1+x^2), i = 0....N
    }
    return pi * 4.0;
}

Benchmarking

About

Leibniz formula for π

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C 79.6%
  • Makefile 15.2%
  • Gnuplot 5.2%