Bisection Method // Matlab code (Simple)

Posted: February 8, 2012 by muhammadakif in Uncategorized
Tags: , , , ,
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
Comments
  1. giggity says:

    thanku very much sir

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s