(12C) Signum Function

03012019, 06:29 AM
(This post was last modified: 03032019 02:18 AM by Gamo.)
Post: #1




(12C) Signum Function
Signum Function is an odd mathematical function that extracts
the sign of a real number. In mathematical expressions the sign function is often represented as sgn. The Signum Function of a real number (x) is defined as follows: sgn(x) = 1 if x < 0 sgn(x) = 0 if x = 0 sgn(x) = 1 if x > 0 For more detail on this topic https://en.wikipedia.org/wiki/Sign_function  Example: 123 [R/S] display 1 23.33 [R/S] display 1 0 [R/S] display 0  Program: for HP12C Code:
Program: for HP12C Platinum on RPN mode Code:
Gamo 

03022019, 03:00 AM
(This post was last modified: 03022019 03:00 AM by Gerson W. Barbosa.)
Post: #2




RE: (12C) Signum Function
Same number of steps (on the HP12C), working on full range:
Code:


03022019, 05:47 AM
(This post was last modified: 03032019 02:18 AM by Gamo.)
Post: #3




RE: (12C) Signum Function
For HP12 Platinum on ALG mode
Program: Code:
Gamo 

03022019, 05:22 PM
Post: #4




RE: (12C) Signum Function  
03022019, 08:57 PM
Post: #5




RE: (12C) Signum Function
(03022019 05:22 PM)Dieter Wrote: I do not have a 12C Platinum or an emulator, so I cannot check this, but on a TI calculator with AOS I'd simply type But... if the input is zero, you get an error instead of zero output. Bob Prosperi 

03032019, 02:31 AM
Post: #6




RE: (12C) Signum Function
Unique HP12C Platinum in ALG mode
I'm not sure if TI Calculator with AOS got the [LSTx] function. For 12CP in order to use [LSTx] it need to execute direct arithmetic first like [+] [] [x] [÷] but with [x²] or [√x] can not recall [LSTx] so then I use 1 [x] [X<>Y] first so that I can recall [LSTx] later in program. Gamo 

03032019, 08:17 AM
Post: #7




RE: (12C) Signum Function
(03012019 06:29 AM)Gamo Wrote: This doesn't work for \(\left  x \right \leqslant 10^{50}\) or \(\left  x \right  \geqslant 10^{50}\) due to under or overflow. Obviously it works for numbers like 113 or 47. But what happens with a number that uses all the 10 digits like 12.78974364? When we square this number we get 163.5775424 which is rounded to 10 digits. The exact value is 163.5775423769204496. Taking the square root of the rounded value 163.5775424, why can we be sure that we get the original number? If we received something off by 1 in the last digit, such as 12.78974363 or 12.78974365, we'd end up with 1.000000001 or 0.999999999 instead. Any thoughts why this can't happen? The reverse isn't true as we know: taking the square root of 3 gives 1.732050808. But the square of this number is rounded to 3.000000001. The exact value is 3.000000001493452864. Kind regards Thomas 

03032019, 12:38 PM
Post: #8




RE: (12C) Signum Function
(03022019 08:57 PM)rprosperi Wrote: But... if the input is zero, you get an error instead of zero output. Yes, sure, in a real program the first steps would be x=0? GTO 000. (03032019 02:31 AM)Gamo Wrote: Unique HP12C Platinum in ALG mode Of course not. But that's not my question. The point is that on a TI you don't need all this. There is no need to use LstX or a dummy multiplication. I just want to know whether the proposed key sequence (without 1 x multipliation and without LstX) also works on the 12CP or not. Does it? What happens if you press 123 [÷] [x²] [√x] [=] ? Dieter 

03032019, 01:15 PM
Post: #9




RE: (12C) Signum Function
(03032019 08:17 AM)Thomas Klemm Wrote: But what happens with a number that uses all the 10 digits like 12.78974364? If a number x had an uncertainty factor 1+ε, (x·(1+ε))² = x²·(1+2ε+ε²) ≈ x²·(1+2ε) So, for squaring, uncertainly doubled (with at most ±½ ulp error). Square root is just a reverse operation, uncertainly cut in half. We would expect squaring, then square root, roundtrip back to original number. 

03032019, 02:39 PM
Post: #10




RE: (12C) Signum Function
Program this in ALG mode for 12CP
[÷] [x²] [√x] [=] 123 [R/S] display 123 123 [CHS] [R/S] display 123 Above routine look like ABS function. Gamo 

03032019, 03:34 PM
Post: #11




RE: (12C) Signum Function
(03032019 02:39 PM)Gamo Wrote: Program this in ALG mode for 12CP No, the above program returns 1.00 on a 12CP, as Dieter suspected. SICNR, I had to try my first algebriac mode program on a 12CP... Interesting UPDATE: On the initial 12CP (before the (), Undo and Backspace were added) the above program returns 1.00, but on later models (including the Android emulator) returns 123 as Gamo reported. Clearly a bug, I need to explore past bug reports. Intuitively, the initial behavior is correct and the later is not, though it seems unlikely such a bug has never been noticed and fixed... Bob Prosperi 

03032019, 04:59 PM
Post: #12




RE: (12C) Signum Function  
03032019, 05:51 PM
(This post was last modified: 03032019 06:01 PM by Dieter.)
Post: #13




RE: (12C) Signum Function
(03032019 03:34 PM)rprosperi Wrote: On the initial 12CP (before the (), Undo and Backspace were added) the above program returns 1.00, but on later models (including the Android emulator) returns 123 as Gamo reported. That's really weird. #) I wonder what happens in similar cases like 2 [+] [√x] [=] or 5 [x] [LN] [x²] [=] I'd expect 3,41 and 12,95 but obviously you never know... Dieter 

03032019, 06:52 PM
(This post was last modified: 03032019 06:55 PM by Gerson W. Barbosa.)
Post: #14




RE: (12C) Signum Function
(03032019 05:51 PM)Dieter Wrote: I wonder what happens in similar cases like 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. Thus, in order to get what you want the following sequences should be used: 2 [+] 2 [√x] [=] > 3.414213562 5 [x] 5 [LN] [x²] [=] > 12.95145197 IMHO, this is a feature, not a bug. Although the old behavior is apparently more convenient in some situations, I prefer this new one (or at least I would if I chose ALG, which I never will). Gerson. 

03032019, 07:03 PM
(This post was last modified: 03032019 07:03 PM by Gerson W. Barbosa.)
Post: #15




RE: (12C) Signum Function
(03032019 08:17 AM)Thomas Klemm Wrote:(03012019 06:29 AM)Gamo Wrote: The RPN program in post #2 above completely avoids these shortcomings. Gerson. 

03032019, 07:49 PM
Post: #16




RE: (12C) Signum Function
(03032019 04:59 PM)Thomas Klemm Wrote: There's no "uncertainty" when it comes to rounding numbers. Turns out, there is nothing to explain. I found a counterexample ... My post on square, following by squareroot roundtrip is wrong Example, on HP12C, x = Pi + 0.04 = 3.181592654 3.181592654^2 ≈ 10.1225318160, roundedupto 10.12253182 √10.12253182 ≈ 3.18159265463, roundedupto 3.181592655 Ratio of x / √(x²) = 0.9999999997 ≠ 1 

03032019, 07:59 PM
(This post was last modified: 03032019 07:59 PM by rprosperi.)
Post: #17




RE: (12C) Signum Function
(03032019 05:51 PM)Dieter Wrote: I wonder what happens in similar cases like Your expectations are correct, IMHO. Original 12CP: 3,41 & 12,95 Later 12CP: 1,41 & 2,59 I've not researched yet, but Gerson's summary "...arguments on the display cannot be reused after an operator..." seems a concise summary of the 'fixed' or at least updated, behavior. Denying reuse of the original argument may have been necessary (or at least easier) as a result of adding the UNDO feature in the 2nd and all later series of 12CP models. One could argue either way which is 'right', since algebraic notation is notoriously ambiguous, though I must admit that this is a more interesting than normal situation. @Gerson  of course the RPN solution works; they're always unambiguous. Bob Prosperi 

03032019, 11:27 PM
Post: #18




RE: (12C) Signum Function
(03032019 07:49 PM)Albert Chan Wrote: Example, on HP12C, x = Pi + 0.04 = 3.181592654 If we just look at the mantissa it appears that this only happens for values between \(\sqrt{10} \approx 3.16228\) and \(5\). And within this interval it happens at about 18.37% of the cases. Which is close to \(\frac{5  \sqrt{10}}{10} \approx 0.18377\). Choosing a number at random leads to a wrong result in about 1 of 27 cases. I don't think that we can neglect that. Here's a table with some values \(x\) having only 5 digits after the decimal point and \(\sqrt{x^2}\) as it is calculated by the HP12C: Code: 3.16343 3.163429999 Cheers Thomas 

03042019, 02:02 AM
(This post was last modified: 03042019 02:30 AM by Albert Chan.)
Post: #19




RE: (12C) Signum Function
(03032019 11:27 PM)Thomas Klemm Wrote: If we just look at the mantissa it appears that this only happens for values between \(\sqrt{10} \approx 3.16228\) and \(5\). This range can be explained by squaring errors: (x·(1+ε))² = x²·(1+2ε+ε²) ≈ x²·(1+2ε) Assuming numbers in scientific notation, with mantissa = [1, 10), ulp = 1e9 Max rel error of √(x²) ≈ ½ Max rel error of x² = ½ (½ ulp / mantissa(x²)) Max abs error of √(x²) ≈ ¼ ulp (mantissa(x) / mantissa(x²)) Roundtrip errors occurs if √(x²) abs error ≥ ½ ulp > mantissa(x) between √10 and 5.0 > Max abs error between 0.79 and 0.50 ulp Edit: this also explained why (√x)² may have errors upto 3 ULP Example: (√9.11)² = 9.110000003 

03042019, 04:58 AM
(This post was last modified: 03042019 05:46 AM by Gamo.)
Post: #20




RE: (12C) Signum Function
Example program on ALG mode
Guass Sum (x² + x) ÷ 2  If program this way [LSTx] [x²] + [LSTx] [÷] 2 [=] Each [R/S] need to clear register to restart Clear by pressing [CLx] [CLx] 100 [R/S] display 5050 If not clear 100 [R/S] display 12751300  This routine no need to clear register but Need the dummy (1 × X<>Y) 1 [×] [X<>Y] [x²] + [LSTx] [÷] 2 [=]  Gamo 

« Next Oldest  Next Newest »

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