You are on page 1of 9

ACTIVITY 5

ROOT FINDING TECHNIQUES IN GNU OCTAVE


(Bracketing Methods)

INTRODUCTION

Root finding in numerical methods is a fundamental problem in computational


mathematics and plays a crucial role in various applications, such as
optimization, engineering, physics, and many others. It involves determining the
values of variables or unknowns that satisfy a given equation. Numerical
methods for root finding are used when analytical solutions are either difficult to
obtain or do not exist [6].

Since root finding in numerical methods involves iterative processes, it is better


to use a computer program to calculate. Using computer programs will lessen the
computation time and error due to human intervention.

Root-finding methods are classified into two, bracketing methods and open
methods. In this activity, we will first explore how to use root-finding under
bracketing methods by computer programming using GNU Octave.

OBJECTIVES

At the end of the activity, the students are expected to:


1. Identify the different bracketing methods of root-finding;
2. Create a computer program for each bracketing method;
3. Execute the computer program for each bracketing method.

MATERIALS

Computer with installed full version of GNU Octave.

TIME FOR ACTION


Bisection Method

Bolzano’s theorem states that - if f(x) is continuous on the closed


interval [a, b], and suppose that f(a) and f(b) have opposite signs, then
there exists a number c in the interval [a, b], for which f(c) = 0. The
bisection method uses this theorem and computes the roots of a
function.

1. The Bisection Method follows the steps below:

Step 1: Choose lower xl and upper xu guesses for the root such that the
function changes sign over the interval. This can be checked by ensuring that
.

30 | P a g e
𝑥𝑙 +𝑥𝑢
Step 2: An estimate of the root is determined by: 𝑥𝑟 = 2
Step 3: Make the following evaluations to determine in which subinterval
the root lies:
a) If , the root lies in the lower subinterval.
Therefore, set and return to step 2.
b) If , the root lies in the upper subinterval.
Therefore, set and return to step 2.
c) If , the root equals ; terminate the computation.
2. The bisection method uses this theorem and computes the roots of a
function. The algorithm is as follows:

Create a flowchart based on the algorithm given. Draw the flowchart in


Observation Matrix I.1.

3. Create a new script by clicking the New Script Function . Type the

following commands and save the file by clicking the button. Name the
file

31 | P a g e
4. Find the positive root of the following function 𝑓(𝑥) = 𝑥 2 − 2𝑥 − 35 using:
a. Your scientific calculator. Write the result in Observation Matrix
I.2.
b. The Octave script you created earlier by clicking the button or
typing the script name in the command window. Use initial values:
Write the result in Observation Matrix I.3.

Note: In typing the function to Octave, type it in linear form. For


example, the given function should be typed as .

5. Create a bisection method in Octave that has a changeable value of stopping


criterion ( ) and will display the results in tabular form. Write your
lines of code in Observation Matrix I.4.
6. Use the code you created in procedure 5 to find the root of the same function
in procedure 4. Use Write the result in Observation Matrix
I.5.

TIME FOR ACTION


False Position Method

The Regula-Falsi method, also known as the false position method,


belongs to the category of proper bracketing methods. It guarantees
that the selected interval for the next iteration ensures that the
function's values at the endpoints of the interval have opposite signs.

1. The False-Position Method follows the steps below:

Step 1: Choose lower xl and upper xu guesses for the root such that the
function changes sign over the interval. This can be checked by ensuring that

32 | P a g e
𝑓(𝑥 )𝑥 −𝑥
Step 2: An estimate of the root is determined by: 𝑥𝑟 = 𝑥𝑢 − 𝑓(𝑥 𝑢)−𝑓(𝑥
𝑙 𝑢
)
𝑙 𝑢
Step 3: Make the following evaluations to determine in which subinterval
the root lies:
a) If , the root lies in the lower subinterval.
Therefore, set and return to step 2.
b) If , the root lies in the upper subinterval.
Therefore, set and return to step 2.
c) If , the root equals ; terminate the computation
2. False-Position Method Algorithm/Pseudocode:

Create a flowchart based on the pseudocode given. Draw the flowchart in


Observation Matrix II.1.

3. Create a new script by clicking the New Script Function . Type the

following commands and save the file by clicking the button. Name the
file

33 | P a g e
4. Repeat procedures 4 – 6 from the Bisection Method activity and write the
required results on the observation matrix respectively.

OBSERVATION MATRIX

I. Bisection Method
1.

2.

34 | P a g e
3.

4.

35 | P a g e
5.

II. False-Position Method


1.

36 | P a g e
2.

3.

4.

5.

37 | P a g e
GUIDE QUESTIONS

What are the difference between Bisecion and False-Position in finding root
1.
of equations?

2. What do the function accomplish?

Which bracketing method is better in finding the roots? Is there a time


3.
when Bisection is better than False-Position or vice-versa?

38 | P a g e

You might also like