# Simple fixed-point iteration method

542 views (last 30 days)
John Smith on 22 Sep 2019
My task is to implement (simple) fixed-point interation.
So far, I've got the following and I keep receiving error Undefined function 'fixedpoint' for input arguments of type 'function_handle'.
(I'm new in Matlab, so there may be both syntactical or semantical errors...)
function [ x ] = fixedpoint(g,I,y,tol,m)
% input: g, I, y, tol, max
% g - function
% I - interval
% y - starting point
% tol - tolerance (error)
% m - maximal number of iterations
% x - approximate solution
a=I(1);b=I(2);
if(y<a | y>b)
error('The starting iteration does not lie in I.')
end
x=y;
gx=g(y);
while(abs(x-gx)>tol & m>0)
if(gx<a | gx>b)
error('The point g(x) does not lie in I.')
end
y=x;
x=g(y);
m=m-1;
end

Dimitris Kalogiros on 22 Sep 2019
Dear John
Put your function into the same folder with the program (m-file) that calls it.
Dimitris Kalogiros on 24 Sep 2019
Hm hm, I don't know if it is necessary , but I always follow this rule.

Ishita Sharma on 18 Aug 2020
f(x)=x^2 - x -1 =0

emmanuel john Lavarias on 27 Sep 2021
1. Solve one real root of ex2x5=0ex2x5=0 with x0=2x0=2 using the Fixed-Point Iteration Method accurate to four decimal places.