Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

CODE IN MATLAB APPLIED NUMERICAL METHODS Write your own program that performs fi

ID: 3753417 • Letter: C

Question

CODE IN MATLAB

APPLIED NUMERICAL METHODS

Write your own program that performs fixed point iteration for a given function g(x). Check whether your program converges to a fixed point or if it diverges. The convergence criterion for your program is given by the condition |xn+1 xn| < tol, where tol is a given tolerance. When it diverges, your code should run up to a maximum number N of iterations or implement a line to stop the code. Print out a message in either case to say how many steps your program has run, and what solution it has found (if the method converges). Use your program to solve the following:

2-2) Each of the following have a fixed point equal to 5. Do the Fixed-Point Iterations converge? If so, rank them from fastest to slowest. Use x0 = 2.5 and a tolerance of 108

. a) g(x) = 5 + x x^2

b) g(x) = 5/x

c) g(x) = 1 + x (1/ 5 )* x^2

d) g(x) = (1 /2 )(x+ 5/x)

(4) Solve the fixed point iteration g(x) = (1/3 + (x 1/3)^3 ), up to a tolerance 10^6 or maximum number of iterations N = 50, with (a) x0 = 1, (b) x0 = 1.4. Which execution is better? And why? Analytically find all the fixed points and analyze (without computing iterates) to which of these fixed points the method should converge if the initial guess is close enough to the root.

Explanation / Answer

please give thumbs up, thanks

ga=@(x) 5+x -x^2;
gb=@(x) 5/x;
gc=@(x) 1+x -(1/5)*x^2;
gd=@(x) (1/2)*(x+5/x);
x(1)=2.5;
tolerence=10^-8;
x(2)=ga(x(1));
n=1;
while(abs(x(n+1)-x(n))>tolerence)
n=n+1;
x(n+1)=ga(x(n));
end
fprintf("Solution for ga is %f and iteratoiion is %d ",x(length(x)),n);

x=[];
x(1)=2.4;
x(2)=gb(x(1));
n=1;
while(abs(x(n+1)-x(n))>tolerence)
n=n+1;
x(n+1)=gb(x(n));
end
fprintf("Solution for gb is %f and iteratoiion is %d ",x(length(x)),n);

x=[];
x(1)=2.5;
x(2)=gc(x(1));
n=1;
while(abs(x(n+1)-x(n))>tolerence)
n=n+1;
x(n+1)=gc(x(n));
end
fprintf("Solution for gc is %f and iteratoiion is %d ",x(length(x)),n);

x=[];
x(1)=2.5;
x(2)=gd(x(1));
n=1;
while(abs(x(n+1)-x(n))>tolerence)
n=n+1;
x(n+1)=gd(x(n));
end
fprintf("Solution for gd is %f and iteratoiion is %d ",x(length(x)),n);

%4 number
g4=@(x) (1/3) +(x-1/3)^3;  
x=[];
x(1)=1;
x(2)=g4(x(1));
n=1;
while(abs(x(n+1)-x(n))>10^-6)
n=n+1;
x(n+1)=g4(x(n));
end
fprintf("Solution for gd is %f and iteratoiion is %d ",x(length(x)),n);

x=[];
x(1)=1.4;
x(2)=g4(x(1));
n=1;
while(abs(x(n+1)-x(n))>10^-6)
n=n+1;
x(n+1)=g4(x(n));
end
fprintf("Solution for gd is %f and iteratoiion is %d ",x(length(x)),n);

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote