Question: clc; close all; clear all; format long %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%% Fixed parameters %%%%%%%%% iter = 0; iter_max = 100; rel_error = 10; tolerance = 10^-8; %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

 clc; close all; clear all; format long %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%% Fixed parameters%%%%%%%%% iter = 0; iter_max = 100; rel_error = 10; tolerance =

clc; close all; clear all;

format long

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%%%%%%%%%%%%%%%% Fixed parameters %%%%%%%%%

iter = 0;

iter_max = 100;

rel_error = 10;

tolerance = 10^-8;

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

xold = 0; % initial guess

f = @(x) (x + cos(x)-sin(x)); % solves cos(x) = sin(x)

x_appro =[];

rel_error_col = [];

while ((rel_error > tolerance) || (iter > iter_max)) % ????

xnew = f(xold); % think about this line

rel_error = abs(xnew-xold);

rel_error_col = [rel_error_col;rel_error];

x_appro = [x_appro; xnew];

xold = xnew;

iter = iter +1;

end

tot_iter = (1:iter);

x_appro;

fprintf(Simulation Summary );

fprintf(iteration x-values Relative error )

fprintf(%3.0f %6.8f %6.8f , [tot_iter ;x_appro; rel_error_col])

clc; close all; clear all; format long 1:h Fixed parameters1 iter = 0; itermax = 100 rel-error 10; tolerance-10-8; - xold 0; % initial guess f 0(x) (x + cos (x)-sin(x)); x_appro =[] ; % solves cos (x) -sin(x) rel error col -[; ((rel-error xnew f(xold); % think about this line rel-error abs (xnew_xold) ; rel-error-col = [rel-error-col; rel-error] ; x-appro = LX-appro ; xnew; xold - xnew; iteriter +1; while > tolerance) 11 (iter > iter-max)) % ???? end tot_iter-(1:iter)'; x_appro; fprintf ('Simulation Summary '); fprintf ('iteration x-values Relative error ') fprintf('X3. Of \t %6.8f \t %6.8f ', [tot-iter, ;x-appro, ; rel-error-col,])

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!