0% found this document useful (0 votes)
19 views

Bisection Method: Enter First Initial Approx Enter The Second Approx

The document describes the bisection method for finding the root of a function. It prompts the user to input initial values for x0 and x1, the maximum number of iterations, and defines the function f(x)=x^2-2. It then iteratively calculates the midpoint of x0 and x1, and updates the x0 or x1 value based on whether f(x0) or f(mid) is negative to converge on the root. The example provided runs for 11 iterations to refine the root.

Uploaded by

ammmmiiit
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
19 views

Bisection Method: Enter First Initial Approx Enter The Second Approx

The document describes the bisection method for finding the root of a function. It prompts the user to input initial values for x0 and x1, the maximum number of iterations, and defines the function f(x)=x^2-2. It then iteratively calculates the midpoint of x0 and x1, and updates the x0 or x1 value based on whether f(x0) or f(mid) is negative to converge on the root. The example provided runs for 11 iterations to refine the root.

Uploaded by

ammmmiiit
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

B isection.

wxm

1 / 1

bisection method

(%i1) block([x0,x1,Nmax,i:0],f(x):=x^2-2,loop1,
x0:read("enter first initial approx"),
x1:read("enter the second approx"),
if(f(x0)*f(x1)<0)then print("initial app are ok")else go(loop1),
Nmax:read("enter the max number of iteration"),loop2,i:i+1,
mid:((x0+x1)/2),if(f(x0)*f(mid)<0)then x1:mid else x0:mid,
print("x0= ",x0,"x1= ",x1,"app root after ",i,"iterations= ",((x0+x1)/2)
if(i<=Nmax)then go(loop2)else return(alldone));
enter first initial approx 1.0;
enter the second approx 2.0;
initial app are ok
enter the max number of iteration 10;
x0= 1.0 x1= 1.5 app root after 1 iterations= 1.25
x0= 1.25 x1= 1.5 app root after 2 iterations= 1.375
x0= 1.375 x1= 1.5 app root after 3 iterations= 1.4375
x0= 1.375 x1= 1.4375 app root after 4 iterations= 1.40625
x0= 1.40625 x1= 1.4375 app root after 5 iterations= 1.421875
x0= 1.40625 x1= 1.421875 app root after 6 iterations= 1.4140625
x0= 1.4140625 x1= 1.421875 app root after 7 iterations= 1.41796875
x0= 1.4140625 x1= 1.41796875 app root after 8 iterations= 1.416015625
x0= 1.4140625 x1= 1.416015625 app root after 9 iterations= 1.4150390625
x0= 1.4140625 x1= 1.4150390625 app root after 10 iterations=
1.41455078125
x0= 1.4140625 x1= 1.41455078125 app root after 11 iterations=
1.414306640625
(%o1) alldone

You might also like