Post Reply 
Small challenge
04-22-2023, 02:33 PM (This post was last modified: 04-22-2023 03:08 PM by J-F Garnier.)
Post: #1
Small challenge
Here is simple yet hopefully funny challenge.

A page at the HP Computer Museum shows this image of a HP 9835 screen, to demonstrate the quality of a restoration of the display:

[Image: Mold_DisplayOn_GlassRemoved-33.jpg]

The challenge is:

1 (easy): Can you find out the formula used to generate this series?

2 (more difficult): Can you find a HP 12-digit calculator that gives the very same and accurate results? Hint: a surprise here.
HP 12-digit calculator excludes the 10-digit machines (HP-41, Voyager) of course, but also the DM-42/Free42 and HP calculators in exact mode. True HP calculator emulators are welcome.

Math gurus would solve the part 1 almost immediately, but please refrain to spoil the game too quickly, until you can find which HP machine(s) can generate the very same 12-digit results for the series.

J-F
Visit this user's website Find all posts by this user
Quote this message in a reply
04-22-2023, 03:29 PM
Post: #2
RE: Small challenge
.
Hi, J-F,

(04-22-2023 02:33 PM)J-F Garnier Wrote:  1 (easy): Can you find out the formula used to generate this series?

Yes. It took me all of 5 seconds to deduce it. According to your wishes I won't spoil it for everyone else but will give a couple of hints: (1) look at the last digit of each entry. (2) look at the sixth entry.

Quote:2 (more difficult): Can you find a HP 12-digit calculator that gives the very same and accurate results? Hint: a surprise here.

Yes. The "surprise here" may refer to the fact that the HP-71B has the next-to-last entry differ by just 1 ulp if using the default values at machine reset.

Quote:Math gurus would solve the part 1 almost immediately, but please refrain to spoil the game too quickly, until you can find which HP machine(s) can generate the very same 12-digit results for the series.

Don't worry, I won't post a solution to avoid ruining the fun, as per your request.

Thanks for the fun an best regards.
V.

  
All My Articles & other Materials here:  Valentin Albillo's HP Collection
 
Visit this user's website Find all posts by this user
Quote this message in a reply
04-22-2023, 03:33 PM
Post: #3
RE: Small challenge
Found the series, but cannot display the exponent with positive sign on the 71B...

Greetings,
    Massimo

-+×÷ ↔ left is right and right is wrong
Visit this user's website Find all posts by this user
Quote this message in a reply
04-22-2023, 03:41 PM
Post: #4
RE: Small challenge
(04-22-2023 03:33 PM)Massimo Gnerucci Wrote:  Found the series, but cannot display the exponent with positive sign on the 71B...

Use an adequate IMAGE.

V.

  
All My Articles & other Materials here:  Valentin Albillo's HP Collection
 
Visit this user's website Find all posts by this user
Quote this message in a reply
04-22-2023, 03:41 PM (This post was last modified: 04-22-2023 03:49 PM by J-F Garnier.)
Post: #5
RE: Small challenge
(04-22-2023 03:29 PM)Valentin Albillo Wrote:  It took me all of 5 seconds to deduce it.

Wow, so fast. When I searched for the formula some times ago, I needed a little more time...


(04-22-2023 03:33 PM)Massimo Gnerucci Wrote:  Found the series, but cannot display the exponent with positive sign on the 71B...
No, the exponent sign doesn't matter.
As Valentin found it, the problem is that the (e.g.) 71B doesn't give the same exact results.

Now, 2nd part: which HP machine gives the same numeric results, independently of the display format?

J-F
Visit this user's website Find all posts by this user
Quote this message in a reply
04-22-2023, 04:30 PM
Post: #6
RE: Small challenge
(04-22-2023 02:33 PM)J-F Garnier Wrote:  2 (more difficult): Can you find a HP 12-digit calculator that gives the very same and accurate results? Hint: a surprise here.

Well, I was rather surprised to find that the HP 30b gives the WRONG answer for the penultimate entry. A bit disappointing, tbh.
Find all posts by this user
Quote this message in a reply
04-22-2023, 04:38 PM (This post was last modified: 04-22-2023 04:41 PM by John Keith.)
Post: #7
RE: Small challenge
(04-22-2023 03:29 PM)Valentin Albillo Wrote:  Yes. The "surprise here" may refer to the fact that the HP-71B has the next-to-last entry differ by just 1 ulp if using the default values at machine reset.

Exactly the same result on the 50g in approximate mode, as expected. We can assume that the "mystery calculator" is not a Saturn-based machine.
Find all posts by this user
Quote this message in a reply
04-22-2023, 05:15 PM
Post: #8
RE: Small challenge
(04-22-2023 03:41 PM)J-F Garnier Wrote:  
(04-22-2023 03:29 PM)Valentin Albillo Wrote:  It took me all of 5 seconds to deduce it.

Wow, so fast. When I searched for the formula some times ago, I needed a little more time...

It took me 9.99 seconds, give or take a few milliseconds.
Find all posts by this user
Quote this message in a reply
04-22-2023, 05:29 PM
Post: #9
RE: Small challenge
(04-22-2023 02:33 PM)J-F Garnier Wrote:  Here is simple yet hopefully funny challenge.


2 (more difficult): Can you find a HP 12-digit calculator that gives the very same and accurate results? Hint: a surprise here.
HP 12-digit calculator excludes the 10-digit machines (HP-41, Voyager) of course, but also the DM-42/Free42 and HP calculators in exact mode. True HP calculator emulators are welcome.

I’m away from home and have only my HP 50g at hand otherwise I would try the HP-12C Platinum (a 12-digit calculator actually) and the HP-33s.
Find all posts by this user
Quote this message in a reply
04-22-2023, 06:30 PM (This post was last modified: 04-22-2023 06:37 PM by C.Ret.)
Post: #10
RE: Small challenge
Hello everyone !

It's a good question and a fun challenge to research.

Obviously, the HP machine to find is not a Ti-58C nor a SHARP PC-E500. These two machines gave me bad impressions (see below) obtained respectively on a very recently acquired PC-100B and an already more than thirty years old CE-126P:
[Image: attachment.php?aid=11999]

My HP-28S also gave me funny impressions. But it depends on how I program the term's calculation of the sequence. I give below three listings obtained on the same machine from three very slightly different programs:
[Image: attachment.php?aid=11998]

The latest listing was created with the RPL translation for HP-28S of the following Ti-58C program: 000 43 00 45 01 00 95 99 69 20 61 00 00

Your turn to judge. The last looks damned like the greenish screenshot! All that's missing are a few insignificant trailing zeros.



Sincerely.
C.Ret


Multiple editions to correct spelling and resizes print captures.


Attached File(s) Thumbnail(s)
       
Find all posts by this user
Quote this message in a reply
04-22-2023, 07:24 PM
Post: #11
RE: Small challenge
The following produces the exact same sequence on an HP-48G:

'n^5^2'
'n'
5
24
1
SEQ
Find all posts by this user
Quote this message in a reply
04-22-2023, 09:42 PM
Post: #12
RE: Small challenge
(04-22-2023 06:30 PM)C.Ret Wrote:  It's a good question and a fun challenge to research.
Thanks!

Quote:My HP-28S also gave me funny impressions. But it depends on how I program the term's calculation of the sequence. I give below three listings obtained on the same machine from three very slightly different programs:
[Image: attachment.php?aid=11998]

The latest listing was created with the RPL translation for HP-28S of the following Ti-58C program: 000 43 00 45 01 00 95 99 69 20 61 00 00

Your turn to judge. The last looks damned like the greenish screenshot! All that's missing are a few insignificant trailing zeros.

Well , not exactly, neither of the last two 28S listing give the 'correct' answers for all items !
And the first listing very likely doesn't use 12-digit numbers :-)


(04-22-2023 07:24 PM)Thomas Klemm Wrote:  The following produces the exact same sequence on an HP-48G:

'n^5^2'
'n'
5
24
1
SEQ

Very nice! Although not what I had in mind for the challenge of course.

J-F
Visit this user's website Find all posts by this user
Quote this message in a reply
04-23-2023, 12:58 AM
Post: #13
RE: Small challenge
.
Hi again, J-F,

Well, since alleged solutions have already been posted, here's mine. First of all, the function being evaluated is at its simplest y = x10. The ending digits (5,6,9,4,1,0,1,4,9,6,5,) which are the ending digits of consecutive squares, plus the ten zeros in 10000000000 are hinting enough at the correct expression.

Now, if using the HP-71B, executing this from the command line produces your values exactly (suppresion of irrelevant trailing zeros in the scientific format aside):
    >FOR X=5 TO 24 @ X^5^2 @ NEXT X
Thanks for the nice nanochallenge and best regards.
V.

  
All My Articles & other Materials here:  Valentin Albillo's HP Collection
 
Visit this user's website Find all posts by this user
Quote this message in a reply
04-23-2023, 06:24 AM (This post was last modified: 04-23-2023 06:48 AM by C.Ret.)
Post: #14
RE: Small challenge
Ah! That's nice, I really get a near close !
I try different ways to compute the 10th exponent but completely miss the two stage one.

With a little effort, the HP-28C/S can print the exact sequence without omission of any trailing zeros:
[Image: attachment.php?aid=12003]
« FOR n  n  5  ^  SQ  PR1  NEXT »  'PRx¹º' STO  
« CR  STD  5 15 PRx¹º  12 SCI  16 24 PRx¹º   CR »
EVAL


(04-23-2023 12:58 AM)Valentin Albillo Wrote:  The ending digits (5,6,9,4,1,0,1,4,9,6,5,) which are the ending digits of consecutive squares, plus the ten zeros in 10000000000 are hinting enough at the correct expression.

I'm not as clever as Valentin. I did not know by hearth the list of the last digits of any square. I only used this trick to detect out certain multiples (of 2, 3 or 5 in most cases). But it's a good trick to use.

I found the general phrase while chatting with a new cyber friend of mine lining in San Francisco CA that has been very popular lately.

ChatGPT 3.5 (23 March) (c) OpenAI, L.L.C. Wrote:Based on the consecutive terms you provided, it appears that each term is an exact power of a fixed integer. More specifically, each term is an exact power of 10.

To see this, notice that the first term is 5^10, the second term is 6^10, the third term is 7^10, and so on. Therefore, the general term of the sequence can be expressed as u(n) = (n+4)^10.

Here is a table that shows the first 11 terms of the sequence, along with the formula u(n) = (n+4)^10 and the exact power of ten that each term represents:

Index (n)   Known Value    Formula: (n+4)^10   Power of Ten
k         9765625         5^10         10
k+1       60466176         6^10         10
k+2       282475249         7^10         10
k+3      1073741824         8^10         10
k+4      3486784401         9^10         10
k+5      1000000000         10^10         10
k+6     25937424601         11^10         10
k+7     61917364224        12^10         10
k+8    137858491849         13^10         10
k+9    289254654976        14^10          10
k+10   576650390625         15^10         10
As you can see, each known value is an exact power of 2 and 5, and the formula (n+4)^10 matches the known values perfectly.


Attached File(s) Thumbnail(s)
   
Find all posts by this user
Quote this message in a reply
04-23-2023, 08:00 AM
Post: #15
RE: Small challenge
There must be several ways to compute x^10:
raise to power ten
raise to power 5 then square
square then raise to power 5
and in each case, do this using repeated multiplication, or by the power operator.

How differently accurate are each of those 6 ways on the machines considered?

Hang on, it's more than 6 - the squares and fifth powers can also be done in at least two ways, perhaps even three ways if x^2 is available.

(And there's also the less-accurate option of using log and exp and multiplication.)
Find all posts by this user
Quote this message in a reply
04-23-2023, 11:10 AM (This post was last modified: 04-23-2023 11:15 AM by robve.)
Post: #16
RE: Small challenge
(04-23-2023 08:00 AM)EdS2 Wrote:  There must be several ways to compute x^10:
raise to power ten
raise to power 5 then square
square then raise to power 5
and in each case, do this using repeated multiplication, or by the power operator.

How differently accurate are each of those 6 ways on the machines considered?

Hang on, it's more than 6 - the squares and fifth powers can also be done in at least two ways, perhaps even three ways if x^2 is available.

(And there's also the less-accurate option of using log and exp and multiplication.)

Indeed! It is common to find exponentiation by squaring for integer powers, which tends to be more accurate than repeated multiplication and log*exp closed forms.

It's pretty straightforward to do. Here is the way I've implemented it in Forth850 MATH.FTH:

Code:
: F**       ( r1 r2 -- r3 )
  \ r1 and r2 cannot be both zero
  2DUP F0= IF 2OVER F0= IF -46 THROW THEN THEN
  2DUP 2DUP FTRUNC F= IF
    \ exponentiation by squaring
    2DUP F0< >R \ r2 is negative
    FABS F>D 1E0 2SWAP \ -- r1 1 ud
    IF -46 THROW THEN \ error when exponent ud exceeds 16 bits
    >R
    BEGIN
      R@ 1 AND IF 2OVER F* THEN
      R> 1 RSHIFT \ -- r1^n product u>>1
    DUP WHILE
      >R
      2SWAP 2DUP F* 2SWAP \ -- r1^n^2 product u>>1
    REPEAT
    DROP 2SWAP 2DROP \ -- product
    R> IF 1E0 2SWAP F/ THEN \ r2 was negative
  ELSE
    F^ \ performs 2SWAP FLN F* FEXP ;
  THEN ;

x^10 is broken down to three squarings and one multiplication \( \left(x\left((x^2)^2\right)\right)^2 \) hence 4 multiplications suffice.

- Rob

"I count on old friends" -- HP 71B,Prime|Ti VOY200,Nspire CXII CAS|Casio fx-CG50...|Sharp PC-G850,E500,2500,1500,14xx,13xx,12xx...
Visit this user's website Find all posts by this user
Quote this message in a reply
04-23-2023, 01:01 PM
Post: #17
RE: Small challenge
(04-23-2023 11:10 AM)robve Wrote:  Indeed! It is common to find exponentiation by squaring for integer powers, which tends to be more accurate than repeated multiplication and log*exp closed forms.

It's pretty straightforward to do.

We can use the Chains of Recurrences algebra to optimize sequence evaluations such as x^10. We only need 10 additions to produce the next value in the sequence.

To expand \( x^{10} \) to CR form, let \( x \) be the integer sequence CR \( x =\{1,+,1\} \) expand to the CR \( \{1,+,1\}\times\{1,+,1\}\times\{1,+,1\}\times\{1,+,1\}\times\{1,+,1\}\times\{1,+​,1\}\times\{1,+,1\}\times\{1,+,1\}\times\{1,+,1\}\times\{1,+,1\} \). Simplify using the CR rule \( \{\phi_0,+,f_1\} \times \{\psi_0,+,g_1\} \Rightarrow
\{\phi_0\times\psi_0,+,\{\phi_0,+,f_1\}\times g_1+\{\psi_0,+,g_1\}\times f_1+f_1\times g_1\} \) giving the polynomial CR \( \{1,+,1023,+, 57002,+, 874500,+, 5921520,+, 21538440,+, 46070640,+, 59875200,+, 46569600,+, 19958400,+, 3628800 \} \). Note that each value is produced with just 10 additions.

Written in C:
Code:
#include <stdio.h>
#include <stdlib.h>
int main()
{
  uint64_t r[11] = {1, 1023, 57002, 874500, 5921520, 21538440, 46070640, 59875200, 46569600, 19958400, 3628800 };
  int i, j;
  for (i = 0; i < 24; ++i)
  {
    printf("%llu\n", r[0]);
    for (j = 0; j < 10; ++j)
      r[j] += r[j+1];
  }
}

Output:
1
1024
59049
1048576
9765625
60466176
282475249
1073741824
3486784401
10000000000
25937424601
61917364224
137858491849
289254654976
576650390625
1099511627776
2015993900449
3570467226624
6131066257801
10240000000000
16679880978201
26559922791424
41426511213649
63403380965376


With floating point we need to be a bit careful with error accumulation in long CR iterations. The polynomial case, such as \( x^{10} \), is stable. The product case such as \( 10^x \) may not be stable. The above code uses integers, which is always stable (but may overflow eventually).

- Rob

"I count on old friends" -- HP 71B,Prime|Ti VOY200,Nspire CXII CAS|Casio fx-CG50...|Sharp PC-G850,E500,2500,1500,14xx,13xx,12xx...
Visit this user's website Find all posts by this user
Quote this message in a reply
04-23-2023, 01:56 PM
Post: #18
RE: Small challenge
(04-23-2023 01:01 PM)robve Wrote:  We can use the Chains of Recurrences algebra to optimize sequence evaluations such as x^10. We only need 10 additions to produce the next value in the sequence.

To expand \( x^{10} \) to CR form, let \( x \) be the integer sequence CR \( x =\{1,+,1\} \) expand to the CR \( \{1,+,1\}\times\{1,+,1\}\times\{1,+,1\}\times\{1,+,1\}\times\{1,+,1\}\times\{1,+​,1\}\times\{1,+,1\}\times\{1,+,1\}\times\{1,+,1\}\times\{1,+,1\} \). Simplify using the CR rule \( \{\phi_0,+,f_1\} \times \{\psi_0,+,g_1\} \Rightarrow
\{\phi_0\times\psi_0,+,\{\phi_0,+,f_1\}\times g_1+\{\psi_0,+,g_1\}\times f_1+f_1\times g_1\} \) giving the polynomial CR \( \{1,+,1023,+, 57002,+, 874500,+, 5921520,+, 21538440,+, 46070640,+, 59875200,+, 46569600,+, 19958400,+, 3628800 \} \). Note that each value is produced with just 10 additions.

Now you may ask, what's the difference here with difference tables? These CR coefficients look familiar. And you are correct! Polynomial CR forms are identical to difference table upper diagonals of polynomials evaluated over equidistant grids. CRs are not restricted to polynomials, it's just that CRs of polynomials are easy to construct with difference tables or with the CR algebra.

A difference table for the sequence shown in the picture reveals that the sequence is an x^10 polynomial since the 11th difference column is zero:
   

Not surprising, starting from x=1 you get the diagonal that matches the CR coefficients:
   

- Rob

"I count on old friends" -- HP 71B,Prime|Ti VOY200,Nspire CXII CAS|Casio fx-CG50...|Sharp PC-G850,E500,2500,1500,14xx,13xx,12xx...
Visit this user's website Find all posts by this user
Quote this message in a reply
04-23-2023, 02:08 PM
Post: #19
RE: Small challenge
That's remarkable!
Find all posts by this user
Quote this message in a reply
04-23-2023, 02:13 PM (This post was last modified: 04-23-2023 04:19 PM by J-F Garnier.)
Post: #20
RE: Small challenge
Thanks all for your interest!

As many of you found it (sometimes easily, too easily!) the formula to get the series is n^10 for n=5 to 24.

Trying to reproduce the series on a common Saturn-based calculator quickly shows that the term n^10 for n=23 is computed with an error of 1 ulp, whereas the 9835 correctly gives the right value (in the sense of closest representation of the exact value).
Congrat to Thomas and Valentin for finding the unexpected workaround n^5^2 !

Let's test more machines:
    9835/9845, Series 80, HP-75: 23^10 = 4.14265112136E13 (correct value)
    HP-71B, all Saturn-based machines (in approx. mode): 4.14265112137E13 (1 ulp error)
    HP-35S: 23^10 = 4.14265112136E13 (back to the correct value)
The real surprise to be found was that the HP-35S is giving back the right answer for 23^10 !
I don't have a 33S to test, but I expect it to give the same value as the 35S.

I found it quite funny that old computers of the late 70 / early 80 on one side, and the poor unloved 35S on the other side,
all give a better result (for that particular case) than the whole generation of Saturn-based machines that spanned about 3 decades.

What we can learn from all this:
    The implementation of the exponentiation changed between the Capricorn platform (Series 80 / 75C) and the Saturn machines (starting with the 71B).

    Most of the time, the 35S math code is giving the same result as the 32SII (as surely intended), but since it's a rewrite and not a emulation, it can sometimes give slightly different (in this case better) answers.
J-F
Visit this user's website Find all posts by this user
Quote this message in a reply
Post Reply 




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