This is a question from numerical methods asking to explain what the code does for 12 marks.

% function [func,deriv]= fcn_nr(x)
% func = x^4 - 5*x^3 -124*x^2 + 380*x + 1200;
% deriv = 4*x^3 -15*x^2 -248*x +380;
x = input('Enter initial guess of root location:');
itermax = 100;
iter =0;
errmax =0.001;
error = 1;
fprintf('\n #root rel error\n\n');
while error > errmax & iter <itermax
iter = iter+1;
[f fprime] = fcn_nr(x);
x=x-f/fprime
if fprime ==0
fprintf('ERROR:deriv(x)=0;can"t divide by zero\n')
break;
end;
end

2 件のコメント

KALYAN ACHARJYA
KALYAN ACHARJYA 2019 年 11 月 4 日
You will get 12 points, we do not, please make sincere efforts to get points, if you have specific problem with any line, let us know here.
Raban Nghidinwa
Raban Nghidinwa 2019 年 11 月 4 日
okay thank you

サインインしてコメントする。

その他の回答 (0 件)

質問済み:

2019 年 11 月 4 日

回答済み:

2019 年 11 月 4 日

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by