Page MenuHomec4science

compute_pi.hh
No OneTemporary

File Metadata

Created
Sat, Nov 9, 02:01

compute_pi.hh

#ifndef COMPUTEPI_HPP
#define COMPUTEPI_HPP
#include "series.hh"
class ComputePi : public Series {
public:
//PREVIOUS IMPLEMENTATION:
//double compute(unsigned int N) {
// double result = 0.0;
// for (int a = 1; a<=N; ++a) {
// result=result+1.0/(a*a);
// }
// result = sqrt(6.0*result);
// return result;
//}
double compute(unsigned int N) {
double current_value = Series::compute(N);
return sqrt(6.0*current_value);
}
double computeValue(int k) {
return 1./(1.*k*k);
}
double getAnalyticPrediction(){
return M_PI;
}
};
#endif

Event Timeline