Numeric49 v1.0 by Steen S. Schmidt

April 25, 2001

 

Contents

Contents. 1

Disclaimer & Copyright 1

Credits. 1

Requirements & Installation. 1

Numeric49. 2

NSOLVE. 2

CNSOLVE. 3

NSUBST. 3

NNUM... 4

NEVAL. 4

NINT. 5

Relationship w/ SymbToolz. 6

Revision History. 6

Disclaimer & Copyright

This program is freeware, so no registration or licensing fees are necessary. You are free to distribute this program to anyone, as long as this document is included.

I cannot take responsibility for any damage or data loss caused by this program – it is written in 100% SysRPL and there could be bugs in it. This also means that it will not run on the HP48 series.

If you have any suggestions, additions or find any bugs in the code, you’re welcome to contact me per email at SSchmidt@nospam.dk. Please include details about ROM revision and flag settings if you’re reporting a bug.

Credits

The library is coded and compiled directly on the HP49G, which has proven to be a great tool for this too. A thanks goes to ACO for making it possible – including these programming tools on the calculator itself has made the job a lot easier.

Mr. Bernard Parisse (CAS author on the HP49G) has been a big help explaining his software to me.

As always, a big thanks to the guys at the comp.sys.hp48 newsgroup – especially Carsten Dominik for his Emacs library, in which the RPLCPL command resides.

Requirements & Installation

You need to copy the library (library #1129) to the calculator (with HPComm for example) and store it in a port (any port should do).

To store it in port 2 for example, you will need to recall the library to the stack, type 2 and STO.

 

 

Hold down ON and press F3, release both keys and the calc should warm boot (warning: you’ll loose all stack contents, but calc memory will remain intact). When this is done, your port 2 should contain the entry for the library (press left shift APPS to enter the Filer):

 

  à 

 

Running BYTES on the library on the stack should yield #579Ah and 2636.5 bytes.

 

  à 

 

This document shows stack syntax for RPN mode, but algebraic mode seems to work too. Use RPN for best results.

Numeric49

This library is a small set of commands to handle numerical calculations a bit easier than it is normally on the calculator. The calculator often asks you to change into numeric mode when dealing with algebraic constructs containing numeric elements – for example when doing EVAL on them. Mode changes occur invisibly inside this library, and the initial modes are restored after each command.

 

When solving equations using the built-in SOLVE command, erroneous solutions may occur. An example is when solving  for , the HP49G will return both  and  as solutions, even though only  is a solution. This is because  and  are solutions of the numerator, but  is cancelled out by the denominator. Both NSOLVE and CNSOLVE of this library take this into consideration.

 

The commands are listed below.

 

NSOLVE

Numerical SOLVE command:

Used to solve equations numerically for real roots, independent of mode. At the moment, this command will only solve rational expressions, but an expansion is planned, so that it’ll solve many more types of expressions.

This command is mostly much faster than SOLVE in numeric mode – it’s comparable in speed with the built-in PROOT command.

 

Level 2

Level 1

à

Level 1

symbolic/number

global name

à

{ solutions1…? }

 

Irrational expressions aren’t solved:

 

  à 

 

NB: The command strips the two arguments from the stack in this case – they are not returned! I’ve not changed this, as I expect a new revision of this command to emerge soon. Use the calculators ‘UNDO’ function to get them back.

 

All rational expressions are solved – only real roots are returned:

 

  à 

 

The expressions to be solved do have to be entirely numeric, except for the variable name to solve for. This means that  can be solved for , while  can not. Even when this command returnes an empty list, there can still exist complex solutions. Use CNSOLVE to find these.

 

CNSOLVE

Numerical complex SOLVE command:

Used to solve equations numerically for real and complex roots, independent of mode. This command will only solve rational expressions, and an upgrade to solve irrational expressions is not planned.

This command is mostly much faster than SOLVE in numeric mode – it’s comparable in speed with the built-in PROOT command.

 

Level 2

Level 1

à

Level 1

symbolic/number

global name

à

{ solutions1…? }

 

Irrational expressions aren’t solved:

 

  à 

 

All rational expressions are solved – both real and complex roots are returned:

 

  à 

 

The expressions to be solved do have to be entirely numeric, except for the variable name to solve for. This means that  can be solved for , while  can not.

 

NSUBST

Substitution command:

Substitutes value(s) into an expression.

 

Level 3

Level 2

Level 1

à

Level 1

expression

global name

value

à

expression

expression

global name

{ values }

à

{ expressions }

 

The expression can be a symbolic, a number or an integer (the latter two cases will of course just return themselves). This is many times faster for numeric substitutions, than SUBST.

 

  à 

 

If more than one substitution is required, just input a list of values instead – this is faster than running the command multiple times.

 

  à 

 

NNUM

àNumeric command:

Converts all integers and constants in an expression into real numbers. Sort of like the built-in XNUM command works in Erable from the HP48G (but doesn’t in the HP49G).

 

Level 1

à

Level 1

symbolic/number

à

symbolic/number

{ symbolics/numbers }

à

{ symbolics/numbers }

 

The expression is evaluated afterwards – not like the EVAL command does, but in the sense that the RPN commands are executed, so that strictly numeric arguments will combine. An example would be the numeric RPN sequence 1.748 4.412 ^ turning into 11.7514858411, not ‘1.748^4.412’.

 

  à 

  à 

  à 

 

NEVAL

Numeric EVAL command:

Changes into numeric mode and does EVAL.

 

Level 1

à

Level 1

symbolic/number

à

symbolic/number

{ symbolics/numbers }

à

{ symbolics/numbers }

 

This command changes back to whatever the mode was before.

 

  à 

  à 

 

NINT

Numerical integration command:

Integrates an expression numerically.

 

Level 4

Level 3

Level 2

Level 1

à

Level 1

lower limit

upper limit

integrand

global name

à

value

 

 

 

òsymbolic

à

value

 

The advantage of this command over the built-in measures of integration is versatility and speed. It’ll try to calculate the integral from an antiderivative, if it exists. This means that, if an antiderivative exists, you’ll always get the fastest calculation of the integral independent of modes. If the caclulator cannot find an antiderivative – which is rare in real life – the integral will be calculated numerically with 5 FIX overriding the current precission setting. NINT will then typically have a performance advantage by a factor of 2 to 10, compared to STD mode. Give NINT any numerical integral, and it’ll solve it as fast as anything on the HP49G.

 

NINT will accept arguments either as the built-in command ò do…

 

  à 

 

…or as a symbolic integral. This will be treated similarly to the above format:

 

  à 

 

It’s a must that the integral to be solved is strictly numeric – or else an error will occur.

 

  à 

 

If an integral has to be solved numerically, and 5 FIX has to be applied, the result will be tagged by a dot to show that the precission is only 5 decimal places.

 

  à    (STD precission à 67 seconds execution time)

  à    (5 FIX precission à 21 seconds calculation time)

Relationship w/ SymbToolz

The command NSOLVE did reside in the SymbToolz library up until v1.1. From SymbToolz v2.0 (not released yet) onwards, this command will not be included with SymbToolz. This library is the natural place for NSOLVE, and therefore it has been removed.

Revision History

v1.0:  Initial public release.