0% found this document useful (0 votes)
466 views8 pages

Lahom Laboratory+Activity+1+ +Bisection+Method

The document describes a laboratory activity on using the bisection method to find the roots of polynomial functions in MATLAB. The objectives are to determine the interval containing real roots, find roots using bisection method in MATLAB, and solve applications using bisection method in MATLAB. The procedure involves using the bisection method function in MATLAB to iteratively approximate roots within a given tolerance by halving the interval on each iteration until the desired accuracy is reached. Two example problems are worked out applying the bisection method in MATLAB to find roots of polynomials.

Uploaded by

Krystel Lahom
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
466 views8 pages

Lahom Laboratory+Activity+1+ +Bisection+Method

The document describes a laboratory activity on using the bisection method to find the roots of polynomial functions in MATLAB. The objectives are to determine the interval containing real roots, find roots using bisection method in MATLAB, and solve applications using bisection method in MATLAB. The procedure involves using the bisection method function in MATLAB to iteratively approximate roots within a given tolerance by halving the interval on each iteration until the desired accuracy is reached. Two example problems are worked out applying the bisection method in MATLAB to find roots of polynomials.

Uploaded by

Krystel Lahom
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 8

Laboratory Activity No.

1
Bisection Method
Name: Section:
Date Performed: Date Submitted:
Instructor:
1. Objective(s):

1.1 To determined the interval that the real roots lie.


1.2 To find roots of polynomial function using bisection method using MATLAB.
1.3 To solve some applications by bisection method using MATLAB.

2. Intended Learning Outcomes (ILOs):

The students shall be able to:


2.1 Determined the interval that two values have opposite sign were the real root can find.
2.2 Utilize MATLAB software in finding the roots using bisection method.
2.3 Infer appropriate conclusions based upon the results of activity.
2.4 Reflect on personal transformation along the TIP graduate attributes, specifically, professional
competence and critical thinking skills.

3. Discussion:

A roots of polynomial function can be determine by the command roots(p) where p is the 1 x n matrix
of coefficients of the polynomial. Bisection method use to find the approximate roots of a given
polynomial function. Approximating the root require a interval [ m, n ], where the root lies between m
and n. Also, the product of m and n is negative or m and n are in opposite sign. The root can be found
by continuous halving m and n until the desired error attained.

m+ n
x=
2
[ 0 7 23 1911 18 14 1 5 226 20 17 13 4 12 3 9 2115 24 16 10 2 8 ]
4. Procedure:

The MATLAB program script for bisection method below, open a new script and encode and run then
save, name the script as bisectionmethod.m

function  m = bisection(f, low, high, tol)


disp('Bisection Method'); 

% Evaluate both ends of the interval


y1 = feval(f, low);
y2 = feval(f, high);
i = 0; 

% Display error and finish if signs are not different


if y1 * y2 > 0
   disp('Have not found a change in sign. Will not continue...');
   m = 'Error'
   return
end 

% Work with the limits modifying them until you find


% a function close enough to zero.
disp('Iter    low        high          x0');
while (abs(high - low) >= tol)
    i = i + 1;
    % Find a new value to be tested as a root
    m = (high + low)/2;
    y3 = feval(f, m);
    if y3 == 0
        fprintf('Root at x = %f \n\n', m);
        return
    end
    fprintf('%2i \t %f \t %f \t %f \n', i-1, low, high, m);   

    % Update the limits


    if y1 * y3 > 0
        low = m;
        y1 = y3;
    else
        high = m;
    end
end 

% Show the last approximation considering the tolerance


w = feval(f, m);
fprintf('\n x = %f produces f(x) = %f \n %i iterations\n', m, y3, i-1);
fprintf(' Approximation with tolerance = %f \n', tol); 

Example 1. Approximate the root of the polynomial in the interval [ 0.1, 0.5 ]

f(x) = 5x4 -2.7x2 -2x +0.5 , approximate error ≤ 0.00001

Encode in new script(m-file) and name the file as sample1.m

my_fun = @(x) 5*x^4 - 2.7*x^2 - 2*x + .5;


low = .1;
high = 0.5;
tolerance = .00001;
x = bisectionmethod(my_fun, low, high, tolerance); 

Copy the output displayed on the command window.


>> sample1
Bisection Method
Iter low high x0
0 0.100000 0.500000 0.300000
Root at x = 0.200000

Example 2. Approximate the root of the polynomial in the interval [ 0, 0.5 ]

f(x) = 2.5x2 -3x+0.5 , approximate error ≤ 0.00001

Encode in new script(m-file) and name the file as sample1.m

my_fun = @(x) 2.5*x^2 - 3*x + .5;


low = 0;
high = 0.5;
tolerance = .00001;
x = bisectionmethod(my_fun, low, high, tolerance);

Copy the output displayed on the command window.

>> sample1
Bisection Method
Iter low high x0
0 0.000000 0.500000 0.250000
1 0.000000 0.250000 0.125000
2 0.125000 0.250000 0.187500
3 0.187500 0.250000 0.218750
4 0.187500 0.218750 0.203125
5 0.187500 0.203125 0.195312
6 0.195312 0.203125 0.199219
7 0.199219 0.203125 0.201172
8 0.199219 0.201172 0.200195
9 0.199219 0.200195 0.199707
10 0.199707 0.200195 0.199951
11 0.199951 0.200195 0.200073
12 0.199951 0.200073 0.200012
13 0.199951 0.200012 0.199982
14 0.199982 0.200012 0.199997
15 0.199997 0.200012 0.200005
x = 0.200005 produces f(x) = -0.000009
15 iterations
Approximation with tolerance = 0.000010

Activity 1
Approximate the root of the polynomial in the interval [ 4.2, 6.3 ]
f(x) = x4 – 5x3 – 7x2 + 41x – 30 , approximate error ≤ 0.00001

Copy the table on command window.

Iter low high x0


0 4.200000 6.300000 5.250000
1 4.200000 5.250000 4.725000
2 4.725000 5.250000 4.987500
3 4.987500 5.250000 5.118750
4 4.987500 5.118750 5.053125
5 4.987500 5.053125 5.020312
6 4.987500 5.020312 5.003906
7 4.987500 5.003906 4.995703
8 4.995703 5.003906 4.999805
9 4.999805 5.003906 5.001855
10 4.999805 5.001855 5.000830
11 4.999805 5.000830 5.000317
12 4.999805 5.000317 5.000061
13 4.999805 5.000061 4.999933
14 4.999933 5.000061 4.999997
15 4.999997 5.000061 5.000029
16 4.999997 5.000029 5.000013
17 4.999997 5.000013 5.000005

Observation: After 17th iteration, the acceptable tolerance is being attained, hence, the root of
the given polynomial is 5.000005 which has a value of f(x) = 0.000476

Activity 2
Approximate the roots of the polynomial in the interval [ – 9.2, – 5.6 ]
f(x) = x5+5x4 – 59x3 – 241x2 + 382x + 560 , approximate error ≤ 0.00001

Copy the table on command window.

Iter low high x0


0 -9.200000 -5.600000 -7.400000
1 -9.200000 -7.400000 -8.300000
2 -8.300000 -7.400000 -7.850000
3 -8.300000 -7.850000 -8.075000
4 -8.075000 -7.850000 -7.962500
5 -8.075000 -7.962500 -8.018750
6 -8.018750 -7.962500 -7.990625
7 -8.018750 -7.990625 -8.004687
8 -8.004687 -7.990625 -7.997656
9 -8.004687 -7.997656 -8.001172
10 -8.001172 -7.997656 -7.999414
11 -8.001172 -7.999414 -8.000293
12 -8.000293 -7.999414 -7.999854
13 -8.000293 -7.999854 -8.000073
14 -8.000073 -7.999854 -7.999963
15 -8.000073 -7.999963 -8.000018
16 -8.000018 -7.999963 -7.999991
17 -8.000018 -7.999991 -8.000005
18 -8.000005 -7.999991 -7.999998

Observation:After 18th iteration, the acceptable tolerance is being attained, hence, the root of
the given polynomial is -7.999998 which has a value of f(x) = 0.007210.

Exercises
Approximate the root of the following function using bisection method, approximate error ≤ 0.00001

1. e− x =sin sin x 2. x5 – x4 – 34x3 + 34x2 + 225x – 225


Code
my_fun = @(x) x^5
- x^4 - 34*x^3 +
34*x^2 + 225*x -
225 ; low = 0;
high = 1;
tolerance = .00001;
x = bisectionmethod(my_fun, low, high,
tolerance);

Output
>> x = bisectionmethod(my_fun, low, high,
tolerance);
Bisection Method
Iter low high x0
0 0.000000 1.000000 0.500000 1 0.500000
1.000000 0.750000 2 0.750000 1.000000
0.875000 3 0.875000 1.000000 0.937500 4
0.937500 1.000000 0.968750 5 0.968750
1.000000 0.984375 6 0.984375 1.000000
0.992188 7 0.992188 1.000000 0.996094 8
0.996094 1.000000 0.998047 9 0.998047
1.000000 0.999023 10 0.999023 1.000000
0.999512 11 0.999512 1.000000 0.999756 12
0.999756 1.000000 0.999878 13 0.999878
1.000000 0.999939 14 0.999939 1.000000
0.999969 15 0.999969 1.000000 0.999985 16
0.999985 1.000000 0.999992
x = 0.999992 produces f(x) = -0.001465 16
iterations
Code
Approximation with tolerance = 0.000010

3. f ( x )=x 3−4 x−9 4. f ( x )=2 sin(3 x )– 1


my_fun = @(x) 2*sin(3*x)-1 ;
low = 4;
high = 5;
tolerance = .00001;
x = bisectionmethod(my_fun, low,
high, tolerance);
Output
>> x = bisectionmethod(my_fun, low,
high, tolerance);
Bisection Method
Iter low high x0
0 4.000000 5.000000 4.500000 1
4.000000 4.500000 4.250000 2
4.250000 4.500000 4.375000 3
4.250000 4.375000 4.312500 4
4.312500 4.375000 4.343750 5
4.343750 4.375000 4.359375 6
4.359375 4.375000 4.367188 7
4.359375 4.367188 4.363281
8 4.363281 4.367188 4.365234
9 4.363281 4.365234 4.364258 10
4.363281 4.364258 4.363770 11
4.363281 4.363770 4.363525 12
4.363281 4.363525 4.363403 13
4.363281 4.363403 4.363342 14
4.363281 4.363342 4.363312 15
4.363312 4.363342 4.363327 16
4.363312 4.363327 4.363319
x = 4.363319 produces f(x) = -0.000019
16 iterations
Approximation with tolerance =
0.000010

5. (Application)

The velocity v of a falling parachutist is given by

gm
v= ( 1−e(−c/ m)t )
c

9.81 m
where g= . For a parachutist with a drag coefficient c=15 kg/s , compute the mass m so that
s2
the velocity is v=36 m/s at t=10 s. Use bisection method to determine m in the interval [55 ,60] at
0.000001.

5. Conclusion:

Therefore I believe that by using MATLAB I have easily identified the bisection method for the root/s of
the given polynomial equation. I believe that the use of MATLAB is a great benefit because MATLAB is
really simple to use and open to students. Perhaps this is one of the quickest approaches of bisection.
root/s are found.

6. Assessment (Rubric for Laboratory Activity):

BEGINNER ACCEPTABLE PROFICIENT SCO


CRITERIA
1 2 3 RE
I. Activity Skills
Work that usually needs to have quality of work and Provides work of the
Quality of
be checked/redone by some small errors on the highest quality and
work
others to ensure quality answer answers are correct
Group is consistently
Group is rarely focused on Group is focused on the
Focus on the stays focused on the task
the task and what to be task and what needs to be
task and what needs to be
done done most of the time
done
Members do not Members occasionally Members always
Process Skills demonstrate targeted demonstrate targeted demonstrate targeted
process skills. process skills. process skills.
II. Work Habits
Time
Management Members do not finish on Members finish on time Members finish on time
/ Conduct of time with incomplete data. with incomplete data. with complete data.
Activity
Members have defined Members are on tasks
Members do not know
responsibilities most of and have defined
Cooperative their tasks and have no
the time. Group conflicts responsibilities at all
and defined responsibilities.
are cooperatively times. Group conflicts
Teamwork Group conflicts have to be
managed most of the are cooperatively
settled by the teacher.
time. managed at all times.
Neat and orderly activity
Neatness and Messy activity manual and Neat and orderly activity
manual with occasional
Orderliness many erasures. manual with no erasure.
erasures.
Ability to do Members require Members require Members do not need to
independent supervision by the occasional supervision by be supervised by the
work teacher. the teacher. teacher.
Other Comments / Observations:
TOTAL SCORE

Rating =
(Total Score / 21)

You might also like