Talk:Numerical integration: Difference between revisions

Undo revision 90958 by Paddy3118 (Talk) I just read the edit comment by Short Circuit.
(Undo revision 90958 by Paddy3118 (Talk) I just read the edit comment by Short Circuit.)
Line 10:
::A correct implementation in C of the mid rect can be seen at [[http://en.wikipedia.org/wiki/Rectangle_method]]. The important thing to notice is that the interval (h in most of the rosettacode examples) is divided in half to find the middle point at which to evaluate the function (the i * 0.5 in the middle). If you're not dividing the interval in half, you cannot determine the value of the function at that point. Averaging the beginning and ending function values of the rectangle is the same number only if the function is linear, because doing that (and multiplying by the width) is simply another way of calculating the area of a right trapezoid. For good "pseudo code" that isn't so pseudo, I suggest the Algol 68 example. Notice how it has h/2 in the mid rect to get to the middle of the rectangle. The trapezium is careful to weight the inner points twice as much as the endpoints. (But don't copy the right rect, I think it's wrong to subtract h from the end position, because we already added h to the start position, and that leaves out one of the rectangles. Maybe use the Common Lisp one for that, since it gets it right.) --[[User:TimToady|TimToady]] 03:18, 12 September 2010 (UTC)
:::On closer inspection, the Algol code was wrong too, so I just fixed it so you'd have something to look at. But you really need to learn to visualize the geometry of it, I think.--[[User:TimToady|TimToady]] 03:40, 12 September 2010 (UTC)
 
==Do we need the other two tests?==
What extra do we gain. Can't we compare accuracy/correct implementation with just the first two? --[[User:Paddy3118|Paddy3118]] 04:29, 12 September 2010 (UTC)
Anonymous user