Menu

#567 difference between x**3 versus x*x*x

open
nobody
5
2021-08-19
2021-08-19
No

There are two REXX programs (uploaded here, JUGGLE.REX and JUGGLE2.REX).

The two REXX programs are identical, except one (JUGGLE.REX) uses x x x and the other (JUGGLE2.REX) uses x ** 3 to compute a cube (for very large numbers).

They produce much different results. Note that these are (positive) integers. If the cube product results in a floating point number (exponential format), the number is parsed and the exponent extracted, "2" is added to this, and then the NUMERIC DIGITS is increased to this new number. Then the cube product is re-calculated so that the new cube product should now be an integer. Except that when using the x ** 3 method, it produces an incorrect result. Other REXXes produce the correct result when running JUGGLER2.REX (note that all versions of Regina REXX fail, from 3.9.3 down to 3.2).

I don't believe the problem is in the exponentiation, at least not directly, but something to do with the changing of NUMERIC DIGITS, and the subsequent re-calculation of the cube product using the ** operator. _____ Gerard Schildberger

2 Attachments

Discussion

  • Gerard Schildberger

    Darn re-formater. The 2nd sentence should be: ... uses x * x * x and ... (the multiplication of three X's.)

     
  • Paul Kislanko

    Paul Kislanko - 2021-08-19

    The error is general. Evidently ** cannot return integers greater than 10^20.

    trexxpow 69667297 6
    x= 69667297 DIGITS= 9
    n= 2 DIGITS= 17; mult= 4853532271286209; pow= 4853532271286209
    n= 3 DIGITS= 25; mult= 338132474242780894407073; pow= 3.3813247424278089E+23
    n= 4 DIGITS= 33; mult= 23556775508416666676583193591681; pow= 2.3556775508416667E+31
    n= 5 DIGITS= 41; mult= 1641136875707189917107524293160136956257; pow= 1.6411368757071899E+39
    n= 6 DIGITS= 49; mult= 114333570137544884990535275866302329892232427329; pow= 1.1433357013754488E+47
    
     
  • Gerard Schildberger

    By the way, the JUGGLER.REX program is designed to show "juggler numbers", that is, numbers in the "juggler" sequence. It has two modes of operation: one mode to show the largest integer when a juggler sequence starts with a particular number, to show the number of steps before completing (ending in unity), and show the biggest integer in the sequence and what "index"/position it is in the sequence. The other mode is similar to the first mode, but is shows how many decimal digits the largest sequence number has. This verbiage has nothing to do with helping anyone debugging this problem, but I'm sure some people would probably like a description what the program is doing. The Juggler sequences were publicized by an American mathematician and author: Clifford A. Pickover. ______ Gerard Schildberger

     

Log in to post a comment.