08-18-2022, 05:17 AM
08-18-2022, 06:18 AM
Try adding a decimal point (or comma, depending on your radix separator) to the -1. This tells the HP-50g you want a numerical answer instead of a symbolic answer which uses the CAS engine.
For example:
-1.^999999999999
Returns -1.
For example:
-1.^999999999999
Returns -1.
08-18-2022, 08:43 AM
Thank you, Steve, that solves it for smaller numbers.
I came upon this when writing
https://www.hpmuseum.org/forum/thread-18683.html
The programme is compact:
Trying this on the 50g I was disappointed at the error report for larger powers of 1 & -1, ie greater than 999999999999. The programme below works for larger numbers, nevertheless it's a disappointment the 50g gives up at some point in powers of the unit.
I came upon this when writing
https://www.hpmuseum.org/forum/thread-18683.html
The programme is compact:
Code:
1. LBL B
2. STO N
3. CLx
4. N+(-1)^N+2*(-1)^IDIV(N:2)
5. RTN
K: LN = 40 CK = 25E5
Trying this on the 50g I was disappointed at the error report for larger powers of 1 & -1, ie greater than 999999999999. The programme below works for larger numbers, nevertheless it's a disappointment the 50g gives up at some point in powers of the unit.
Code:
Size: 96.
CkSum: # 7D33h
::
CK1&Dispatch
# FF
::
FPTR2 ^DupZIsEven?
ITE
ZINT 1
ZINT -1
OVER
ZINT 2
FPTR2 ^ZQUOText
FPTR2 ^DupZIsEven?
SWAPDROP
ITE
ZINT 1
ZINT -1
DUP
FPTR2 ^RADDext
FPTR2 ^RADDext
FPTR2 ^RADDext
;
;
08-18-2022, 01:57 PM
Though it doesn't address the issue of integer powers, we can get the result for any number < 2^63 using binary numbers with #3 XOR. this works on any RPL calculator but requires entering the number with a leading #. The 3 can be replaced with any other integer to return values for similar sequences since Nim addition is just XOR.
Going even farther afield, we can make lists of A004444 and similar sequences very rapidly using ListExt commands on the 50g by taking advantage of the structure of the sequence (groups of 4 consecutive numbers reversed). Given a number n on the stack, the following program returns 4n terms of the sequence. If the 4's in the program are replaced with 2's, the program will return 2n terms of A004442.
With the number 250 on the stack, the program returns the first 1000 terms in 1.5 seconds on my 50g.
Going even farther afield, we can make lists of A004444 and similar sequences very rapidly using ListExt commands on the 50g by taking advantage of the structure of the sequence (groups of 4 consecutive numbers reversed). Given a number n on the stack, the following program returns 4n terms of the sequence. If the 4's in the program are replaced with 2's, the program will return 2n terms of A004442.
Code:
\<< 0 SWAP 4 * 1 - LSEQR @ List of numbers 0 to 4n-1
4 LSDIV @ Break up into sublists of 4
:: REV LMAP @ Reverse each sublist
LXIL @ Flatten list
\>>
With the number 250 on the stack, the program returns the first 1000 terms in 1.5 seconds on my 50g.
08-19-2022, 04:09 AM
Also the HP35S gives the correct answer.