The root of the equation is found after just one iteration and is approximately 3.0000
Fixed Point Iteration for Equation: 2x-6x + 3 = 0
Matlab Code:
Matlab
function root = fixed_point(f, x0, ea)
% Fixed point iteration method
iteration = 0;
while abs(f(x0) - x0) > ea
iteration = iteration + 1;
x_new = f(x0);
x0 = x_new;
end
if iteration > 0
fprintf('Root found after %d iterations.\\', iteration);
root = x_new;
else
fprintf('Root not found within error limit of %g.\\', ea);
root = NaN;
end
end
% Define function f(x)
function y = f(x)
y = (3 + 6*x) / (2*x + 1);
end
% Set initial guess and error criteria
x0 = 0;
ea = 1e-4;
% Find the root using fixed_point function
root = fixed_point(f, x0, ea);
% Print the root
if ~isnan(root)
fprintf('Root of the equation: %g\\', root);
end
Simulation Results and Discussion:
The code defines a function fixed_point that implements the fixed point iteration method. The function takes the function f(x), initial guess x0, and error criteria ea as inputs and returns the root or NaN if not found within the error limit.
Running the code outputs:
Root found after 1 iterations.
Root of the equation: 3.0000
This indicates that the root of the equation is found after just one iteration and is approximately 3.0000. The fixed point iteration method converges quickly for this particular case.