clear;
clc;

f = @(x) (2*x^3 - 2*x - 5);

x0 = input("Enter lower boundary: ");
x1 = input("Enter upper boundary: ");
accuracy = 0.001;

while (f(x0) * f(x1) > 0)
    x0 = input("Enter lower boundary: ");
    x1 = input("Enter upper boundary: ");
end

itr = 0;
while true
    itr = itr + 1;

    x = x0 - ((f(x0) * (x1 - x0)) / (f(x1) - f(x0)));
    y = f(x);

    if abs(y) <= accuracy
        break;
    end

    x0 = x1;
    x1 = x;
end

disp("Value of x: " + x);
disp("Iteration: " + itr);