0% found this document useful (0 votes)
2 views4 pages

NM-Lab 08 Bisection Method Lab

The document provides an overview of the bisection method, a technique for finding the roots of polynomial equations by narrowing intervals based on the intermediate theorem for continuous functions. It outlines the algorithm steps, including defining a function, choosing an initial interval, setting tolerance and maximum iterations, and implementing the method in MATLAB. A sample MATLAB script is included to illustrate the implementation of the bisection method.

Uploaded by

Naeem Hanif
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)
2 views4 pages

NM-Lab 08 Bisection Method Lab

The document provides an overview of the bisection method, a technique for finding the roots of polynomial equations by narrowing intervals based on the intermediate theorem for continuous functions. It outlines the algorithm steps, including defining a function, choosing an initial interval, setting tolerance and maximum iterations, and implementing the method in MATLAB. A sample MATLAB script is included to illustrate the implementation of the bisection method.

Uploaded by

Naeem Hanif
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/ 4

Lab# 08

Bisection Method on MATLAB


Introduction to Bisection Method
he bisection method is used to find the roots of a polynomial equation. It separates the interval and
subdivides the interval in which the root of the equation lies. The principle behind this method is the
intermediate theorem for continuous functions. It works by narrowing the gap between the positive and
negative intervals until it closes in on the correct answer. This method narrows the gap by taking the
average of the positive and negative intervals. It is a simple method and it is relatively slow. The
bisection method is also known as interval halving method, root-finding method, binary search method
or dichotomy method.

Bisection Method Algorithm


For any continuous function f(x),

 Find two points, say a and b such that a < b and f(a)* f(b) < 0

 Find the midpoint of a and b, say “t”

 t is the root of the given function if f(t) = 0; else follow the next step

 Divide the interval [a, b] – If f(t)*f(a) <0, there exist a root between t and a
– else if f(t) *f (b) < 0, there exist a root between t and b

 Repeat above three steps until f(t) = 0.

The bisection method is an approximation method to find the roots of the given equation by repeatedly
dividing the interval. This method will divide the interval until the resulting interval is found, which is
extremely small.

Procedure to Execute Bisection Method


Step-by-Step Procedure to Implement Bisection Method in MATLAB

1. Define the Function

You must have a function f(x)f(x) defined either as an inline function or as a separate function file.

Example:

f = @(x) x^3 - x - 2; % Example function

2. Choose Initial Interval [a, b]

Make sure:

f(a)*f(b) < 0

This condition ensures the existence of a root in [a,b][a, b].


3. Set Tolerance and Maximum Iterations

Define a stopping criterion:

tol = 1e-6; % Desired tolerance

max_iter = 100; % Max number of iterations

4. Implement the Bisection Method

Here's a sample MATLAB script for the bisection method:

% Bisection Method in MATLAB

f = @(x) x^3 - x - 2; % Define your function here

a = 1; % Start of interval

b = 2; % End of interval

tol = 1e-6; % Tolerance

max_iter = 100; % Maximum number of iterations

if f(a)*f(b) > 0

error('Function has same sign at endpoints a and b. Choose a different interval.')

end

for i= 1:n

c= (a+b)/2

fprintf('P%d=%.4f\n',i,c)

if abs(c-b)<e || abs(c-a)<e

break

end

if f(a)*f(c)<0

b=c;

elseif f(b)*f(c)<0

a=c;

end

end

else disp('No root given below brackets')

end

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy