0% found this document useful (0 votes)
2 views

Bisection Method Humanized

The document explains the Bisection Method, a numerical technique for finding roots of nonlinear equations, and provides a MATLAB implementation to find the root of the function f(x) = x + exp(x) + 2 within the interval [-10, 4] with a tolerance of 0.01. It outlines the steps involved in the method, including interval checking, iteration, and plotting the results. The conclusion emphasizes the reliability of the Bisection Method in engineering and applied mathematics.

Uploaded by

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

Bisection Method Humanized

The document explains the Bisection Method, a numerical technique for finding roots of nonlinear equations, and provides a MATLAB implementation to find the root of the function f(x) = x + exp(x) + 2 within the interval [-10, 4] with a tolerance of 0.01. It outlines the steps involved in the method, including interval checking, iteration, and plotting the results. The conclusion emphasizes the reliability of the Bisection Method in engineering and applied mathematics.

Uploaded by

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

Understanding and Implementing the Bisection Method in MATLAB

The Bisection Method is a simple yet powerful numerical technique used to find the
roots of a nonlinear equation. It works by repeatedly dividing an interval [a, b] in half and
selecting the subinterval where the function changes sign. This process continues until the
interval is small enough, ensuring an accurate approximation of the root.

In this document, we'll implement the Bisection Method in MATLAB to find the root of the function:

f(x) = x + exp(x) + 2

within the interval [-10, 4] with a given tolerance of 0.01 (1e-2).

MATLAB Code Explanation


The MATLAB script follows these steps:

1. Define the function and the given interval [a, b].


2. Check if a root exists within the interval using the condition f(a) * f(b) < 0.
3. Initialize the iteration counter and an array to store approximations.
4. Use a while loop to repeatedly bisect the interval until the desired accuracy is reached.
5. Display the approximate root and the number of iterations.
6. Plot the function along with the computed root approximations.

Now, let's look at the MATLAB code:

clc; clear all; close all;


% Define the interval and tolerance
a = -10; b = 4; tol = 1e-2;

% Define the function


f = @(x) x + exp(x) + 2;

% Initialize iteration counter and approximation list


iter = 0;
sol = [];
% Check if a root exists within the interval
if f(a) * f(b) > 0
fprintf('No root in the given interval.\n');
return;
end

% Bisection Method Loop


while abs(b - a) > tol
c = (a + b) / 2;
sol = [sol, c];
if f(a) * f(c) < 0
b = c;
else
a = c;
end
iter = iter + 1;
end

% Display results
fprintf('Approximate root: %f\n', c);
fprintf('Number of iterations: %d\n', iter);

% Plot results
x_vals = linspace(-10, 4, 100);
y_vals = f(x_vals);
figure; hold on; grid on;
plot(x_vals, y_vals, 'b-', 'LineWidth', 1.5);
plot(sol, f(sol), 'ro', 'MarkerSize', 8, 'MarkerFaceColor', 'r');
xlabel('x'); ylabel('f(x)');
title('Bisection Method Approximation');
legend('Function f(x)', 'Approximations');
hold off;

Conclusion
The Bisection Method is a reliable numerical approach to finding roots of equations.
In this example, we successfully implemented it in MATLAB and plotted the approximations to
visualize
the convergence. This technique is widely used in engineering and applied mathematics for solving
nonlinear equations.

You might also like