Tugas 14 Metode Numerik - Nur Syah Ibrahim - 41322120032
Tugas 14 Metode Numerik - Nur Syah Ibrahim - 41322120032
dengan keakuratan
clearvars; clc
format longg
syms H
h = 8;
r = 2;
v = 45;
f(H) = pi*(r^2*h/3 + H*r^2/2 + H^3/6)-v;
df(H) = diff(f,H)
df(H) =
fplot(f)
x0 = 1;
tol = 10^-15;
max = 50;
i = 1;
error = 1;
while (i<max && error>tol)
1
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 1.5962446179749
2 1.5962446179749 1.53116148510226
3 1.53116148510226 1.53011025190358
4 1.53011025190358 1.53010998512821
5 1.53010998512821 1.5301099851282
6 1.5301099851282 1.5301099851282