KURNIA SETIAWAN
41323110024
Carilah nilai akar dari x 3−7 x 2+ 14 x=6 dengan toleransi sebesar 10−10 menggunakan metode
Newton.
clearvars; clc;
format longg
syms x
x0 = 1;
tol = 10^-10;
max = 50;
i = 1;
error = 1;
while (i<max && error>tol)
x = x0-(f(x0)/df(x0));
error = abs((x-x0)/x0);
data(i,:) = [i x0 x f(x)];
i = i+1;
x0 = x;
end
double(data)
ans = 6×4
1 1 0.333333333333333
⋯
2 0.333333333333333 0.547892720306513
3 0.547892720306513 0.584730165689234
4 0.584730165689234 0.585785582064245
5 0.585785582064245 0.585786437626343
6 0.585786437626343 0.585786437626905
if i>max || error>tol
disp('Solusi tidak ditemukan')
end