0% found this document useful (0 votes)
24 views6 pages

Fixed Point Iteration Method in MATLAB

Uploaded by

Ratas Khan
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)
24 views6 pages

Fixed Point Iteration Method in MATLAB

Uploaded by

Ratas Khan
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/ 6

Numerical Methods

LAB REPORT # 02
Submitted To
Sir Ayaz Mehmood

Submitted By
Jalil Rabbani 18-EE-095

Ratas Khan Niazi 18-EE-141

Section
“D”
Date: March 11th,2021
Marks Distribution 5 5 5
Marks Obtained
Report # 02
Fixed Point Intersection

Objective:
Objective of this lab session is to understand and implement Fixed Point Intersection method
by coding.

Software Tool:
1. MATLAB simulation tool.
Theory:

In numerical analysis, fixed-point iteration is a method of computing fixed points of a


function. More specifically, given a function defined on the real numbers with real values
and given a point in the domain of, the fixed point iteration is. This gives rise to the
sequence which is hoped to converge to a point. This method includes three steps, first to
select an appropriate interval at which the sign of output changes. Second is to check all the
possible solution of function that it can be a part of variable, i.e. if the function is f(x) the
proposed solution is x- g(x)=f(x). Check a point in a specified interval an function x=g(x)<1 that
proposed equation can be select. Xn+1=g(xn).

Procedure:
 Begin by turn on the computer, after turning on the computer.

 We familiarized with bisection method and familiarized with the way of solution.

 Open the MATLAB simulation tool, then read the given tasks and start coding them on
the software.

 The codes we also use some built in functions. From help we learn about the built-in
functions and we also come to know what they function do.

 This method includes three steps, first to select an appropriate interval at which the
sign of output changes.

 Second is to check all the possible solution of function that it can be a part of variable,
i.e. if the function is f(x) the proposed solution is x- g(x)=f(x). Check a point in a
specified interval an function x=g(x)<1 that proposed equation can be select.
 Xn+1=g(xn).

 Each if statement requires an end keyword. Avoid adding a space after else within
the else if keyword (else if ). The space creates a nested if statement that requires its
own ends keyword.
 A for loop is a repetition control structure that allows you to efficiently write
a loop that needs to execute a specific number of times. The syntax of a for loop in
MATLAB is as following: for index = values.

 After that we run the codes and we see the output on the screen.

 Similarly, we perform all other given tasks and compile them also and see the output on
the screen.

General function:
Write a code for function f(x) to calculate root.
x a b
f(x) Output at a Output at b
sign - +

Program:
x0=1;
maxlter=50;
tolX=1e-4;
x=x0;
xold=x0;
for i=1:maxlter
x=g(x);
err=abs(x-xold);
xold=x;
if(err<tolX)
break;
end
end
x
i

Task # 01:
Find the root of x-(2+ln(x))=0
Calculation:
Let x=ln(x)+2
Program:
x0=1;
maxlter=50;
tolX=1e-4;
x=x0;
xold=x0;
for i=1:maxlter
x=2+log(x);
err=abs(x-xold);
xold=x;
if(err<tolX)
break;
end
end
x
i
table:
X-Values y=x g(x)=ln(x)+2 (FPI) f(x)=x-ln(x)-2 (BM)
0 0
0.5 0.5 1.3069 -0.8069
1 1 2 -1
2 2 2.6931 -0.6931
3 3 3.0986 -0.0986
4 4 3.3863 0.6137
5

2 y=x
g(x)=ln(x)+2 (FPI)
1 f(x)=x-ln(x)-2 (BM)

0
0 0.5 1 1.5 2 2.5 3 3.5 4 4.5

-1

-2

Output:
Task # 02:
Find the root of x2-x-1=0
Calculation:
1
Let x=1+
x

Program:
x0=1;
maxlter=50;
tolX=1e-4;
x=x0;
xold=x0;
for i=1:maxlter
x=1+1/x;
err=abs(x-xold);
xold=x;
if(err<tolX)
break;
end
end
x
i
Table:
y Y=x g(x)=1+1/x (FPI) f(x)=x^2-x-1 (BM)
0 0 -1
1 1 2 -1
2 2 1.5 1
3 3 1.333333333 5
6

3
Y=x
2 g(x)=1+1/x (FPI)
f(x)=x^2-x-1 (BM)
1

0
0 0.5 1 1.5 2 2.5 3 3.5
-1

-2

Output:

‘x’ is root that we want to calculate and ‘i’ is no of iteration.

Conclusion:
In this experiment we learned Fixed Point Iteration method which provides us a root of
equation. We made a function of variable that is part of equation whose root our desire to
calculate. The benefit of implementing it by coding we can write a function and get an
output with in a second.

You might also like