// Richardson Extrapolation Aprroximation (REA) for the derivative of a function f(x)
// For f(x) = x^4 the analytical solution is 4x^3 e.g. f'(3.5)=171.5
#include <iostream>
#include <iomanip>
using namespace std;

double f(double x) { return x*x*x*x; } // The function f(x)

int main() {

  double  x=3.5, h=0.001;
  double REA = (f(x-2*h)-8*f(x-h)+8*f(x+h)-f(x+2*h))/(12*h);

  cout << setprecision(8) << fixed;
  cout << "REA = " << REA << endl;

}
