Compact Simpson's 3/8 Rule(??) - Printable Version +- HP Forums (https://www.hpmuseum.org/forum) +-- Forum: HP Calculators (and very old HP Computers) (/forum-3.html) +--- Forum: General Forum (/forum-4.html) +--- Thread: Compact Simpson's 3/8 Rule(??) (/thread-5326.html) |
Compact Simpson's 3/8 Rule(??) - Namir - 12-13-2015 02:26 PM Here is the pseudo-code 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 pseudo-code 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=B-h. 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 RE: Compact Simpson's 3/8 Rule(??) - Dieter - 12-13-2015 03:38 PM (12-13-2015 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 for-next-loops 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 RE: Compact Simpson's 3/8 Rule(??) - rprosperi - 12-13-2015 04:05 PM (12-13-2015 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 ? RE: Compact Simpson's 3/8 Rule(??) - Dieter - 12-13-2015 04:39 PM (12-13-2015 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 four-digit 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 RE: Compact Simpson's 3/8 Rule(??) - Namir - 12-13-2015 05:05 PM (12-13-2015 03:38 PM)Dieter Wrote:(12-13-2015 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 pseudo-code version looks simple and very nice. RE: Compact Simpson's 3/8 Rule(??) - walter b - 12-13-2015 07:32 PM 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:-) RE: Compact Simpson's 3/8 Rule(??) - Dieter - 12-13-2015 07:45 PM (12-13-2015 05:05 PM)Namir Wrote: Your pseudo-code version looks simple and very nice. Thank you. Actually it isn't pseudo-code but VBA – directly copied from a test version I tried in Excel. ;-) Dieter RE: Compact Simpson's 3/8 Rule(??) - rprosperi - 12-13-2015 08:09 PM (12-13-2015 04:39 PM)Dieter Wrote:(12-13-2015 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 place-holder number to shift the round-off. But it just begged the question... and I suppose I rose to the bait!! (12-13-2015 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! RE: Compact Simpson's 3/8 Rule(??) - Dieter - 12-14-2015 08:13 PM (12-13-2015 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 RE: Compact Simpson's 3/8 Rule(??) - rprosperi - 12-14-2015 08:44 PM (12-14-2015 08:13 PM)Dieter Wrote:(12-13-2015 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 odd-looking number. RE: Compact Simpson's 3/8 Rule(??) - Dieter - 12-18-2015 09:19 PM (12-14-2015 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 odd-looking number. Since the brand is pronounced "47–11" it even sounds more odd in English than in German. ;-) Dieter RE: Compact Simpson's 3/8 Rule(??) - Thomas Klemm - 12-18-2015 11:58 PM (12-14-2015 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 RE: Compact Simpson's 3/8 Rule(??) - rprosperi - 12-19-2015 01:51 AM (12-18-2015 11:58 PM)Thomas Klemm Wrote:(12-14-2015 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? RE: Compact Simpson's 3/8 Rule(??) - walter b - 12-19-2015 07:39 AM 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. RE: Compact Simpson's 3/8 Rule(??) - Dieter - 12-19-2015 08:53 AM (12-19-2015 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). (12-19-2015 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 below-standard) and widespread. As this is a calculator forum: think TI-30. ;-) Dieter RE: Compact Simpson's 3/8 Rule(??) - rprosperi - 12-19-2015 05:24 PM (12-19-2015 08:53 AM)Dieter Wrote:(12-19-2015 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! RE: Compact Simpson's 3/8 Rule(??) - Csaba Tizedes - 09-25-2019 06:47 PM (12-13-2015 05:05 PM)Namir Wrote: Or maybe: Code: h = (b - a) / n Csaba RE: Compact Simpson's 3/8 Rule(??) - toml_12953 - 09-25-2019 10:02 PM (12-13-2015 04:39 PM)Dieter Wrote:(12-13-2015 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? RE: Compact Simpson's 3/8 Rule(??) - Albert Chan - 10-04-2019 06:20 PM (09-25-2019 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 |