HP Forums
(12C) Signum Function - Printable Version

+- HP Forums (https://www.hpmuseum.org/forum)
+-- Forum: HP Software Libraries (/forum-10.html)
+--- Forum: General Software Library (/forum-13.html)
+--- Thread: (12C) Signum Function (/thread-12529.html)

Pages: 1 2


RE: (12C) Signum Function - Dieter - 03-04-2019 10:49 AM

(03-03-2019 06:52 PM)Gerson W. Barbosa Wrote:  That’s what I get on my TI 57, but on my 12c Prestige (and on the latest Platinums, I presume), arguments on the display cannot be reused after an operator.

But it seems to have worked on early 12CPs, as Robert noted.

(03-03-2019 06:52 PM)Gerson W. Barbosa Wrote:  IMHO, this is a feature, not a bug. Although the old behavior is apparently more convenient in some situations, I prefer this new one

I prefer the other way as it can shorten and simplify quite a lot of calculations. For instance the sum formula (n²+n)/2, that's simply + x² / 2. Add an "=" before the division, if required.

On some (many, most, all?) TIs, e.g. the 58/59, there even was a way to re-enter the displayed value during a calculation by means of the CE key, as in

5 x ( CE + 1 ) / 2 =

I really appreciated this as it helped overcome the limitations of AOS (a bit).

But then...
(03-03-2019 06:52 PM)Gerson W. Barbosa Wrote:  (or at least I would if I chose ALG, which I never will).

That's what I really love about RPN: it's direct, straightforward and unambiguos. It simply does what you tell it to do and intermediate results can be freely stored on the stack.

Dieter


RE: (12C) Signum Function - Dieter - 03-04-2019 10:57 AM

(03-02-2019 03:00 AM)Gerson W. Barbosa Wrote:  
Code:
01 ENTER 
02 CHS
03 x<=y
04 CHS
05 x=0
06 n!
07 /

That's a nice one. I probably would have used e^x to convert 0 into 1, but n! does it either, and maybe it's a tiiiiiiiiiny bit faster.

This also makes a nice ABS code:

Code:
01 ENTER 
02 CHS
03 x<=y
04 CHS

This leaves the original input in Y and its absolute value in X.
And again it does not have the problems of the x² √x method: it neither underflows for very small values not does it cause inaccuracies for about one out of five arguments (cf. Thomas' post).

Dieter


RE: (12C) Signum Function - Gerson W. Barbosa - 03-04-2019 08:11 PM

(03-04-2019 10:57 AM)Dieter Wrote:  This also makes a nice ABS code:

Code:
01 ENTER 
02 CHS
03 x<=y
04 CHS

This leaves the original input in Y and its absolute value in X.

In order to use that as a function I’d rather get rid of the original input, but I cannot do it in less than five steps on the HP-12C:

Code:

01 0
02 x<=y
03 x<>y
04 -
05 CHS

On the HP-25 it can be done with four steps:

Code:

01 0
02 x>y
03 x<>y
04 -

It won’t beat the usual method, though:

Code:

01 x^2
02 sqrt

|-3.43142| = 3.431420001 might not be much of problem for most applications, I think.

Gerson.