public static void main(String[] args) {
        double integral=0;
        double integralprev = 0;
        double sum = 0;

        do {
            integral = function(a) + function(b);
            xi = a;
            sum = 0;
            for (int i = 1; i < n; i++) {
                xi += h;
                if (i % 2 != 0) {
                    sum += 4 * function(xi);
                } else if (i % 2 == 0) {
                    sum += 2 * function(xi);
                }
            }
            integral += sum;
            integral*=h/3;
            ///////

            integralprev = function(a) + function(b);
            xi = a;
            sum = 0;
            for (int i = 1; i < n; i++) {
                xi += h;
                if (i % 2 != 0) {
                    sum += 4 * function(xi);
                } else if (i % 2 == 0) {
                    sum += 2 * function(xi);
                }
            }
            integralprev += sum;
            integralprev*=h/3;

            h/=2;
        }
        while(Math.abs(integral - integralprev) >= eps * 15);

        System.out.println("Integral by Simpson= " + integral);
//      System.out.println("1.89818");
    }