Compact Simpson's 3/8 Rule(??)

12132015, 02:26 PM
(This post was last modified: 12132015 03:07 PM by Namir.)
Post: #1




Compact Simpson's 3/8 Rule(??)
Here is the pseudocode for a compact version of Simpson's 3/8 Rule. This rule divides the integral range [A, B] into N (=3m where m>1) divisions. The area is calculated using:
area = 3*h/8*(f(A) + 3*f(x(1)) + 3*f(x(2)) + 2*f(x(3)) + ... + f(B)) The following pseudocode is able to apply the sequence of coefficient values of 3,3, and 2 for every three points, starting with x=A+h and until X=Bh. Code: Give f(x), interval [A, B] and N divisions where N=3m for any m>1. The variable I cycles between 1, 2, and 3. The coefficient C is calculated using a special (and simple) quadratic equation to yield 3, 3, and 2 for I=1, 2, and 3. Here is an alternate form that uses memory registers (suitable for calculators) Code: Give f(x), interval [A, B] and N divisions where N=3m for any m>1. The main point in this thread and the one about a compact (basic) Simpson's Rule is to perform one summation of f(x) per loop iteration. Enjoy! Namir 

12132015, 03:38 PM
(This post was last modified: 12132015 03:50 PM by Dieter.)
Post: #2




RE: Compact Simpson's 3/8 Rule(??)
(12132015 02:26 PM)Namir Wrote: The variable I cycles between 1, 2, and 3. The coefficient C is calculated using a special (and simple) quadratic equation to yield 3, 3, and 2 for I=1, 2, and 3. Waaaayyyyyy too complicated. ;) Instead of i=1, 2, 3 make it 0, 1, 2 and get c = 2 + sign(i). This doesn't even require two separate variables i and n (cf. second code sample). Code: h = (b  a) / n Or, if you do not like fornextloops and prefer while/repeat: Code: h = (b  a) / n Those who are a bit paranoid about floating point arithmetics and exact zero results may replace the exit condition with something like Loop Until n+4711 = 4711. ;) Dieter 

12132015, 04:05 PM
Post: #3




RE: Compact Simpson's 3/8 Rule(??)
(12132015 03:38 PM)Dieter Wrote: Those who are a bit paranoid about floating point arithmetics and exact zero results may replace the exit condition with something like Loop Until n+4711 = 4711. ;) OK, I just gotta ask  why 4711 ? Bob Prosperi 

12132015, 04:39 PM
(This post was last modified: 12132015 07:50 PM by Dieter.)
Post: #4




RE: Compact Simpson's 3/8 Rule(??)
(12132015 04:05 PM)rprosperi Wrote: OK, I just gotta ask  why 4711 ? That's why. ;) Click on "history" and the year 1794 where the origin of this number is explained. Of course you may just as well use any other three or fourdigit integer. While we're at it, here's a quick and dirty version for the HP41 series. It implements yet another way of generating the 3–3–2 sequence. Code: 01 LBL"SIMP38" Dieter 

12132015, 05:05 PM
Post: #5




RE: Compact Simpson's 3/8 Rule(??)
(12132015 03:38 PM)Dieter Wrote:(12132015 02:26 PM)Namir Wrote: The variable I cycles between 1, 2, and 3. The coefficient C is calculated using a special (and simple) quadratic equation to yield 3, 3, and 2 for I=1, 2, and 3. I like your FOR loop and the use of the SIGN function!! Now we have a compact implementation that performs one function summation per iteration and with minimum calculations. Your pseudocode version looks simple and very nice. 

12132015, 07:32 PM
Post: #6




RE: Compact Simpson's 3/8 Rule(??)
It's quite common in Germany to use this for an arbitrary (random) number if you don't want to use letters. When this was used, you can continue with 4712 etc. Yes, we've got some special habits, too.
d:) 

12132015, 07:45 PM
Post: #7




RE: Compact Simpson's 3/8 Rule(??)  
12132015, 08:09 PM
Post: #8




RE: Compact Simpson's 3/8 Rule(??)
(12132015 04:39 PM)Dieter Wrote:(12132015 04:05 PM)rprosperi Wrote: OK, I just gotta ask  why 4711 ? I shall go and read that, though I imagined it was just a placeholder number to shift the roundoff. But it just begged the question... and I suppose I rose to the bait!! (12132015 07:32 PM)walter b Wrote: It's quite common in Germany to use this for an arbitrary (random) number if you don't want to use letters. When this was used, you can continue with 4712 etc. Yes, we've got some special habits, too. Hopefully the referenced article explains the source of this 'magic' number. Typically, these explanations are nice stories, but not always the real truth behind how these things have come down though history. The real stories are probably much less interesting... Thanks to you both! Bob Prosperi 

12142015, 08:13 PM
Post: #9




RE: Compact Simpson's 3/8 Rule(??)
(12132015 08:09 PM)rprosperi Wrote: Hopefully the referenced article explains the source of this 'magic' number. Typically, these explanations are nice stories, but not always the real truth behind how these things have come down though history. The real stories are probably much less interesting... Well, in this case the story is said to be true. ;) If you haven't read the referenced 4711 website yet, Wikipedia also knows the story behind this number in its respective arcticle. You'll find the story of one of the world's most traditional fragrances and the 4711 brand, especially for Eau de Cologne, which was named after the manufacturer's original location at Glockengasse 4711 in Cologne. The origins of this number again are explained in the section "house number 4711". In Germany "4711" has a brand awareness of 80%, and I assume between 90 and 100% in the older generation. Over the decades this number has become a kind of synonym for any arbitrary number, which is the way it was used here. Dieter 

12142015, 08:44 PM
Post: #10




RE: Compact Simpson's 3/8 Rule(??)
(12142015 08:13 PM)Dieter Wrote:(12132015 08:09 PM)rprosperi Wrote: Hopefully the referenced article explains the source of this 'magic' number. Typically, these explanations are nice stories, but not always the real truth behind how these things have come down though history. The real stories are probably much less interesting... Thanks for the additional comments. I did go the site you listed and read the history. Seems strange I've never heard of this brand of cologne; though hardly an expert or anything, I have spent many occasions having perfumes/colognes recommended and don't recall this one. Perhaps I liked other brands and only recall the ones I purchased. Wikipedia has quite a detailed history! Astounding someone researched that so thoroughly. Any idea how something so well recognized by almost all folks ended up becoming a synonym for an arbitrary number? Seems an odd evolution, though it is a rather oddlooking number. Bob Prosperi 

12182015, 09:19 PM
Post: #11




RE: Compact Simpson's 3/8 Rule(??)
(12142015 08:44 PM)rprosperi Wrote: Any idea how something so well recognized by almost all folks ended up becoming a synonym for an arbitrary number? Seems an odd evolution, though it is a rather oddlooking number. Since the brand is pronounced "47–11" it even sounds more odd in English than in German. ;) Dieter 

12182015, 11:58 PM
Post: #12




RE: Compact Simpson's 3/8 Rule(??)
(12142015 08:44 PM)rprosperi Wrote: Any idea how something so well recognized by almost all folks ended up becoming a synonym for an arbitrary number? It's not the only magic number in use. Cf. 08/15. Cheers Thomas 

12192015, 01:51 AM
Post: #13




RE: Compact Simpson's 3/8 Rule(??)
(12182015 11:58 PM)Thomas Klemm Wrote:(12142015 08:44 PM)rprosperi Wrote: Any idea how something so well recognized by almost all folks ended up becoming a synonym for an arbitrary number? There doesn't spear to be an English version of this page. Oddly, when I saw your link, my thought was "the machine gun?  nah, can't be..." so I was a bit surprised upon seeing the gun when I go there. Is "08/15" used to mean a derived or improved version, or something similar? Bob Prosperi 

12192015, 07:39 AM
(This post was last modified: 12192015 10:32 PM by walter b.)
Post: #14




RE: Compact Simpson's 3/8 Rule(??)
AFAIK without the net, it was the standard German rifle in WWI.
d:/ Edit: Just checked: it was a "light machine gun" in WWI. Sorry for my ignorance. 

12192015, 08:53 AM
Post: #15




RE: Compact Simpson's 3/8 Rule(??)
(12192015 01:51 AM)rprosperi Wrote: There doesn't spear to be an English version of this page. Oddly, when I saw your link, my thought was "the machine gun?  nah, can't be..." so I was a bit surprised upon seeing the gun when I go there. That's exactly what this number originally referred to: it's the model number which stands for the year of construction (1908 resp. 1915). (12192015 01:51 AM)rprosperi Wrote: Is "08/15" used to mean a derived or improved version, or something similar? The "08/15" was a common piece of equipment with a rather modest reputation among its users. And this is what that number stands for today: if something is said to be "08/15" it is something not very sophisticated or special, but standard (or even belowstandard) and widespread. As this is a calculator forum: think TI30. ;) Dieter 

12192015, 05:24 PM
Post: #16




RE: Compact Simpson's 3/8 Rule(??)
(12192015 08:53 AM)Dieter Wrote:(12192015 01:51 AM)rprosperi Wrote: There doesn't spear to be an English version of this page. Oddly, when I saw your link, my thought was "the machine gun?  nah, can't be..." so I was a bit surprised upon seeing the gun when I go there. Thanks for clarifying Dieter. I've not heard this term before, but have plenty of reasons to use it now. Your example is a perfect one! Bob Prosperi 

09252019, 06:47 PM
Post: #17




RE: Compact Simpson's 3/8 Rule(??)
(12132015 05:05 PM)Namir Wrote: Or maybe: Code: h = (b  a) / n Csaba 

09252019, 10:02 PM
Post: #18




RE: Compact Simpson's 3/8 Rule(??)
(12132015 04:39 PM)Dieter Wrote:(12132015 04:05 PM)rprosperi Wrote: OK, I just gotta ask  why 4711 ? I went there and still couldn't figure out the significance of that particular number. Why not 4712? 4709? Tom L Cui bono? 

10042019, 06:20 PM
Post: #19




RE: Compact Simpson's 3/8 Rule(??)
(09252019 06:47 PM)Csaba Tizedes Wrote: I don't think this work. We assumed n divisible by 3, and put a weight of 1 (3 3 2) ... (3 3 2) 3 3 1 However, above generate weight of 1 (3 3 2) ... (3 3 2) 0 0 1 You could also pull the (2*, 3*, 3*) from inside the loop, and scale it all in 1 step. Code: h = (b  a) / n 

« Next Oldest  Next Newest »

User(s) browsing this thread: 2 Guest(s)