HP 50g Romberg Integration
|
03-31-2014, 03:28 PM
Post: #1
|
|||
|
|||
HP 50g Romberg Integration
Hello friends,
because of educational reasons I've written a program for the HP 50g in UserRpl. In some papers of that kind of numerical integration is written, that the Richardson extrapolation can be easily done with a table formed as a triangle. The only nice feature of my program is, that it doesn't need such a table, it only works with a list with N elements and this list was the input for the DOSUBS command, which seems to me very practical and useful. The program isn't optimized in performance or memory. Enjoy it. I included it as a text-file, because I didn't succeed to include it as a well formatted program text. ROMB.txt (Size: 1.99 KB / Downloads: 39) |
|||
04-01-2014, 04:02 AM
Post: #2
|
|||
|
|||
RE: HP 50g Romberg Integration | |||
04-01-2014, 05:24 AM
Post: #3
|
|||
|
|||
RE: HP 50g Romberg Integration
Hello Gerson,
first of all, I tried to include with the tags my program, but it doesn't works, the format was spoiled. Second the example: The function to integrate is defined in 'Y' (I forgot this to mention in my first post, sorry) (here: << INV >> for 1/x) Input: 4. 2. 1. 4 is iteration depth 2 upper limit 1 lower limit output: 6,9412E-1 { 6,9444E-1 6,9325E-1 6,9315E-1 } { 6,9317E-1 6,9315E-1 } { 6,9315E-1 } 6,9315E-1 First value: result from pure trapezoid rule in total Last value: with Richardson extrapolation the three lists in between are the "table" for the Richardson extrapolation (this outputs results every DOSUBS call). |
|||
04-02-2014, 01:05 PM
Post: #4
|
|||
|
|||
RE: HP 50g Romberg Integration
(04-01-2014 05:24 AM)peacecalc Wrote: first of all, I tried to include with the tags my program, but it doesn't works, the format was spoiled. Everything works fine. The only exception are the comments that will not line up because you used tab characters. Which is always a bad idea since there is no standard that defines how many blanks will equal one tab. That's why you should always use blanks instead of tabs for such applications. Without tabs everything looks fine: Code: %%HP: T(3)A(R)F(,); Dieter |
|||
04-02-2014, 05:21 PM
Post: #5
|
|||
|
|||
RE: HP 50g Romberg Integration
Hello Dieter,
Quote:The only exception are the comments that will not line up because you used tab characters. That's the advice I need to avoid such a situation in future, thank you! And many thanks for deleting all the tabs and filling with spaces in my original text. Greetings peaceglue |
|||
04-02-2014, 05:32 PM
Post: #6
|
|||
|
|||
RE: HP 50g Romberg Integration | |||
04-02-2014, 10:02 PM
(This post was last modified: 04-02-2014 10:16 PM by C.Ret.)
Post: #7
|
|||
|
|||
RE: HP 50g Romberg Integration
I just recover from an old notepad the ROMBERG INTEGRATION programm I wrote for my HP-28S a few ago ...
It's regular RPL code, so, it will also run on any "new" RPL systems such as the HP-50g ! Code:
I just test it with the example \[\int_{-1}^{2} \frac{2}{4t^2+1}dt\] from Wikipedia - Méthode de Romberg : Code:
To see intermediate results simply press [ shift ][ LAST ], the R table is bring back in the stack : Code:
|
|||
04-03-2014, 07:11 PM
Post: #8
|
|||
|
|||
RE: HP 50g Romberg Integration
Hello Thomas,
thank you for sharing your code. The code seems to me more clearly and its output is nicer formatted than my program. Nevertheless I'm tried to make a code, which doesn't use exponential operator "^" and this is replaced by multiplication and division. But this costs more use of the storage operations. Greetings peacecalc |
|||
04-03-2014, 09:51 PM
(This post was last modified: 04-03-2014 09:54 PM by Gerson W. Barbosa.)
Post: #9
|
|||
|
|||
RE: HP 50g Romberg Integration
(04-02-2014 10:02 PM)C.Ret Wrote: I just recover from an old notepad the ROMBERG INTEGRATION programm I wrote for my HP-28S a few ago ... As you said, your code runs with no modification on the HP 50g: Code:
A test: Code:
The buit-in integrator, OTOH: Code:
The actual result is 0.577215664902 ( « 1. Psi NEG» ). I understand your program and peacecalc's are not meant to replace the built-in integrator, but I've read the legacy algorithm is not the best one around (it's only there because it's been tried and tested since the HP-34C, the Saturn code since the HP-71B, I think). Does anyone know of alternative programs that have better performance on this example, that is, faster and more accurate? Thanks! Gerson. |
|||
04-04-2014, 06:22 AM
Post: #10
|
|||
|
|||
RE: HP 50g Romberg Integration
(04-02-2014 05:32 PM)Thomas Klemm Wrote: That's easy in a decent editor like emacs: Thanks! I have been using Emacs on and off since the 1980s and there are still plenty of tricks for me to learn. This is a particularly good one! It ain't OVER 'till it's 2 PICK |
|||
04-04-2014, 09:42 AM
Post: #11
|
|||
|
|||
RE: HP 50g Romberg Integration
(04-04-2014 06:22 AM)HP67 Wrote: This is a particularly good one! Quote:Oh yeah! Good ol' C-x M-c M-butterfly ... |
|||
04-04-2014, 06:25 PM
Post: #12
|
|||
|
|||
RE: HP 50g Romberg Integration
Hello Gershon,
Quote:but I've read the legacy algorithm is not the best one around (it's only there because it's been tried and tested since the HP-34C, the Saturn code since the HP-71B, I think). That maybe is true, but it is not fair, because when you use the Romberg method with the iteration depth of 20, the program have to calculate 2^20 - 1 function values, this are at least over a million, no wonder about the time you have to wait... I don't know wether a side effect occures: so many additions can cause a summation error??? Did you try the lower iteration depths and how the results behavier is? And your test function is a hard piece of cake because of its limits at 0 and 1, both are divergent. Greetings peacecalc |
|||
04-04-2014, 07:40 PM
Post: #13
|
|||
|
|||
RE: HP 50g Romberg Integration
(04-04-2014 06:25 PM)peacecalc Wrote:Quote:but I've read the legacy algorithm is not the best one around (it's only there because it's been tried and tested since the HP-34C, the Saturn code since the HP-71B, I think). Yes, I tried successively 6, 8, 10 and noticed the exponential growth of the running times while the results would be improved only by a little. Without analyzing the code, this story soon crossed my mind :-) Wheat and chessboard problem (04-04-2014 06:25 PM)peacecalc Wrote: And your test function is a hard piece of cake because of its limits at 0 and 1, both are divergent. I'll try integrating it from 0 to 1/e then from 1/e to 1 and see if the results get better. In 1982 I wrote what was perhaps the shortest numerical integration program ever, using midpoint rectangles: it fit in 30 steps, on an algebraic calculator. Totally useless though, as only the few built-in functions could be integrated, to only a few decimal places: http://www.hpmuseum.org/cgi-sys/cgiwrap/...ead=216249 (Message #11) Regards, Gerson. |
|||
04-04-2014, 08:23 PM
Post: #14
|
|||
|
|||
RE: HP 50g Romberg Integration
(04-03-2014 09:51 PM)Gerson W. Barbosa Wrote: The actual result is 0.577215664902 ( « 1. Psi NEG» ).Did you try the substitution \(u=log(x)\) leading to \(\int_{0}^{\infty}-\frac{\log(u)}{e^u}du\)? Or have you started with this and tried to avoid the calculation of an improper integral? Cheers Thomas |
|||
04-04-2014, 09:12 PM
Post: #15
|
|||
|
|||
RE: HP 50g Romberg Integration
(04-04-2014 08:23 PM)Thomas Klemm Wrote:(04-03-2014 09:51 PM)Gerson W. Barbosa Wrote: The actual result is 0.577215664902 ( « 1. Psi NEG» ).Did you try the substitution \(u=log(x)\) leading to \(\int_{0}^{\infty}-\frac{\log(u)}{e^u}du\)? Or have you started with this and tried to avoid the calculation of an improper integral? Hi Thomas, No, I just used the integral in the form it was presented by Valentin, at the end of an old thread I started: http://www.hpmuseum.org/cgi-sys/cgiwrap/...ead=109056 There are a few mistakes in the post, hopefully mostly linguistic ones. I intended to revised it, but I haven't done it yet. Also, at least one link is not working anymore. Cheers, Gerson. |
|||
« Next Oldest | Next Newest »
|
User(s) browsing this thread: 6 Guest(s)