The attached file is a function that numerically integrates any given anonymous function (fx), using Simpson's rule, which is more accurate than the trapeziodal rule (accuracy: dx^4), it includes an explicit help
integrate the function 1/x between 1 and 2
using 30 intervals gives as a result 0.693147 ( the exact value is the same up to 6 places)
the m-function call is:
where fx=@x 1./x for the example above, the rest of the inputs are asked for on-line
Log in to post a comment.