Well you can move this to whatever board you want. Anyway I'm taking a course called 'engineering mathematics.' It's kind of the equivalent of a linear algebra course. My professor is an eccentric old lady that is way too smart to teach math to humans.
Our assignment over the weekend was to write in excel a command to evaluate the series for 'e' and 'pi' and to see how many terms in the series it took to get a certain number of decimal places accuracy. She suggested trying a couple of hundred terms, so of course I wrote a program that evaluates PI using 50 million terms. Kind of neat. Here are the results, the series for 'e' converged pretty quickly, not true for PI.
E after 20 terms in the series: 2.718281828459045500000000000000
PI after 1000 terms in series: 3.142593654340044100000000000000
PI after 50000000 terms in series: 3.141592673590250900000000000000
Here's the program for it
Code:#include <iostream> #include <fstream> #include <math.h> using namespace std; double factorial(double input) { if(input > 0) return input * factorial(input-1); else return 1; } double e_term(double which_term) { return 1.0 / (factorial(which_term)); } double pi_term(double which_term) { int i_term; _asm { fld which_term; fistp i_term; } double sgn = pow(-1.0,i_term+1); double denom = 1.0 / ((2.0 * which_term)-1); return 4 * sgn * denom; } int main(void) { std::ofstream fout; fout.open("results.txt"); fout.precision(50); cout.precision(50); double summation = 0.0; for(double which_term = 0; which_term < 20; ++which_term) { summation += e_term(which_term); fout << summation << "\n"; } fout << "\n\n\n\n\n\n\n"; summation = 0; for(which_term = 1; which_term < 1000; ++which_term) { summation += pi_term(which_term); } cout << "PI after 1000 terms in series: " << summation << "\n"; fout << "\nPI after 1000 terms in series: " << summation << "\n\n"; summation = 0; for(which_term = 1; which_term < 50000000; ++which_term) { summation += pi_term(which_term); } cout << "PI after 50000000 terms in series: " << summation << "\n"; fout << "\nPI after 50000000 terms in series: " << summation << "\n\n"; return 0; }