Post Reply 
RE: HP48-HP50G : Error functions ERF(z), FRESNEL integrals, PROBIT, etc.
11-11-2023, 03:43 PM
Post: #10
RE: HP48-HP50G : Error functions Erf(x), Erfc(x) & Erf/Erfc —>x
(11-11-2023 01:24 PM)John Keith Wrote:  Could you make x a local variable? I've never tried using local variables with ROOT but it should work.

This can be done, but it's a bit more convoluted than it should be.

It appears that the ROOT command has overloaded argument signatures that all expect global IDs only (as opposed to local). This was probably done to save space, as there are already 8 dispatches for ROOT, and allowing locals would have doubled that number. The underlying code, though, uses SysRPL SAFE@, which works fine with either globals or locals.

So getting this to work properly involves a little trickery. Basically you have to instantiate the local, then bypass the dispatcher with a SYSEVAL call instead of the UserRPL ROOT command. The address to pass to SYSEVAL depends on the platform you are targeting.

I've used Gil's code from above as the basis here, and modified it for a 50g. As usual, be careful with SYSEVAL commands. One small typo or using a code for the wrong platform will likely crash your calculator.
Code:
ERF
\<<
  0 .5 ROT UTPN -2 * 1 +
\>>

iERF
\<<
  1 - -2 / NOVAL \-> p X
  \<<
    \<< p 0 .5 X UTPN - \>>
    'X'
    2
    # 2F12Ch SYSEVAL   @ direct ROOT code
    "x of Erf" \->TAG
  \>>
\>>

ERFc
\<<
  0 .5 ROT UTPN 2 *
\>>

iERFc
\<<
  2 / NOVAL \-> p X
  \<<
    \<< p 0 .5 X UTPN - \>>
    'X'
    2
    # 2F12Ch SYSEVAL   @ direct ROOT code
    "x of Erfc" \->TAG
  \>>
\>>

I chose to use NOVAL when instantiating the local X, just to make it easier to see. Any value could have been used there, since whatever is there will be overwritten by the ROOT solver.

The 50g needs # 2F12Ch as the argument to SYSEVAL. A rev. R 48gx needs # 32F77h instead.
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
RE: HP48-HP50G : Error functions Erf(x), Erfc(x) & Erf/Erfc —>x - DavidM - 11-11-2023 03:43 PM



User(s) browsing this thread: 20 Guest(s)