// Central Difference Approximation (CDA) 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 CDA = (f(x+h)-f(x-h))/(2*h);

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

}
