Jaime,
your approach is basically correct. But you give the number of a point to the gaussian and not the x-value, which is in fact
PuntosEnsayo[[i]]
and not i. i is the number of your x-value. And you start with i =0, which is problematic for Tables.
Try in your code
For[i = 1, i < numero, i++,
valorNumerico =
valorNumerico +
step ((1/2)*(gausiana[PuntosEnsayo[[i]]] +
gausiana[PuntosEnsayo[[i + 1]]]))];
For[i = 1, i < numero, i++,
valorNumericoSimpson =
valorNumericoSimpson +
step (1/6)*(gausiana[PuntosEnsayo[[i]]] +
gausiana[PuntosEnsayo[[i + 1]]] +
4*gausiana[PuntosEnsayoMedios[[i]]])];
valorNumerico
valorNumericoSimpson
Daniel's approach is Mathematica-like (avoid Do's, For's and so on if possible) and elegant.
He applies gausiana to each x-value, meaning each value in PuntosEnsayo. This is done with the Map-command. Then he adds all these values ( Total ) and finally multiplies with your step-width.
You can achieve this as well with
step*Total[gausiana /@ PuntosEnsayo]
neglecting the contributions at the ends of the interval
Attachments: