Talk:Simpson's rule

From Wikipedia, the free encyclopedia

I put the matlab code in there because it WAS a different implementation. The python code is for the simpson's rule and the matlab code was for the composite simpsons rule. Two different things, and two very different implementations I personally think there should be a different page for each, maybe when they get a bit longer. Epachamo 22:53, 3 April 2006 (UTC)

         thanks I'm glad you did it helps for my emth lab;)Randomkeys 07:12, 31 July 2006 (UTC)

[edit] History of Simpson's rule

It would be nice to have a section on the history of Simpson's rule, if good references can be found. There's a little bit at Thomas Simpson. 165.189.91.148 17:31, 23 October 2006 (UTC)

[edit] Alternative method of finding composite Simpson's rule

There is an alternative method of finding the composite Simpson's rule - it can be calculated as a weighted average of the midpoint and trapezium rule. If you decide to use x strips for the Simpson's rule, then you estimate the integration using the midpoint and trapezium rule using x/2 strips. You can then find the Simpson's rule result by (2*M + T)/3 where M is the midpoint rule result and T is the trapezium rule result. Perhaps this could be added? —The preceding unsigned comment was added by 84.65.170.151 (talk • contribs) 21:47, 2 November 2006 (UTC)

Hmmm. That's a rather mysterious derivation; where do the weights come from, and why would you expect that the resulting method is any better. On the other hand, you're right that Simpson = (2*M + T)/3; I guess one could add a statement to that effect. -- Jitse Niesen (talk) 04:16, 3 November 2006 (UTC)
Indeed, there is even a third way: One simply sets up a system of equations as follows: You start with a rule saying Q(f) = a0*f(a) + a1*f((a+b)/2) + a2*f(b), and find the coefficients {ai} by solving Q(f) = a*x^2 + b*x + c. This thus ensures that the quadrature rule is exact for polynomials up to and including degree 2, which of course means it must be Simpson's rule. Grokmoo 19:48, 3 November 2006 (UTC)
If you look at the error of the midpoint and trapezium rule, then the error reduces at the same rate. However, the midpoint rule normally has about half of the error of the trapezium rule (with the same number of strips), so we weight the two results accordingly.Mike Williamson 22:26, 3 November 2006 (UTC)
Those are both quite natural ways to arrive at Simpson's rule, and I think that they would make good additions to the article. -- Jitse Niesen (talk) 02:05, 4 November 2006 (UTC)
I removed that derivation. By the above, the weights should be 2 and -1, while in reality they are 2 and 1. The text was not rigurous enough, as it is was not clear what exactly the error was or why. And I am not sure we need such a derivation anway. Oleg Alexandrov (talk) 03:42, 6 November 2006 (UTC)
Why do you think we don't need this derivation (done properly, of course)? I think it's quite nice to show that Simpson's rule can be derived in multiple ways. -- Jitse Niesen (talk) 04:48, 6 November 2006 (UTC)
OK, if I see it done well I may change my mind. :) Oleg Alexandrov (talk) 04:51, 6 November 2006 (UTC)
This is what I had in mind. I wasn't going to include the error of midpoint and trapezium, but since Oleg asked for it … Anyway, I'm less sure now that it's a good addition. It also is a bit ORish. -- Jitse Niesen (talk) 07:49, 11 November 2006 (UTC)

[edit] matlab implementation

I changed the article earlier to comment that the matlab function "quad" does composite simpson's rule, and my change was reverted. I don't necessarily disagree with the revert (this isn't a matlab tutorial), but I don't see why the matlab and python code is in the article in the first place then. Why not just write psuedo-code? The only purpose of matlab or python code is so that someone can easily implement it -- in which case, you would implement the builtin matlab function.

Hence, I say keep the coding to high level psuedo-code. Maybe there's a wikipedia-wide convention on this, but I say if wikipedia is more than a user's manual for various software, then we should keep algorithms and coding separate. Lavaka 20:40, 4 March 2007 (UTC)

Implementing both the Simpson's rule and its composite version in pseudocode is a good idea I think, if somebody's willing to do the work. Oleg Alexandrov (talk) 03:47, 5 March 2007 (UTC)
In my opinion, it is a bit silly to have implementations in different languages in the same article, because that makes it hard to compare them. Generally, I would agree with using pseudocode. Having a (pseudo)implementation helps when trying to understand algorithm. However, in this case the algorithm is so simple that it can be described in one formula, so I don't see what an algorithm would add to the article. Therefore, I think we should just delete both implementations.
I assume you already know this, but Matlab's quad does more than the composite Simpson's rule as described in this article. It automatically adapts the lengths of the subintervals. -- Jitse Niesen (talk) 04:23, 10 March 2007 (UTC)