// taylors.cc #include #include double S(const double x, const int N) { double s=1; double f=1; double inverse=0; if (x<0) inverse=1; for (int i=1;i<=N;i++) { f *= fabs(x/i); s += f; }; if (inverse) s = 1/s; return s; }; int main(int argc, char* argv[]) { const double e=exp(1); int N=30; double x; double s; double p; //do { cout << "# This program will give you a Taylor expansion of e^x for a given number x." << endl; cout << "# Please enter that number and I will calculate S(x,N) = " << endl; cout << "# 1 + x + x^2/2! + x^3/3! + ... + x^N/n!" << endl; cout << "# for N up to " << N << endl; cin >> x; //cout << "Please enter N (the number of iterations you wish to perform) "; //cin >> N; //cout << e << "^" << x << "= " << (p = pow(e,x)) <