HP Forums
HP50g Using library functions in programs - 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: HP50g Using library functions in programs (/thread-14089.html)



HP50g Using library functions in programs - erazor - 12-02-2019 10:46 AM

Hi,

For some problems I'm using my HP50g with the LongFloat library. For repeated things I wanted to do a User-RPL program using this libraries functions.
But I found nothing that this is even possible.
Is it possible using library functions in calculator programs with User-RPL or maybe System-RPL?


RE: HP50g Using library functions in programs - Joe Horn - 12-02-2019 01:00 PM

Yes, you can use any of LongFloat's commands in your programs exactly as if they were built-in User-RPL functions. That's one of the powerful things that libraries do: they extend the built-in RPL command set. If you have any trouble using particular LongFloat commands in a User-RPL program, just post here what you wanted to do (please be specific), and how you attempted to do it (please be specific), and what error(s) occurred, so that we can help you.


RE: HP50g Using library functions in programs - erazor - 12-04-2019 06:23 AM

I had some sophisticated calling procedure in mind where I just had to use the library soft menu to select the functions. Thanks for the hint.
With this achieved I wanted to use these functions in a formula but always get "Invalid Syntax", no matter what I try inside the ''.


RE: HP50g Using library functions in programs - Joe Horn - 12-04-2019 06:09 PM

(12-04-2019 06:23 AM)erazor Wrote:  ... I wanted to use these functions in a formula but always get "Invalid Syntax", no matter what I try inside the ''.

None of LongFloat's commands can be used inside algebraic expressions. They are intended to be used in RPL programs in sequential order, operating on the stack. If you would like assistance turning a formula into RPN using LongFloat commands, just let us know the specific formula, and what you want to do with it (e.g. graph it, or send it to a solver, or whatever). Just keep in mind that only LongFloat's commands can handle its special "long float" object type. Attempting to feed long floats to any functions built into the 50g will error out (with a few obvious exceptions, e.g. TYPE).


RE: HP50g Using library functions in programs - erazor - 12-05-2019 07:32 PM

So I have the formula n=log(g/(1-w))/log(g/(g-1)) which estimates the number n of needed clones to pick from an amplified genetic library to have all g different clones with 1 > w >= 0,9 probability.
I need to use this with g values above 1e14. That doesn't work with HPs 12 digits and produces wrong results with, for example, a 15 digits casio.
I transferred this to the following user rpl program:

<< -> G W <<
G R<-->F 'G' STO
W R<-->F 'W' STO
G 1 W FSUB FDIV FLN
G G 1 FSUB FDIV FLN
FDIV
R<-->F
>>
>>

which now works well. For calculating w I would transpose the formula, but just for learing purpose as you mentioned it:
How do I need to formulate the program so I can use it with the numeric solver like the formula? The Num.solv lets load me the program but doesn't work otherwise and I found nothing in the manual about this.


RE: HP50g Using library functions in programs - Joe Horn - 12-05-2019 10:36 PM

(12-05-2019 07:32 PM)erazor Wrote:  How do I need to formulate the program so I can use it with the numeric solver like the formula? The Num.solv lets load me the program but doesn't work otherwise and I found nothing in the manual about this.

Supposing that you saved your user-defined function (program) under the name 'CLONZ', just run any of the 50g's solvers on the equation 'N=CLONZ(G,W)'. I just tried it, and it's very slow but it works. Hint: Immediately after pressing the SOLVE key, press any other key, and the 50g solver will display each iteration at the stop of the screen, which lets you watch as it converges on the solution. Since LongFloat's accuracy is controllable, be sure to set DIGITS as small as possible to speed up the process.

Example: If N=1500, and G=153, the 50g's solver says that W=.991816725459