Archive for February, 2012

x1 = 1
x2 = 2

fx1 = (x1^3) + (x1^2) - (3*x1) - 3;
fx2 = (x2^3) + (x2^2) - (3*x2) - 3;

while(abs(x1 -x2)> 0.00001)
    x3 = (x1 +x2)/2;
    fx3 = (x3^3) + (x3^2) - (3*x3) - 3;

    if (fx1 * fx3 < 0)
        x2 = x3;
        fx2 = fx3;
    else
        x1 = x3;
        fx1 = fx3;
    end

end

x3
Advertisements