Simpson's 1/3 rule on the 50g - 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: Simpson's 1/3 rule on the 50g (/thread-17829.html) |
Simpson's 1/3 rule on the 50g - EngineerX - 12-19-2021 01:16 PM Hello, I would like to implement the following on the 50g in RPL but don't know how. Seems simple but I am new to the language. I have a feeling the Prime would be a better choice for me who has some experience with Matlab, but the thing is that I prefer the 50g for nostalgic reasons, although I never really learned more than the trivial. I would like to be able to calculate the area under a curve using Simpson's 1/3 rule for a given set of data. For exemple: For x = {x0 x1 x2 x3 ... xN} where N is an even number. Compute A = h/3*(y0 + 4*y1 + 2*y2 + 4*y3 + 2*y4 + 4*y5 +...+ yN) Very much appreciated. RE: Simpson's 1/3 rule on the 50g - Wes Loewer - 12-19-2021 03:43 PM I dug through my old files an found a program that I wrote some 15+ years ago. Looking at it now, I might have done this differently, but here it is, warts and all. To understand the code fully, look up the syntax of the Σ and the | (where) commands. Code:
Feel free to ask if there is anything that is not clear. RE: Simpson's 1/3 rule on the 50g - Juan14 - 12-20-2021 01:45 AM This program uses GETI to get trough each element of the list, flag -64 is checked in the WHILE loop, it gets set when the index reach the end of the list. In the loop, a 4 or 2 is generated with the help of MOD. The program requires h in level 2: and the list of values in level 1: « 1 GETI UNROT WHILE GETI -64 FC? REPEAT OVER 2 MOD 2 * 2 + * 4 ROLL + UNROT END NIP NIP + * 3 / » RE: Simpson's 1/3 rule on the 50g - EngineerX - 12-20-2021 03:23 AM Thank you for the inputs. Simple and elegant. I would have used many more commands in attempt to emulate what Matlab does. |