#include #include #include using namespace std; int main() { for(double h = 1.; h > 1.e-12; h /= 10.) { double x = 3.14159265358979323846264338327950288419716939937510/4.; double d1 = sin(x+h) - sin(x); //forward double d2 = sin(x+h*0.5) - sin(x-h*0.5); // midpoint d2 /= h; d1 /= h; cout << "Your result is " << h << " " << setprecision(10) << d1 << " " << d2 << endl; } }