Simpson's 1/3 rule on the 50g
|
12-19-2021, 01:16 PM
Post: #1
|
|||
|
|||
Simpson's 1/3 rule on the 50g
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. |
|||
12-19-2021, 03:43 PM
Post: #2
|
|||
|
|||
RE: Simpson's 1/3 rule on the 50g
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. |
|||
12-20-2021, 01:45 AM
Post: #3
|
|||
|
|||
RE: Simpson's 1/3 rule on the 50g
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 / » |
|||
12-20-2021, 03:23 AM
(This post was last modified: 12-20-2021 03:30 AM by EngineerX.)
Post: #4
|
|||
|
|||
RE: Simpson's 1/3 rule on the 50g
Thank you for the inputs. Simple and elegant. I would have used many more commands in attempt to emulate what Matlab does.
|
|||
« Next Oldest | Next Newest »
|
User(s) browsing this thread: 1 Guest(s)