I'd just use a constant.I don't care - would just do 4 * arctan(1.0) anyway.
Soma
This is a discussion on Approximating PI using the Taylor Series - Help! within the C++ Programming forums, part of the General Programming Boards category; I don't care - would just do 4 * arctan(1.0) anyway. I'd just use a constant. Soma...
I'd just use a constant.I don't care - would just do 4 * arctan(1.0) anyway.
Soma
"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the universe trying to produce bigger and better idiots. So far, the Universe is winning." Rick Cook
I might do the loop more like this:
but to each his own.Code:double numerator = -1.0 double taylor = 1.0; for (int i = 3; i < terms; i+=2, numerator *= -1) { taylor += numerator/i; }