Question
Use the following pseudocode for the fixed point method to write MATLAB code to approximate a solution to x 4 3x 2 3 = 0
Use the following pseudocode for the fixed point method to write MATLAB code to approximate a solution to x4 3x2 3 = 0 on the interval [1, 2] with accuracy roughly within 10-8 using x0 = 1. Use maximum number of iteration of 100. Explain steps by commenting on them.
Algorithm : Bisection Method
Input: f(x)=ex x2, interval [0,2], tolerance 10-3, maximum number of iterations 50
Output: an approximate root of f on [0, 2] within 10-3 or a message of failure
set a = 0 and b = 2;
xold = a; for i = 1 to 50 do set x = (a + b)/2; if |x xold| < 10-3 then % checking required accuracy
FoundSolution = true; % done
Break; % leave for environment end if if f(a)f(x) < 0 then a = a and b = x
else a = x and b = b
end if xold = x; % update xold for the next iteration
end for if FoundSolution then
return x else print the required accuracy is not reached in 50 iterations end if
Algorithm : Fixed-point Iteration Input: g(x) = ln(x + 2), interval [0, 2], an initial approximation x0, tolerance 10-3, maximum number of iterations 50 Output: an approximate fixed point of g on [0, 2] within 10-3 or a message of failure set x=x0 and xold=x0;
for i = 1 to 50 do x = g(x); if |x xold| < 10-3 then % checking required accuracy FoundSolution = true; % done break; end if xold = x; % update xold for the next iteration
end for if FoundSolution then
return x else print the required accuracy is not reached in 50 iterations
end if
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started