public static double newtonRaphson(double x0, double epsilon, int cantIter, Funcion fun) throws Exception {
        double x1;
        int iter = 0;
        x1 = x0 - (fun.f(x0) / fun.fd(x0));

        while ((iter < cantIter) && (Math.abs(x1 - x0) >= epsilon)) {
            x0 = x1;
            x1 = x0 - (fun.f(x0) / fun.fd(x0));
            iter++;
        }

        if (iter == cantIter && (Math.abs(x1 - x0) >= epsilon) ) {
            throw new Exception("Maximas iteraciones alcanzadas");
        } else {
            return x1;
        }
    }