public Point getExtremum(Function function, Interval interval, double e) {
        Point a = interval.getX1();
        Point b = interval.getX2();
        ExtremumType extremumType = interval.getExtremumType();
        Point x = getX(a, b);
        int iteration = 0;
        do {
            iteration++;
            ComparePointResult bigVector = comparePoint(function, a, b, x);
            Point s = getPointOnVetor(bigVector.getMaxA(), bigVector.getMaxB(),RANDOM.nextDouble());
            double fs = function.getValue(s);
            double fx = function.getValue(x);
            if (
                    (fx >= fs && extremumType.equals(ExtremumType.MAX)) ||
                            (fx <= fs && extremumType.equals(ExtremumType.MIN))
                    ) {
                if (bigVector.isAxMax()) {
                    a = s;
                } else {
                    b = s;
                }
            } else {
                if (bigVector.isAxMax()) {
                    b = x;
                } else {
                    a = x;
                }
                x=s;
            }

        } while ((b.minus(a).module()) > e);
//        printLog(iteration, "", a, b, null, null);
        return a.plus(b).multiply(1.0 / 2.0);
    }