matlab code for simpsons rule and midpoints rule


muq08
11-18-2009, 01:20 PM
I have to write a code for this in matlab and not sure how to....any help would be good:

Write a code which implements both the midpoint rule and Simpson's rule (with weights 1 4 2 4 ... 2 4 1) for evaluating integrals.

Plot the log of the error as a function of the log of h (the step size) when approximating I = integral[pi ->0] sin(x) and I2 = integral [2 -> 0] x

MPD78
11-18-2009, 01:54 PM
Hello,

I have MatLab 7.0 but am not that great at using it yet. In order to get a good feel for it and to try to overcome the learning curve, I have used this website for help.

http://numericalmethods.eng.usf.edu/

There are examples of the Simpsons 1/3 Rule there and numerous other integration techniques.

Thanks
Matt