Info

Questa domanda è chiusa. Riaprila per modificarla o per rispondere.

use newton raphson method to find roots of exp(-x)-x

1 visualizzazione (ultimi 30 giorni)
지민 이
지민 이 il 7 Nov 2021
Chiuso: John D'Errico il 7 Nov 2021
clear all;
clc;
n = 11;
x = zeros(1,numel(n));
ea = zeros(1,numel(n));
g=@(x) exp(-x);
f=@(x) exp(-x)-x;
true_root=0.56714329;
disp('----------------------------------------------------');
disp('i xi Ea(%) Et(%) ');
disp('----------------------------------------------------');
for i=1:n-1
x(i+1)=g(x(i));
if x(i+1)~=0
ea(i+1)=100*abs(x(i+1)-x(i))/x(i+1);
end
end
e_t=100*abs(x-true_root)/true_root;
res=[[0:n-1]' x' ea' e_t'];
fprintf('%d %10.6f %10.3f %10.3f\n', res');
i use simple fixed-point iteration method. but i want to use newton raphson method. how can i this?

Risposte (0)

Community Treasure Hunt

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

Start Hunting!

Translated by