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)
Contents |
[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? —Preceding unsigned comment added by 84.65.170.151 (talk • contribs) 21:47, 2 November 2006
- 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)
- 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)
-
-
-
-
-
- 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)
- OK, if I see it done well I may change my mind. :) Oleg Alexandrov (talk) 04:51, 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)
-
-
-
[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)
[edit] Composite Simpsons's rule
Composite Simpson's rule: The explanation on what n is is not clear, i have tried deriving the equation:
If we say n=3 in the above example
so
or to put it as in the main article:
So, in my opinion, either what n is needs to be carefully defined, or the equation should be changed to be h/6 instead of h/3
--Richtea2007 16:21, 27 April 2007 (UTC)
- In your example, n = 6, as can be seen by comparing the last two of your equations: x0 = a, x1 = (a + b) / 2, …, x5 = (c + d) / 2, x6 = d. I agree that the article did not clearly define n. It used to say that the interval [a,b] is divided in n subintervals, while it is probably clearer to say that it's divided in n / 2 subintervals. I changed that. Thanks for your comment. -- Jitse Niesen (talk) 03:25, 28 April 2007 (UTC)
Although it works both ways, it would be right to take h/6 with n=3, as there are actually 3 subintervals, and the 6 comes from the coefficents 1(f(a))+4(f((a+b)/2)+1(f(b)=6. I don't see a reason to take h/3, as it is h/6 in all the other examples. —Preceding unsigned comment added by 85.103.74.156 (talk) 20:01, 15 May 2008 (UTC)
[edit] Another Simpson's rule...
d = oh! ♥♥ ΜÏΠЄSΓRΘΠ€ ♥♥ slurp me! 20:56, 3 June 2007 (UTC)
Hey sorry to sound like an idiot but are you sure it's not named after Edward Simpson? I think it is Thomas but a lecturer said that it was Edward
Greenharpoon 10:36, 27 June 2007 (UTC)Greenharpoon
[edit] Python example bug?
The python example includes the line:
h3 = abs(b - a) / 6.0
However, the function given uses (b - a)/6, not |b-a|/6. I believe the Python code is simply wrong, but am I missing something? -Ahruman (talk) 14:24, 28 February 2008 (UTC)