Simpson for odd number of subintervals
Show older comments
Hello I want to know whether it is possible to use simpson rule for the case of odd number of subintervals, if yes, How ?! Thank you all !
Answers (1)
David Goodmanson
on 30 Dec 2017
Edited: David Goodmanson
on 30 Dec 2017
Hi Djamel.
One approach is to use the usual Simpson's rule for all but three (consecutive) intervals and use Simpson's 3/8 rule for what is left over. Assume n points 1:n with n even, so there are an odd number of intervals. You can use the usual Simpson's rule on points 1 to n-3 (even number of intervals) and the 3/8 rule at the end. For equally spaced intervals of width h,
Integral = (3*h/8)*(f(n-3) + 3*f(n-2) + 3*f(n-1) + f(n))
Or you could put the 3/8 rule section at the beginning, or somewhere in the middle.
4 Comments
Djamel HAMMOUDI
on 30 Dec 2017
David Goodmanson
on 30 Dec 2017
Hi Djamel,
I don't think it's as good as using the 3/8 rule on the last three intervals. The error will quite likely be larger using trap, although it may still be acceptable.
Djamel HAMMOUDI
on 31 Dec 2017
Pratik Ananda Koli
on 10 Jul 2023
But n is 7
Categories
Find more on Numerical Integration and Differential Equations in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!