The solution of the problem it is 1.732400451459101 for Simpson 1/3 Rule. Instead the solution that the program give me is 1.73239801
Can anyone help me out? Thanks in advance.
clc
clear
close all
f = @(x) sin(x);
a = 0.1;
g = a;
b = 2.4;
k = 19;
n = 2*k;
S = 0;
h = (b-a)/n;
for i=1:k
S=S+(h/3)*(f(a)+4*f(a+h)+f(a+2*h));
a=a+2*h;
end
fprintf('La integral se aproxima a: %0.8f \n',S)
syms x
y = sin(x);
InT = int(y,g,b);
InT = double(InT)