2. Write a function fixed-point_iteration that inputs a function g, an initial g
ID: 3751189 • Letter: 2
Question
2. Write a function fixed-point_iteration that inputs a function g, an initial guess ro, an error tolerance tol, 1 and a maximum number of iterations N, and approximates a fixed point c of g using fixed-point iteration. Your r function should estimate error as err--1l and halt when err N, whichever happens first. The function signature should be as follows: function [c, n, err] fixed-point-iteration(g, ro, tol, N) = Use your code to solve z - g(x), g: for r e-1,1], with tol how many iterations were needed. 1010. State your initial guess andExplanation / Answer
%computes approximate solution of g(x)=x
%input:function handle g,starting guess x0,
% number of iteration steps N
%output: Approximate solution xc
function xc[c.n,err]=fixed_pointer_iteration(g,x0,t01,N)
x(1)=x0
for i=1:N
x(i+1)=g(x(i));
end
xc=x(N+1);
here,
we know x=g(x)
g:x->e^-x
using the above code
x(1)=e^0=1
x(1+1)=X(2)
x(2)=e^1=2.718
----------------------------------THANK YOU-------------------------
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.