0% found this document useful (0 votes)
26 views3 pages

Lab No.10

This lab report details implementing the fixed point iteration root finding method in MATLAB. The objective is to create a program that uses this numerical analysis technique to locate roots of polynomials. The method works by iteratively applying a function g(x) where the root is a fixed point, such that the absolute value of the derivative is less than 1. The algorithm involves choosing an initial guess x0, expressing the equation as x = g(x), and iteratively calculating xn = g(xn-1) until the difference between successive approximations is very small. The student provides MATLAB code that takes a user-input function, initializes iterations, and outputs the estimated root. When tested on the function cos(x), it returns a

Uploaded by

David James
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)
26 views3 pages

Lab No.10

This lab report details implementing the fixed point iteration root finding method in MATLAB. The objective is to create a program that uses this numerical analysis technique to locate roots of polynomials. The method works by iteratively applying a function g(x) where the root is a fixed point, such that the absolute value of the derivative is less than 1. The algorithm involves choosing an initial guess x0, expressing the equation as x = g(x), and iteratively calculating xn = g(xn-1) until the difference between successive approximations is very small. The student provides MATLAB code that takes a user-input function, initializes iterations, and outputs the estimated root. When tested on the function cos(x), it returns a

Uploaded by

David James
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/ 3

Numerical Analysis Lab

Lab No.10

Submitted By:
Muhammad Hassan (2020-MC-274)
Submitted to:
Dr. Arshi Khalid
--------------------------------------------------------------------------------------------------------
-

Department of Mechatronics & Control Engineering


University of Engineering & Technology Lahore,
Faisalabad Campus.
Lab report By: M.Hassan (2020-MC-274) Submitted To: Dr. Arshi Khalid

Date: 01-11-2022

Lab Objective:
Implement the following Root Finding Methods on the Matlab.

 To create a program for a Fixed Point Iteration Method to locate the roots of polynomials.

 Fixed Point Iteration Method:


The fixed point iteration method uses the concept of a fixed point in a repeated manner to
compute the solution of the given equation.

Suppose we have an equation f(x) = 0, for which we have to find the solution. The equation can be
expressed as x = g(x). Choose g(x) such that |g’(x)| < 1 at x = x o where xo,is some initial guess called fixed
point iterative scheme. Then the iterative method is applied by successive approximations given by x n = g(xn
– 1), that is, x1 = g(xo), x2 = g(x1) and so on.

Algorithm of Fixed Point Iteration Method:

 Choose the initial value xo for the iterative method. One way to choose x o is to find the values x = a
and x = b for which f(a) < 0 and f(b) > 0. By narrowing down the selection of a and b, take x o as the
average of a and b.
 Express the given equation, in the form x = g(x) such that |g’(x)| < 1 at x = x o. If there more than one
possibility of g(x), choose the g(x) which has the minimum value of g’(x) at x = xo.
 By applying the successive approximations xn = g(xn – 1), if f is a continuous function, we get a
sequence of {xn} which converges to a point lo, which is the approximate solution of the given
equation.

Matlab Code:
% Fixed Point Iteration Method
clc;
clear;
f = input('\nPlease re-arrange the function in the form of x = g(x) before entering it
in the Matalb\nEnter the function: ');
% to take the initial guess
a = 0;
x(1) = f(a);
x(2) = f(x(1));
n = 3;
while (((x(n-1) - x(n-2)) > 0.00001) || ((x(n-1) - x(n-2)) < -0.00001))
x(n) = f(x(n-1));
n = n+1;
end
fprintf('\nRoot is: \t%f\n',x(n-1));

Output:
If we input
Please re-arrange the function in the form of x = g(x)
before entering it in the Matalb
Enter the function: @(x) cos(x)

2
Lab report By: M.Hassan (2020-MC-274) Submitted To: Dr. Arshi Khalid

Then
Root is: 0.739082

You might also like