The Museum of HP Calculators

HP Forum Archive 21

[ Return to Index | Top of Index ]

x root y on hp42s
Message #1 Posted by David Griffith on 7 Apr 2012, 4:23 a.m.

I'm trying to turn the cube root program in the 42s's manual into an "x root y" program, but I'm having trouble understanding how to recall the Y register. Would please paste an nth-root program here?

      
Re: x root y on hp42s
Message #2 Posted by Alexander Oestert on 7 Apr 2012, 4:39 a.m.,
in response to message #1 by David Griffith

To recall X, Y, Z, T from the stack on th 42s, press

[RCL] and [.] and you will be presented with soft key choices. The same for STO.

Another way to access Y is to do X<>Y

      
Re: x root y on hp42s
Message #3 Posted by Gerson W. Barbosa on 7 Apr 2012, 11:51 p.m.,
in response to message #1 by David Griffith

The following results match what I get with x|/y on the HP32 SII, except for the error messages. This can be optimized for size, of course.

             00 { 41-Byte Prgm }
             01>LBL "XROOT"
             02 STO ST Z
             03 X<>Y    
             04 X>=0?    
             05 GTO 00  
             06 X<>Y    
             07 2       
             08 MOD     
             09 X=0?    
             10 DOT     
             11 Rv      
             12 X<>Y    
             13 ENTER   
             14 FP      
             15 X!=0?   
             16 DOT     
             17 Rv      
             18 Rv      
             19>LBL 00  
             20 SIGN    
             21 LASTX   
             22 RCL ST Z
             23 1/X     
             24 Y^X     
             25 ABS     
             26 ×       
             27 .END.

Keystrokes Display

27 +/- ENTER 3 XEQ XROOT -3 32 +/- ENTER 5 XEQ XROOT -2 27 +/- ENTER 3 +/- XEQ XROOT -3.33333333333E-1 32 +/- ENTER 5 +/- XEQ XROOT -4.99999999999E-1 32 ENTER 5 +/- XEQ XROOT 0.5 625 ENTER 4 XEQ XROOT 5 625 ENTER 4 +/- XEQ XROOT 0.2 625 +/- 4 XEQ XROOT Invalid Type 27.5 ENTER 3.5 +/- XEQ XROOT 3.87937790083E-1 27.5 +/- ENTER 3.5 XEQ XROOT Invalid Type 27.5 +/- ENTER 3.5 +/- XEQ XROOT Invalid Type 27.5 ENTER 3.5 XEQ XROOT 2.577732888 5 ENTER 0 XEQ XROOT Divide by 0

P.S.: Real arguments only.

Edited: 8 Apr 2012, 12:00 a.m.

            
Re: x root y on hp42s
Message #4 Posted by Dieter on 8 Apr 2012, 6:17 a.m.,
in response to message #3 by Gerson W. Barbosa

Hi Gerson,

Quote:
The following results match what I get with x|/y on the HP32 SII ...

27 +/- ENTER 3 XEQ XROOT -3


Fine. And now try the cube root of 729. Does it still match ?-)
Quote:
32 +/- ENTER 5 +/- XEQ XROOT -4.99999999999E-1
My 35s here returns exactly -0,5. What does your 32sII say? I cannot imagine the result is any different.

BTW, it can be shown that evaluating roots this way may exhibit an error up to several units in the last significant digit. That's why I was so eager about CUBERT and XROOT in the 34s. ;-)

Dieter

                  
Re: x root y on hp42s
Message #5 Posted by Paul Dale on 8 Apr 2012, 6:22 a.m.,
in response to message #4 by Dieter

The 34S will still exhibit the same error in the last place, but due to the increased internal precision, it will likely be hidden resulting in an effective +/- 1 ULP in the result.

- Pauli

                        
Re: x root y on hp42s
Message #6 Posted by Dieter on 8 Apr 2012, 12:06 p.m.,
in response to message #5 by Paul Dale

Yes, that's why there are guard digits. With its 39-digit precision and 16 resp. 32 digit output, I think the 34s may look at all this quite relaxed. ;-)

Dieter

                              
Re: x root y on hp42s
Message #7 Posted by Paul Dale on 8 Apr 2012, 6:14 p.m.,
in response to message #6 by Dieter

Double precision carries 34 digits not 32 :-)

- Pauli

                                    
Re: x root y on hp42s
Message #8 Posted by Walter B on 8 Apr 2012, 10:34 p.m.,
in response to message #7 by Paul Dale

... for that reason it's called 'double' ;-)

                                          
Re: x root y on hp42s
Message #9 Posted by Paul Dale on 8 Apr 2012, 11:14 p.m.,
in response to message #8 by Walter B

It is called double because it occupies 128 bits of memory whereas single precision occupies 64 bits. There is logic here.

In reality, we're using double and quadruple precision. Single precision being 32 bits which allows seven digits.

The gain in digits is made possible by not doubling the size of the exponent field and not duplicating the sign bit with each doubling in length of the number.

- Pauli

                  
Re: x root y on hp42s
Message #10 Posted by Gerson W. Barbosa on 8 Apr 2012, 11:37 a.m.,
in response to message #4 by Dieter

Hello Dieter,

Quote:
And now try the cube root of 729. Does it still match ?-)

It practically matches: 8.99999999998.

Quote:
Quote:
32 +/- ENTER 5 +/- XEQ XROOT -4.99999999999E-1
My 35s here returns exactly -0,5.
So does my HP-32SII. "Practically" is the word I missed. My fault, sorry!
Quote:
That's why I was so eager about CUBERT and XROOT in the 34s. ;-)
It's a pity the latter is not available from the keyboard. IMHO, it should be a better companion to yx than LOGx, which of course should stay. Where to find room for both on the keyboard? I think ./, is superfluous as RDX. and RDX, are available under MODE. But I am aware time for keyboard layout suggestions is over...

Gerson.

                        
Re: x root y on hp42s
Message #11 Posted by Dieter on 8 Apr 2012, 12:17 p.m.,
in response to message #10 by Gerson W. Barbosa

Gerson,

Quote:
It practically matches: 8.99999999998.
Aaaaaha! ;-)

But it gets even worse. Try the 6th root of 531441. In cases like these the error may be as large at 5 ULP.

Quote:
It's a pity the latter is not available from the keyboard. IMHO, it should be a better companion to y^x than LOGx, which of course should stay. Where to find room for both on the keyboard?
I think XROOT would fit nicely on the (green shifted) sqrt / x^2 key.
Oooops... guess what - that's exactly where it is placed on the 35s. :-)
Quote:
But I am aware time for keyboard layout suggestions is over...
Walter always says that the 34s is a moving target. So nothing is fixed. ;-)

Dieter

                              
Re: x root y on hp42s
Message #12 Posted by Paul Dale on 8 Apr 2012, 6:16 p.m.,
in response to message #11 by Dieter

Quote:
Walter always says that the 34s is a moving target. So nothing is fixed. ;-)

The keyboard layout is a little less fluid than everything else.

- Pauli

                        
Re: x root y on hp42s
Message #13 Posted by Walter B on 8 Apr 2012, 12:21 p.m.,
in response to message #10 by Gerson W. Barbosa

Quote:
I think ./, is superfluous as RDX. and RDX, are available under MODE. But I am aware time for keyboard layout suggestions is over...
Sim, Gerson - you're right with your second sentence. And the label ./, was caused by the fact that at design time our North American friends kept asking for an easy way to change the radix mark whenever they got a comma calculator ;-) And since we meanwhile put an alpha menu on said label, we can't change that easily (BTW I remember we had a discussion about that very label some (many?) months ago, but I don't remember when).
                              
Re: x root y on hp42s
Message #14 Posted by Gerson W. Barbosa on 8 Apr 2012, 12:39 p.m.,
in response to message #13 by Walter B

Quote:
And the label ./, was caused by the fact that at design time our North American friends kept asking for an easy way to change the radix mark whenever they got a comma calculator ;-)

On the other hand, this also allows for an easy way to accidentally change the radix mark. I missed that discussion, however.

                                    
Re: x root y on hp42s
Message #15 Posted by Walter B on 8 Apr 2012, 12:43 p.m.,
in response to message #14 by Gerson W. Barbosa

Quote:

On the other hand, this also allows for an easy way to accidentally change the radix mark. I missed that discussion, however.


You're right again, but you can correct that accident most easily :-)


[ Return to Index | Top of Index ]

Go back to the main exhibit hall