Professional Documents
Culture Documents
%trapezoid_multi_segments
syms x
fx=5*x^3+3*x^2+x;
a=0;
b=6;
n=3;
h = (b-a)/n;
fa = subs(fx,x,a);
fb = subs (fx,x,b);
fc1 = 0;
for i=1:(n-1)
fc = subs (fx,x,(a+i*h))
fc1 = fc1 + fc;
end
I = (b-a)/(2*n)*(fa+2*fc1+fb)
es = abs((I-1854)/1854)
HASIL;
fc =
54
fc =
372
I=
2046
es =
0.1036
PROGRAM
%metode_simpson1/3_multisegmens
syms x
fx = 5*x^3+3*x^2+x;
a = 0;
b = 6;
n = 6;
h = (b-a)/n;
x0 = 0;
fx0 = subs(fx,x,x0);
xn = b;
fxn = subs(fx,x,xn);
f_genap = 0;
f_ganjil = 0;
for i = 1:(n-1)
if rem (i,2) == 0
fx_genap = subs(fx,x,(x0+i*h));
f_genap = f_genap+fx_genap;
else
fx_ganjil = subs(fx,x,(x0+i*h));
f_ganjil =f_ganjil+fx_ganjil;
end
end
f_genap
f_ganjil
inum = h/3*(fx0+4*f_ganjil+2*f_genap+fxn)
HASIL;
f_genap =
426
f_ganjil =
879
inum =
1854