Ledger Nano X - The secure hardware wallet
SHARE
TWEET

integral equation: automatic integration step

shadeyourself May 23rd, 2020 (edited) 1,056 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. double getIntegral(double (*f)(double), double a, double b, long n, double eps, double step) {
  2.     double x, y, z;
  3.     double integral = 0;
  4.     do{
  5.         x = integrate(f, a, a+step, n);
  6.         y = integrate(f, a, (a+step)/2, n);
  7.         z = integrate(f, (a+step)/2, a+step, n);
  8.         if(fabs(x-(y+z)) < eps){
  9.             a+=step;
  10.             integral+=x;
  11.         }
  12.         n*=2;
  13.     }while(a+step < b);
  14.     return integral;
  15. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top