0% found this document useful (0 votes)
35 views2 pages

F @X - D: X - 5 X + 1 Plot @F@XD, 8X, - 3, 4, Plotstyle ® 8thick, Axeslabel ® 8X, Y D

This document demonstrates the bisection method to find the root of a function. It defines a cubic function f(x), plots it, then iteratively applies the bisection method by checking the sign of f(a) and f(c) and updating the interval endpoints a and b until the root is converged upon.

Uploaded by

Rinki
Copyright
© © All Rights Reserved
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)
35 views2 pages

F @X - D: X - 5 X + 1 Plot @F@XD, 8X, - 3, 4, Plotstyle ® 8thick, Axeslabel ® 8X, Y D

This document demonstrates the bisection method to find the root of a function. It defines a cubic function f(x), plots it, then iteratively applies the bisection method by checking the sign of f(a) and f(c) and updating the interval endpoints a and b until the root is converged upon.

Uploaded by

Rinki
Copyright
© © All Rights Reserved
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/ 2

Q.1 Bisection Method.

Sol.

In[8]:= f@x_D := x3 - 5 * x + 1
Plot@f@xD, 8x, -3, 4<,
PlotStyle ® 8Thick<, AxesLabel ® 8x, y<D

15

10

Out[9]= 5

x
-3 -2 -1 1 2 3 4

-5

-10
2 Bisection Methods.nb

In[10]:= a = N@0D;
b = N@1D;
c = Ha + bL • 2;
i = 1;
output = 88a, b, c, f@aD, f@bD, f@cD, Sign@f@aD * f@cDD<<;
While@i £ 6, If@Sign@f@aD * f@cDD < 0, b = c, a = cD;
c = Ha + bL • 2;
i = i + 1;
output = Append@output,
8a, b, c, f@aD, f@bD, f@cD, Sign@f@aD * f@cDD<DD;
Print@NumberForm@TableForm@output,
TableHeadings ® 8Automatic, 8"a", "b", "c", "f@aD",
"f@bD", "f@cD", "Sign@f@aD*f@cDD"<<D, 8DD;

a b c f@aD f@bD
1 0. 1. 0.5 1. -3.
2 0. 0.5 0.25 1. -1.375
3 0. 0.25 0.125 1. -0.234375
4 0.125 0.25 0.1875 0.37695313 -0.234375
5 0.1875 0.25 0.21875 0.069091797 -0.234375
6 0.1875 0.21875 0.203125 0.069091797 -0.083282471
7 0.1875 0.203125 0.1953125 0.069091797 -0.0072441101

You might also like