Write a MATLAB code for fixed point iteration method using Aitken Steffensen acceleration procedure. Steffensen’s Method is a combination of fixed-point iteration and the Aitken’s 42 method: Suppose we have a fixed point iteration: Po; P1 = g (po). P2 = g (p1 ). Once we have po, P1 and p2, we can compute (P1 Po)4 po = Po P2 2p1 + Po At this point we ‘restart” the fixed point iteration with po 5 Po, e.g. p3 = po. P4 = g(p3) . p5 = g (pa). and compute (pa p3)2 p3 = p3 p5 2p4 + p3
The Correct Answer and Explanation is:
Here’s a MATLAB code implementing the fixed-point iteration method using Steffensen’s acceleration procedure:
matlabCopyEdit% Steffensen's Method for Fixed-Point Iteration
% Function for fixed-point iteration
g = @(x) (x^2 + 1)^(1/2); % Example function: g(x) = sqrt(x^2 + 1)
% Initial guess
p0 = 1.0;
% Tolerance and maximum iterations
tolerance = 1e-6;
max_iter = 100;
% Initialize iteration variables
iter = 0;
p0_vals = p0;
error = Inf;
while error > tolerance && iter < max_iter
% Fixed-point iterations
p1 = g(p0);
p2 = g(p1);
% Steffensen's method
p_new = p0 - ((p1 - p0)^2) / (p2 - 2*p1 + p0);
% Error calculation
error = abs(p_new - p0);
% Update the guess for next iteration
p0 = p_new;
p0_vals = [p0_vals, p0]; % Store iteration values
% Increment iteration counter
iter = iter + 1;
end
% Display results
disp('Steffensen Method Results:');
disp(['Root: ', num2str(p0)]);
disp(['Iterations: ', num2str(iter)]);
disp(['Final Error: ', num2str(error)]);
Explanation:
- Fixed-Point Iteration: The general idea of fixed-point iteration is to iterate the equation pn+1=g(pn)p_{n+1} = g(p_n)pn+1=g(pn), where g(x)g(x)g(x) is a function chosen to express the root of the equation.
- Steffensen’s Method: This method accelerates the fixed-point iteration by applying Aitken’s delta-squared process. After computing p1p_1p1 and p2p_2p2 from the fixed-point iteration, the new approximation pnewp_{\text{new}}pnew is computed as: pnew=p0−(p1−p0)2p2−2p1+p0p_{\text{new}} = p_0 – \frac{(p_1 – p_0)^2}{p_2 – 2p_1 + p_0}pnew=p0−p2−2p1+p0(p1−p0)2 This formula helps improve convergence speed, reducing the number of iterations required to reach a sufficiently accurate approximation of the root.
- Loop until Convergence: The loop continues until the error (absolute difference between the new and old approximations) is less than the set tolerance or the maximum number of iterations is reached.
- Performance: Steffensen’s method significantly speeds up convergence compared to basic fixed-point iteration, especially when the function has a slowly converging fixed-point. The process is often faster, needing fewer iterations to achieve a desired precision.
- Result Display: Once the loop completes, the final root, iteration count, and error are displayed.
You can modify the function g(x)g(x)g(x) as per your problem. The given example uses g(x)=x2+1g(x) = \sqrt{x^2 + 1}g(x)=x2+1, but any function where the fixed-point iteration is applicable can be used.
