Root ?nding using the bisection method, MATLAB Programming

Assignment Help:

In many applications, including ?nancial mathematics, ?nding zeros of a function

f(x) = 0 (4)

is paramount. One of the simplest method is the Bisection Method. The bisection method is a systematic search technique for ?nding a zero of a continuous function. The method is based on a well-known property of continuous functions, the intermediate value theorem. We ?rst ?nd an interval in which a zero is known to occur. This is done by evaluating the function f(x) at a and b: if f(a) > 0 and f(b) < 0 or if f(a) < 0 and f(b) > 0 then there exists a number x = c, say, between a and b such that f(c) = 0.

Suppose that an interval [a, b] has been located which is known to contain a zero, since the function changes sign between a and b. The approximate solution is the midpoint of the interval and therefore the zero must now lie either in the interval [a, x1] or [x1, b]. The appropriate subinterval is determined by testing the function to see whether it changes sign on [a, x1].

If yes, the search continues to obtain the next point x2 = a+x1 Otherwise, the search continues on [x1, b to obtain x1 = x1+b And the search is repeated until one converges to the approximate root either given some tolerance or number of iterates to convergence.

Below, I give you a head start to writing a MATLAB function bisect to compute a zero of a function. Let us consider as inputs a, b, tolerance, nmax (we do not want our algorithm to run forever in case it can not ?nd a zero), and the function fun. You must ?nd was of declaring the function fun such that it can be read easily into our function bisect. We want to output xvect (the vector containing the approximates zeros x0, x1, · · · , etc.), xdif (this is the difference between the roots to monitor the error), fx (this is a vector with the values of the function evaluated at it approximate zero, i.e. a vector of all f(xi)) and ?nally nit (this is the maximum number of iterations taken to converge. If the  algorithm can not ?nd the zero, then nit = nmax).


Related Discussions:- Root ?nding using the bisection method

Example of variable names, Example of variable names: If nothing appea...

Example of variable names: If nothing appears when, who or whose is entered, which means there aren't any variables! For illustration, in the starting of a MATLAB session, the

Batch reactor, how to wriet program for batch reactor

how to wriet program for batch reactor

Mod function, how to reverse the digits of positive number by using mod fun...

how to reverse the digits of positive number by using mod function?

Matlab programming on johnson''s sequencing rule, i want matlab programming...

i want matlab programming on johnson''s sequencing rule

Suspension, how to control a suspension by linear quadratic regulator metho...

how to control a suspension by linear quadratic regulator method?

Monte carlo simulation, i need help with a monte carlo simulation. I have m...

i need help with a monte carlo simulation. I have most of the code, but I can''t get it to plot correctly

Write a computer program using matlab, From A to B the inlet valve is open ...

From A to B the inlet valve is open and the steam pressure increases linearly from 0.1000 MPa absolute to 15.00 MPa absolute, 1000°C. The inlet valve closes and from B to C the

Write Your Message!

Captcha
Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd