Sie sind auf Seite 1von 18

TITLE: BISECTION METHOD

TITTLE: BISECTION METHOD


PROGRAM: HK01 (CIVIL ENGINEERING)
PROGRAM: HK01 (CIVIL ENGINEERING)
COURSE: KA20602 (NUMERICAL ANALYSIS)
COURSE: KA20602 (NUMERICAL ANALYSIS)
LECTURER: DR DJAMILA HARIMI
LECTURER: DR DJAMILA HARIMI
SUBMISSION DATE: 27th MAY 2016
SUBMISSION DATE: 27th MAY 2016

NO. NAME MATRIC NO. SIGNATURE

1 NUR FASHA AZUIN BINTI RIDZUAN BK14110189


NO. NAME MATRIC NO. SIGNATURE

1 NUR NURUL IRAH FAZIRAH BINTI


2 FASHA AZUIN BINTI RIDZUAN BK14110189
BK14110048
SAPAR

NURUL
IRAHSHAHERAH BINTISAPAR
2 NURUL
3 FAZIRAH BINTI BK14110048
BK14110196
MOHAMAD IDRIS

SITI
NURUL NURMASYITTAH
SHAHERAH BINTI AG.
BINTI MOHAMAD
3 4 BK14110052
BK14110196
BESAR
IDRIS

SITI NURMASYITTAH BINTI AG.


4 BK14110052
BESAR
SUMMARY

This report provides the sequential problem-solution for finding the roots by using the
bisection method with manual calculation and MATLAB software as well. The problem is
commonly to find the roots for the resulting elastic curve of the beam that subject to a
linearly increasing distributed load.

For the hand-calculation, few steps to apply the bisection method to find the root
need to be followed including:

1. Pick the xl and xu such that they bound the root of interest

2. Check if f(xl).f(xu) <0, estimate the root by evaluating [x r = (xl+xu)/2]

3. Find the pair by following 3 main conditions;

If f(xl). f(x r)<0, root lies in the lower interval, then x u= x r and go to
step 2.

If f(xl). f(x r) >0, root lies in the lower interval, then xl= x r and go to
step 2

If f(xl). f(x r)>0, root lies in the upper interval, then xl= x r, go to step 2.

If f(xl). f(x r) =0, then root is x r = (xl+xu)/2 and terminate

While the approximate percent relative error, calculated by using the formula:


| | = | | 100%

Where


= estimated root from present iteration

= estimated root from previous iteration


As the problem asked us to solve two different things, methods that have been used for
MATLAB calculation are for end loop and while end loop respectively. The for end
loop allows a group of functions to be repeated a fixed and predetermined number o f
times while while end loop evaluates a group of commands with an indefinite number
of times. All calculations can be found in the results.

Findings show that there is a slightly difference between the result of hand-
calculation and result found by using the MATLAB software due to some reasons which
will be discussed in Discussion part in this report.

As a conclusion, we found that the bisection method has its own advantages and
disadvantages in calculating the roots. These will be elaborated further i n part of
Advantages and Disadvantages in this report. The errors might be occurred for both
calculations; hand-calculation and MATLAB software in such it might be prevented or
avoided with any other best solutions or recommendations that will be discussed more
in the Recommendation part so that we can find the best answers while solving each
problem.
TABLE OF CONTENTS

NO. CONTENTS PAGES

1.0 INTRODUCTION AND BACKGROUND

2.0 PROBLEM DEFINITION

3.0 NUMERICAL ANALYSIS OF THE PROBLEM

4.0 CONCLUSION AND RECOMMENDATION

5.0 REFERENCES
1.0 INTRODUCTION AND BACKGROUND

MATLAB Software
MATLAB is produced by MathWorks, and is one of a number of commercially available
software packages for numerical computing and programming. MATLAB provides an
interactive environment for algorithm development, data visualisation, data analysis,
and numerical computation. MATLAB, which derives its name from MATrix LABoratory,
excels at matrix operations and graphics. Its main competitors are Maple, Mathematica,
and Mathcad, each with their own strengths and weaknesses.

MATLAB is available in both commercial and academic versions with new


releases bimanually e. g. R2011a (released around March 2011), and R2011b (released
around September 2011). MATLAB itself is the core product and is augmented by
additional toolboxes, many of which have to be purchased separately. The ability to use
tools such as MATLAB is increasingly required by employers of graduate engineers in
industry. Many job adverts specifically mention knowledge of MATLAB as an essential
skill. MATLAB is a widely-used tool in many different fields of engineering and science.
MATLAB has 4 divided windows:-

I. Command Window: This is the main window, and contains the command prompt
(). A place to type all commands.

II. Command History: Displays a list of previously typed commands. The command
history persists across multiple sessions and commands can be dragged into the
Command Window and edited, or double-clicked to run them again.

III. Workspace: Lists all the variables that have been generated in the current
session. It shows the type and size of variables, and can be used to quickly plot,
or inspect the values of variables.

IV. Current Directory: Shows the files and folders in the current directory. The path
to the current directory is listed near the top of the MATLAB desktop. By default,
a MATLAB folder is created in your home directory on your M:drive, and this is
where you should save your work.

Table 1: Arithmetic Operations Command Description

Symbols Process
+ Addition
- Subtraction
* Multiplication
/ Division
^ Exponentiation

A script file is a text file that contains a series of MATLAB commands that would type at
the command prompt. A script file is one type of m-file (.m file extension), the other
type being a function file. Script files are useful when the user have to repeat a set of
commands, often only changing the value of one variable every time. By writing a script
file user are saving the work for later use. Script files work on variables in the current
workspace, and results obtained from running a script are left in the current workspace.
New script files can be created by clicking on the New M-File icon in the MATLAB
Window toolbar. This launches the MATLAB Editor with a blank M-File. A comment is
always preceded with a percent sign (%) which tells MATLAB not to execute the rest of
the line as a command. Then, script file names MUST NOT contain spaces (replace a
space with the underscore), start with a number, be names of built-in functions, or be
variable names. It is a good idea to use the clear all and clc commands as the first
commands in the script to clear any existing variables from the MATLAB workspace and
clear up the Command Window. Furthermore, the semicolon instructing MATLAB to
execute the command but to suppress the output. Without a semicolon, the result is
printed out immediately after the computation. Because displaying every result is
cumbersome, however, it is generally place a semicolon after each command. Multiple
commands may be written in a single line separated by semicolons. If the results are to
be printed out for each command executed, separate commands by commas. The line
may be terminated with or without a comma.

Another type of m-file (.m file extension) is a function file. Functions are similar
to scripts, except that the variables in a function are only available to the function itself
that is local to the function. This is in contrast with script files, where any variables the
user define exist in the Workspace (are global) and can be used by other scripts and
commands. A function file always begins with a function definition line. T his specifies
the input and output variables that the function will use, and defines a name for the
function. The first word, function, is mandatory, and tells MATLAB this m-file in a
function file. On the left-hand side of the equals sign is a list of the output variables
that the function will return. When there is more than one output variable, that they are
enclosed in square brackets. On the right-hand side of the equals sign is the name of
the function. User must save the function file with the same name that it has used here.
Lastly, within the round brackets after the function name, is a comma separated list of
the input variables. Besides, it is good practice to put some comments after the function
definition line to explain what task the function performs and how the user should use
the input and output variables. This is in addition to comments that would usually
include at the top of a script file.

Loops are another way of altering the flow of control in your program, and
provide methods for repeatedly executing commands. User might want to repeat the
same commands, changing the value of a variable each time, for a fixed number of
iterations. Alternatively, user might want to repeat the same commands, changing the
value of a variable each time, continually until a certain condition is reached. Two of the
most common types of loops, for and while. A for loop is used to repeat a command, or
set of commands, a fixed number of times. All for ... end loops have the same format, it
begins with for, followed by an index (i) and a range of numbers (1: n). Then come the
commands that are to be repeated. Last comes the end command. Loops are one of the
main ways that computers are made to do calculations that humans cannot. Any
calculation that involves a repeated process is easily done by a loop. Deciding to do
different things in different situations in a program is called flow control. The most
common way to do this is the if ... else ... end statement which is an extension of the if
... end statement we have used already.

Bisection Method

Bisection method is a numerical method to find a root of a given function. This is


the simplest method which is used to find zeros of continuous non-linear functions. This
method is very robust and it always tends to the solution if the signs of the function
values are different at the borders of the chosen initial interval. This method is a
successive approximation method that narrows down an interval that contains a root of
the function f(x). The bisection method is given an initial interval [a,b] that contains a
root. Next, the interval will be cut into two halves and the half interval which contains a
root of function is checked. The interval will be continuously cut into halves until
resulting interval is extremely small. The root is then approximately equal to any values
in the final interval. Unfortunately, it has only linear convergence, more precisely, it
doubles the accuracy with each iteration, which is relatively slow. Hence, it is usually
used to find only a proper initial value for alternative root finding methods which have
better rate of convergence (e.g.: Newtons method). A big advantage of the bisection
method is, however, that it can be applied for non-differentiable continuous functions.

Figure 1: Schematic representation of the iteration by bisection


Geometrically, root-finding algorithms of f(x) = 0 find one intersection point of the
graph of the function and the axis of the independent variable. In many applications,
this 1-dimensional intersection problem must be extended to higher dimensions, e.g.:
intersections of surfaces in a 3D space (volume), which can be described as a system
on non-linear equations. In higher dimensions, the existence of multiple solutions
become very important, since the intersections of two surfaces can create multiple
intersection lines.

The bisection method is used to find the root of a nonlinear real valued scalar
function f(x) = 0 (f : R R). The method is initialized with the limits of an interval [xa,
xb], where the function is defined (see Fig. 1). The signs of f(xa) and f(xb) must be
different. In this case xa and xb are bracketing at least one root, since, by the
Intermediate Value Theorem, the function f must have at least one zero in the interval
(xa, xb). At the beginning of the iteration, the midpoint of the interval xc = (xa+ xb)/2
is computed and f(xc) is evaluated. If the sign of f(xc) is the same as the sign of f(xa),
then xc is set as a new value of xa, otherwise, xc is set as a new value of xb and the
iteration is repeated. If xc happens to be a root of f (i.e., f(xc) = 0) than the iteration is
completed in finite number of steps. In this process, the length of the interval is
reduced by 50% in each step, leading to a strictly monotone linear convergence. The
drawback of this process is that it can find only one intersection point.
2.0 PROBLEM DEFINITION

Figure 2: Figure P5.13a

Figure P5.13a shows a uniform beam subject to a linearly increasing distributed load.
The equation for the resulting elastic curve is

y = 3x5-2x3+6x-8

Use bisection to determine the roots for the curve found. Use initial guesses of xl = 1
and xu = 2, and iterate the number of iterations=16. Find your answers using MatLab.

This problem asked us to find the roots of the elastic curve formed by using the
bisection method. Initial guess (xl) ,final guess (xu) and number of iterations are given.
Hence, hand-calculation is done and MatLab software is being used in order to solve
this problem.
Advantages and Limitations of Bisection Method

The bisection method, which alternatively called binary chopping, interval halving, or
Bolzanos method, is a type of incremental search method in which the interval is
always divided in half. If a function changes sign over an interval, the function value at
the midpoint is evaluated. After applying the method of bisection in our engineering
related problems, we can say that bisection method will give both advantages and
limitations in terms of calculation and to find the exact roots.

There are a few advantages of using bisection method. First and foremost, the
bisection method is always convergent. Since the method brackets the root, the method
is guaranteed to converge. The discrepancy between the true value and the midpoint of
the interval never exceeds half the interval length, x/2(Figure 1). Bisection method
provides an exact upper bound on the true error as it uses the formula of x/2 = x rnew
xrold (Figure 2). For this bound to be exceeded, the true root would have to fall
outside the bracketing interval, which could never occur for the bisection method.
Although we found that, bisection method required us to spend lot of time in
completing the calculation, the neatness of its error analysis is certainly a positive
aspect that makes it attractive for solving engineering related problems.

Figure 3: Three ways in which the interval may bracket the root
Figure 4: Graphical depiction of why the error estimate for bisection is
equivalent to the root estimate for the present iteration minus the root
estimate for the previous iteration

The drawbacks of bisection method can first be focused on the time constraints.
The convergence of the bisection method is slow as it is simply based on halving the
interval. Besides, if one of the initial guesses is closer to the root, it will take larger
number of iterations to reach the root. This will actually drag the time of calculation. If
a function f(x) is such that it just touches the x-axis such as f(x)=x2=0 (Figure 3), it will
be unable to find the lower guess, x l, and upper guess, xu, such that f(xl)f(xu)<0.

Figure 5: The equation f(x)=x 2=0 has a single root at x=0 that
cannot be bracketed
3.0 NUMERICAL ANALYSIS OF THE PROBLEM (HAND CALCULATION &
MATLAB)

There are comparison between the result from MAtLab and hand-calculation in term of
f(xr). Then, by using the Microsoft Excel the result is comparable. Excel shows 100%
similar answer with the hand-calculation. It shows that MatLab software is quit sensitive
with the commands that had been written. Fully understanding and further research
should be done to make sure that the program is run in correct ways. The difference in
results might be occurred in such it is due to the number of significant rules which
affect the whole results. Yet, the answer still similar if being round off to 3 to 4 decimal
point.

Table 2: Result from Microsoft Excel

xr f(xr)
1.5000 17.0313
1.2500 4.7490
1.1250 1.3084
1.0625 0.0383
1.0313 -0.5061
1.0469 -0.2407
1.0547 -0.1030
1.0586 -0.0328
1.0606 0.0036
1.0596 -0.0146
1.0601 -0.0055
1.0604 -0.0001
1.0605 0.0017
1.0605 0.0017
1.0605 0.0017
1.0604 -0.0001
4.0 CONCLUSION AND RECOMMENDATION

Bisection method is very simple and robust method, guaranteed to converge to a root
of f(x) if f(x) is a continuous function on the interval [a,b] and f(a) and f(b) have
opposite signs. The absolute error is halved at each step so the method converges
linearly, which is comparatively slow. This is the main problem for this method in such
because of this slow convergence, bisection method is often used to obtain a rough
approximation to a solution which is then used as a starting point for more rapidly
converging methods. The method is also called the binary search method. However, in
this section, we will only emphasize on the recommendation for some problems that we
encountered while doing calculation for bisection method manually and using MATLAB
software.

For the hand calculation, we have to determine either the root between xl and
xr or between xr and xu. We can find the sign of f(xl)f(xr) and if f(xl)(fxr)<0 then the
new bracket is between xl and xr, otherwise, it is between xr and xu. So, we are
literally halving the interval. As we repeat the process, the width of interval [xl, xu]
getting smaller, and we can zero in to the root of equation f(x) = 0. While following this
algorithm of bisection method, we tend to do mistake in such the roots might be
wrong-chosen. So, in order to prevent it to occur, determine the sign results by doing
the multiplication process correctly. Since the results will be in decimal point, round off
the value to at least 6 significant figures to find the best results.

Solving this problem using the MATLAB software; great prototyping and
investigating data obviously allow us to find the answer without recompilation. We can
type something at the command line or execute a section in the editor and immediately
see the results, greatly facilitating algorithm development. In fact, the MATLAB Desktop
environment allows us to work interactively with our data, helps us to keep track of files
and variables and simplifies common programming or debugging tasks.

However, it still got some pitfalls in using this software. As we all know, MATLAB
is an interpreted language. The main disadvantage of interpreted languages is
execution speed. When a language is compiled, all of the code is analyzed and
processed efficiently, before the programmer distributes the application. With an
interpreted language, the computer running the program has to analyze and interpret
the code (through the interpreter) before it can be executed (each and every time),
resulting in slower processing performance.

Besides that, the language was designed around small scripts to do two-
dimensional matrix math and everything else is a bolt-on, which leads to an outstanding
number of errors that can lead to real bugs and limitations. One of the examples is if
we mismatch the number of fprintf formatting symbols (%f, %d, etc) with our
arguments; we will get some serious nonsense rather than an error. Then, if we using a
function name as a variable, this will hide the function, making it impossible to call it.
Example:

>>line = [0 0 1 1];

>>line(x,y);

Instead of creating a line, an error message is probably produced. Next case is


the miss-spelling function in the beginning of an M-file. This will give the error M-file
scripts return no outputs. when trying to call the function with return arguments and
Missing operator, comma, or semi-colon. when calling it without return arguments.
Last but not the least, forgetting an end after and if clause early in the function also
will consider the main part of the function being part of that if clause, hence ignoring it
unless the specified error occurs.

Hence, in order to solve this kind of problems, we should have better


understanding on each command used in our scripts so there is no errors will be
occurred. Never use the arguments that we do not know how it works. Do more
research to find the details on each function that might be used in script to contribute
correct answers for every problem.
Another obvious problem for the MATLAB software is it uses a large amount of
memory and on slow computers, it is very hard to use. So, before installing this
software, we have to ensure that the computer got enough space and compatible with
the version of the MATLAB software that we want to install so that the installation can
be done successfully and it can be used efficiently.

It can be conclude that both types of calculations have their own pitfalls which
need to be encountered. These problems actually depend on the kind of questions that
we need to solve; the harder the questions, the more problems come, hence; more
recommendations are needed.

As a conclusion, bisection method can be said as the easiest way in finding the
roots for equations in terms of hand-calculation, so do in making the command for the
MATLAB software. It can be proved through the steps used in hand calculation of the
bisection method itself. Even though there is a difference between the result of hand
calculation and result found in MATLAB, yet it still can be encountered by doing some
other relevant alternatives which bring us to the best answers for each problems. It is
undeniable that the results found from calculation using the MATLAB software will not
always right; it might be affected by some factors which may lead to errors. Hence, it is
really critical to well-understand on how to use the MATLAB software in solving any
problems as such things that related to engineering fields. In fact, MATLAB is widely
used tool in the civil engineering community. Its numerous Toolboxes can replace and
enhance the usage of traditional stimulation tools for advanced engineering
applications. So, as the engineers-to-be, we will use it a lot in our career life someday.
5.0 REFERENCES

i. An interactive introduction to MATLAB (Online)


http://www.science.smith.edu/~jcardell/Courses/EGR326/Intro-to-
MATLAB.pdf. Retrieved on 18 th May 2016.

ii. Chapra S. C. & Canale R.P. 2006. Numerical Methods for Engineers. 5th Ed.
New York: McGraw-Hill Companies, Inc.

iii. Chapter 1 Iteration (Online)


https://www.mathworks.com/moler/exm/chapters/iteration.pdf.
Retrieved on 20 th May 2016.

iv. Chapter 1 - MAtlab Primer (Onine)


http://www.physics.mun.ca/~bdeyoung/P6314/doc/matlab/nakamura_
chapter1.pdf. Retrieved on 19 th May 2016.

v. Karris T. S. 2007. Numerical Analysis Using MATLAB and Excel. 3rd Ed. United
States: Orchard Publications.

vi. Topic 10.1: Bisection Method (Online)


https://ece.uwaterloo.ca/~dwharder/NumericalAnalysis/10RootFinding/
bisection/complete.html. Retrieved on 18 th May 2016.
REFERENCE FOR THE PROBLEM

Das könnte Ihnen auch gefallen