Fixed Point Iteration Method
In the fixed point iteration method, we are given with function . We reorganize this function into the form:
The function is called a fixed point iteration function.
After obtaining the function , we have to find a numerical value of such that . For that, we start with a guess . Then we iteratively find the next approximation with:
This is equivalent to applying the function over and over again to the initial guess like . We can understand why this works with the following diagram:
Fixed point iteration visualization
In the above diagram, the vertical projection into is equivalent to calculating and the horizontal projection into the line turns the output of to be the next input producing .
The fixed point iteration method is one of the oldest and most widely used methods. Babylonians used this method to find the square root of a number.
Given, the function , finding the square root of is equivalent to solving . Now let's write this equation in the form as:
Now we can find the square root of starting from as follows:
Algorithm
- Start
- Read values for initial guess and error threshold
- Calculate
- If assign and go to 3.
- Print solution
- Stop
Programs
- C
- Python
- Matlab
/*
* Fixed point iteration method in C
*/
#include<stdio.h>
#include<math.h>
#define MAX_ITER 100
double phi(double x){
return 0.5 * (2/x + x);
}
int main(){
double x0, x1, threshold;
int iter = 0;
printf("-------------Fixed Point Iteration-------------\n");
printf("Enter x0: ");
scanf("%lf", &x0);
printf("Enter error threshold: ");
scanf("%lf", &threshold);
printf("%5s %10s %10s\n", "N", "xn", "xn+1");
while(iter<MAX_ITER){
x1 = phi(x0);
iter++;
printf("%5d %10.5lf %10.5lf\n", iter, x0, x1);
if(fabs(x1-x0)<threshold){
printf("\nHence the solution is: %10.5lf\n", x1);
return 0;
}else{
x0 = x1;
}
}
printf("Max iterations reached\n");
return -1;
}
#
# Fixed point iteration method in Python
#
MAX_ITER = 100
def phi(x):
return 0.5 * (2/x + x)
def fixed_point(x0, threshold):
print("%5s %10s %10s" % ("N", "xn", "xn+1"))
iter = 0
while iter < MAX_ITER:
x1 = phi(x0)
iter += 1
print("%5d %10.5lf %10.5lf" % (iter, x0, x1))
if abs(x1-x0) < threshold:
print("\nHence the solution is: %10.5lf" % x1)
return
else:
x0 = x1
raise "Max iterations reached"
print("-------------Fixed Point Iteration-------------")
x0 = float(input("Enter x0: "))
threshold = float(input("Enter error threshold: "))
fixed_point(x0, threshold)
%% Fixed point iteration method in Matlab/Octave
MAX_ITER = 100;
printf('-------------Fixed Point Iteration-------------\n');
phi = @(x) 0.5 * (2/x + x);
printf('Enter x0: ');
x0 = scanf('%f', 'C');
printf('Enter error threshold: ');
threshold = scanf('%lf', 'C');
printf('%5s %10s %10s\n', 'N', 'xn', 'xn+1');
iter = 0;
while(iter<MAX_ITER)
x1 = phi(x0);
iter++;
printf('%5d %10.5f %10.5f\n', iter, x0, x1);
if(abs(x1-x0)<threshold)
printf('\nHence the solution is: %10.5f\n', x1);
break;
else
x0 = x1;
end
end
if iter >= MAX_ITER
error('Max iterations reached');
end
Output
-------------Fixed Point Iteration-------------
Enter x0: 1
Enter error threshold: 0.0001
N xn xn+1
1 1.00000 1.50000
2 1.50000 1.41667
3 1.41667 1.41422
4 1.41422 1.41421
Hence the solution is: 1.41421
Convergence
The fixed point iteration method has a variable convergence rate and a linear order of convergence.
Advantages
- Requires only one initial guess
- Can be implemented easily in programs
- Suitable for manual calculation
Disadvantage
- Slower convergence.
- Finding can be challenging for complicated equations.