I was recently programing an integral and decided to check how it would work compared to a numerical aproximation. I used Simpson and trapezoid rules. However, my results are several orders of magnitude different. I have attached my code.
Can someone please give me some hindsight on what I am doing wrong?
There are a number of ways to improve on this. Most important error is to not multiply trapezoid heights by step length. The value below is pretty good for an approximation.
I see. Thank you bery much for the information. I am afraid I am not fluent enough in mathematica to propperly understand your proposed aproximation, but I will try to comprehend it.
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