Problem 43003. Simpsons's rule (but not Homer Simpson)
Solution Stats
Problem Comments

9 Comments
If this problem gains some interest, I'll start trying to post additional problems. My idea is to build a new problem set, for general numerical methods like this.
Great problem along with a very clear description. Looking forward to your addtional problems in numerical analysis.
I've asked Ned how to create a new problem group first. (I don't think if I have that privilege.) Then I plan to establish a few new problem groups for problems like this. Perhaps a numerical methods group, a computational geometry group, others? I hope there will also be some existing problems I can then include in addition to those I will write.
Great idea to create a new problem group! Numerical analysis is definitely good problem group to start with. There are already some numerical integration problems which I have solved on Cody (such as a general integration problem: https://www.mathworks.com/matlabcentral/cody/problems/1031compositetrapezoidalrulefornumericintegration, and a problem dealing with trapezoidal rule: https://www.mathworks.com/matlabcentral/cody/problems/1031compositetrapezoidalrulefornumericintegration). I guess these problems can be included in a numerical analysis group.
Sorry for the wrong link. A general numerical integration problem: https://www.mathworks.com/matlabcentral/cody/problems/1197numericalintegration, and a trapezoidal rule problem: https://www.mathworks.com/matlabcentral/cody/problems/1031compositetrapezoidalrulefornumericintegration. I realize that Cody does not allow users to modify/delete their own comments, which is very inconvenient.
Thanks for the problem links. I'll forward that idea about editing comments to the site developers.
Nice problem, but #7 in the Test Suite needs an assert in it.
There's something I don't understand. The first function I wrote, according to Simpson's rule, passed all tests except #6; here the absolute error was still very small (~1.53e15) but greater than the tolerance, so my first solution failed the test set. Thus I had to add a small correction factor of 1e15. Now the function passes all tests, but I can't understand the error in my implementation.
@Giovanni I had the same problem; the test case is overzealous.
Solution Comments

1 Comment
I used the same formula and failed test 6. I think it's because of the machine error eps. Is that why you had 1e15 at the end?
Problem Recent Solvers30
Suggested Problems

2098 Solvers

1846 Solvers

Solve the set of simultaneous linear equations
359 Solvers

Calculate the Number of Sign Changes in a Row Vector (No Element Is Zero)
445 Solvers

find the surface area of a cube
450 Solvers
More from this Author4
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!