> From: John Randall
> 
> Sherlock, Ric wrote:
> > While working on this Rosetta Code task:
> > "http://rosettacode.org/wiki/Numerical_Integration";
> > I came across the following question regarding the base library
> > implementation of Simpson's Rule.
> 
> > I'm wondering whether the simpson conjunction in 'math/misc/integrat'
> is
> > "correct" as is or whether it should be changed to include "steps=.
> > +:steps" so that it gives the same answer as simpsonWK given the same
> > inputs?
> 
> This depends as to whether you are specifying panes or subintervals.
> Rosetta Code uses n panes and 2n subintervals, simpsonBL and simpsonJR
> use
> n subintervals and n%2 panes (so n necessarily has to be even).  You
> can
> argue it either way.  Perhaps subintervals make the most sense when
> comparing methods, since you then have the same number of functional
> evaluations.

This answers my question nicely thanks. The point about specifying subintervals 
when comparing methods makes sense.
 
> The Rosetta Code specification does not bring out the coefficients for
> Simpson's rule particularly well: simpsonBL and simpsonJR do.  I have
> written an explanation of where the coefficients come from at
> 
> http://www.jsoftware.com/jwiki/JohnRandall/Quadrature

Nice write up - perhaps it would be worthwhile re-homing it in the Essays 
section on the wiki?

I agree that the current solution on Rosetta Code isn't the most mathematically 
illuminating, or the most efficient, however it is terse, while not appearing 
too complex, and matches many of the other implementations both in terms of 
results and flexibility. Hopefully these characteristics pique the interest of 
non-Jers.

I was thinking of adding either simpsonJR or simpsonBL as a better performing 
variant once I'd resolved my question.

----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to