Post Reply 
Little explorations with HP calculators (no Prime)
12-31-2018, 08:20 PM
Post: #341
RE: Little explorations with HP calculators (no Prime)
Hmm, am I wrong when I think that 71 matches should be simply impossible?

Wikis are great, Contribute :)
Find all posts by this user
Quote this message in a reply
12-31-2018, 08:36 PM
Post: #342
RE: Little explorations with HP calculators (no Prime)
(12-31-2018 08:20 PM)pier4r Wrote:  Hmm, am I wrong when I think that 71 matches should be simply impossible?

Here's a straightforward way to create 21 arrangements where all starting positions (1-71) result in a "match":

1) Find all unique arrangements of a combination of 5 blue and 2 white balls:
(1, 1, 1, 1, 0, 0, 1)
(0, 1, 1, 1, 0, 1, 1)
(1, 1, 0, 0, 1, 1, 1)
(1, 1, 1, 0, 1, 1, 0)
(1, 0, 1, 0, 1, 1, 1)
(0, 1, 1, 0, 1, 1, 1)
(1, 1, 1, 1, 0, 1, 0)
(1, 1, 0, 1, 1, 0, 1)
(1, 0, 1, 1, 1, 0, 1)
(1, 1, 1, 0, 0, 1, 1)
(0, 1, 1, 1, 1, 0, 1)
(1, 1, 0, 1, 1, 1, 0)
(1, 0, 1, 1, 1, 1, 0)
(1, 0, 0, 1, 1, 1, 1)
(0, 1, 1, 1, 1, 1, 0)
(0, 0, 1, 1, 1, 1, 1)
(0, 1, 0, 1, 1, 1, 1)
(1, 1, 1, 1, 1, 0, 0)
(1, 1, 1, 0, 1, 0, 1)
(1, 1, 0, 1, 0, 1, 1)
(1, 0, 1, 1, 0, 1, 1)

2) For each of those groups, repeat the indicated pattern 20 times to form a particular arrangement of 100 1s (blue) and 40 0s (white)

Each resulting 140-ball arrangement has 71 "matches" for this problem. In other words, any contiguous subgroup of 70 elements from any of those lists will result in a group containing 50 1s and 20 0s.

These aren't the only ones, though. I believe the same logic applies if you start with a set of 10 1s and 4 0s, stepping through each unique arrangement (this time repeated only 10 times). There are undoubtedly others, but I haven't taken the time to verify them.
Find all posts by this user
Quote this message in a reply
01-13-2019, 10:48 AM (This post was last modified: 01-13-2019 11:07 AM by pier4r.)
Post: #343
RE: Little explorations with HP calculators (no Prime)
Another little problem that may be solved with a calculator, although the idea is that you try before without.

we have the numbers:
1 2 3 4 5 6 7 8

and we multiply those adjacent to one another, getting:
1x2 2x3 3x4 etc...
2 6 12 20 30 42 56
notice that now we have 7 numbers, not 8.

then we continue in this way until we have only one number.
Is this number smaller than 10^80 ?

if possible use spoilers as usual

Code:





















for example at my first estimation I estimated the last number would 
have an upper bound of 128 digits. Because we have:
line 1 max 8.
line 2 max 56
line 3 max 2352
thus line 4, 8 digits
line 5, 16
line 6, 32
line 7, 64
line 8, 128

Theb I refined it utilizing all the numbers trying to estimate the upper bound of theresulting multiplication in digits.
line 1: all 1 digits,
line 2: nnumbers with 1 digit and 2 digits
line 3: numbers from 2 to 4 digits
line 4: numbers from 4 to 8 digits
line 5: numbers from 9 to 15 digits
...
line 8: 96 digits


with the sharp el 506w I got ~ 6.64 e77 . So far away from my estimates.
And it appears I may have made a mistake while inputting numbers on the 506w.

Wikis are great, Contribute :)
Find all posts by this user
Quote this message in a reply
01-13-2019, 01:44 PM
Post: #344
RE: Little explorations with HP calculators (no Prime)
Code:
Spoiler alert!










Using the HP-48GX:

{ 1 2 3 4 5 6 7 8 }
« 1 7
  START 2
    « *
    » DOSUBS
  NEXT
»
{ 6.64903611917E80 }


Using binomial coefficients the product can be written as:

1^1 * 2^7 * 3^21 * 4^35 * 5^35 * 6^21 * 7^7 * 8^1 =
8^1 * 14^7 * 18^21 * 20^35 =
6.64903611913E80


Using the common logarithm we can calculate:

 8:    0.90309 *  1 =  0.90309
14:    1.14613 *  7 =  8.02290
18:    1.25527 * 21 = 26.36072
20:    1.30103 * 35 = 45.53605
                      --------
                      80.82276

Even if we only knew the common logarithm of 2, 3 and 7 we can still calculate the needed values:

 2:    0.30103
 3:    0.47712
 7:    0.84510

 8:    0.90309 = 3 * 0.30103
 9:    0.95424 = 2 * 0.47712
18:    1.25527 = 0.95424 + 0.30103
14:    1.14613 = 0.84510 + 0.30103
20:    1.30103 = 1 + 0.30103

So the number is not smaller than 10^80.
Find all posts by this user
Quote this message in a reply
01-13-2019, 01:48 PM (This post was last modified: 01-13-2019 04:56 PM by Albert Chan.)
Post: #345
RE: Little explorations with HP calculators (no Prime)
Code:
Spoiler alert!










Brute force way:
lst = range(1,9)
while len(lst) > 1: lst = [ i*j for i,j in zip(lst, lst[1:]) ]
print float(lst[0]) ==> 6.64903611914e+80

Distribution way:
Final number should have a binomial distribution of factors:
1 and 8: 1 times
2 and 7: 7 times
3 and 6: 7*6/2 = 21 times
4 and 5: 21*5/3 = 35 times

print 8. * 14**7 * 18**21 * 20**35 ==> 6.64903611914e+80

If only required to confirm above number > 1e80:

X = 8 * (14*18*18*18)**7 * 20**35 > 8 * (16**4)**7 * 2**35 * 1e35

log10(X) > log10(2) * (3 + 4*4*7 + 35) + 35 > 0.301 * 150 + 35 = 80.15 > 80
Find all posts by this user
Quote this message in a reply
01-13-2019, 05:05 PM
Post: #346
RE: Little explorations with HP calculators (no Prime)
I didn't attempt to apply any symbolic analysis first, as my limited "toolbox" in that regard didn't offer any obvious hints.

Seeing the problem description did, though. So I came up with the following code to produce the numeric result:
Code:











\<<
   WHILE
      DUP SIZE 1. >
   REPEAT
      2 { * } DOSUBS
   END
   EVAL
\>>

The code assumes the initial list is already on the stack before execution. Although I didn't look at the other solutions before putting this together, it does bear a striking resemblance to Thomas' approach.
Find all posts by this user
Quote this message in a reply
01-13-2019, 07:00 PM (This post was last modified: 01-13-2019 07:00 PM by pier4r.)
Post: #347
RE: Little explorations with HP calculators (no Prime)
the idea of using the factors of the final number and then going with the log is a nice one.

Wikis are great, Contribute :)
Find all posts by this user
Quote this message in a reply
01-13-2019, 08:27 PM (This post was last modified: 01-14-2019 09:23 PM by John Keith.)
Post: #348
RE: Little explorations with HP calculators (no Prime)
(01-13-2019 05:05 PM)DavidM Wrote:  I didn't attempt to apply any symbolic analysis first, as my limited "toolbox" in that regard didn't offer any obvious hints.

Seeing the problem description did, though. So I came up with the following code to produce the numeric result:


The code assumes the initial list is already on the stack before execution. Although I didn't look at the other solutions before putting this together, it does bear a striking resemblance to Thomas' approach.

I just looked at this thread, and (un)surprisingly my program was exactly the same as yours.

The result is the 8th term of A064320, the description of which is very similar to Thomas's derivation. Many interesting ideas here!

Additionally, the same operation with + instead of * yields A001792.
Find all posts by this user
Quote this message in a reply
01-28-2019, 01:38 PM
Post: #349
RE: Little explorations with HP calculators (no Prime)
While programming a bit in RPL after a long pause I love the possibility to abuse the IF clause (or whatever clause), if needed (read: until I find a better way) nesting an IF in an IF clause sounds glorious.

I don't believe it is good code - to be more clean I should go maybe with IFERR or a better clause structure - but the fact that is possible is amazing.

Wikis are great, Contribute :)
Find all posts by this user
Quote this message in a reply
01-31-2019, 04:07 PM
Post: #350
RE: Little explorations with HP calculators (no Prime)
Interesting...

With conn4x and the hp50g, if I edit directories as text, after they get big enough I get syntax errors that otherwise I don't get. I was not yet able to pinpoint the size, could also depend on the memory free on the device.

Solution: create single variables and edit them directly.

Wikis are great, Contribute :)
Find all posts by this user
Quote this message in a reply
05-27-2019, 04:47 PM
Post: #351
RE: Little explorations with HP calculators (no Prime)
So I was searching for functions for probability distributions built in RPL (hp 50G). For instance the Poisson is not part of the RPL built in functions.

A brief search over hpmuseum.org and hpcalc.org points to the following libraries:

Statspack 1.3 https://www.hpcalc.org/details/1285 (2017)
StatPack 49 https://www.hpcalc.org/details/4911 (2001)
(of course I can always code the functions on my own to refresh them)

Interestingly, I did not find any forum post, at least through google, mentioning RPL code for probability distributions.

Does anyone have experience with other libraries or those two are good enough?

Wikis are great, Contribute :)
Find all posts by this user
Quote this message in a reply
05-27-2019, 06:06 PM (This post was last modified: 05-27-2019 06:09 PM by pier4r.)
Post: #352
RE: Little explorations with HP calculators (no Prime)
Together with the question about the statistical distributions for RPL (see previous posts) another question.

In RPL is it possible to have different stacks?

Sort of:
use the stack, save its state to a variable A, clear . This without knowing how deep the stack is, otherwise one could just pack everything in a list.
Then use the stack, save its state to a variable B, clear.
Recall A, populate the stack again, work on it, once again save the state to A, clear.

etc...

Or better maybe DEPTH \->LIST would always work, but then it ends up packing and unpacking a list that slow down things if the list is huge and it is no different than doing 'listVar' object STO+ .

This because, as usual, collecting results in a loop while doing other operations is not happening for free and sometimes even vectors are clumsy to use.

Wikis are great, Contribute :)
Find all posts by this user
Quote this message in a reply
05-28-2019, 11:09 AM (This post was last modified: 05-28-2019 11:11 AM by 3298.)
Post: #353
RE: Little explorations with HP calculators (no Prime)
With UserRPL you're most likely stuck with DEPTH \->LIST 'varname' STO for saving and 'varname' RCL OBJ\-> DROP for restoring the stack. \->LIST is indeed a bottleneck here due to all the copying it does, though STOring large objects into global variables does some copying too. (On the other hand, moving things into globals gets them out of the way of the garbage collector, which can shave off a few seconds in later parts of the program. I think that's been mentioned in one of your threads already.)

SysRPL gives you more tools though, including the Virtual Stack (pretty much a stack of stacks). This allows you to not only save and restore parts of or the entirety of your stack, but it also grants some limited access (can't change the number of items, basically) to the contents of saved stacks. You can simply ask for the n-th level of the most recent saved stack, or even overwrite that spot with something else. This is sometimes employed in place of complex stackrobatics e.g. when so-called "meta objects" (a series of objects followed by their count, for instance an exploded list) are involved.

Come to SysRPL, we have all the awesome toys. Wink
Find all posts by this user
Quote this message in a reply
05-28-2019, 07:18 PM
Post: #354
RE: Little explorations with HP calculators (no Prime)
While I don't doubt that sysRPL is even more powerful than userRPL, the latter is vast enough for my needs. Also diving too much in the RPL world (and I am already at least down to my knee) is dangerous. Already for all little questions I tend to use the 50g instead of using more sane tools (Hp PPL is already much more sane, even with lists limited to 10k objects, as one could nest them). Again, because the digesting speed of mine is slower than the computing speed of the 50g due to the little time available. And still there is newRPL behind the corner!

Wikis are great, Contribute :)
Find all posts by this user
Quote this message in a reply
07-17-2021, 06:13 PM
Post: #355
RE: Little explorations with HP calculators (no Prime)
Little experience today - maybe already known but maybe it helps to share it - I wanted to connect the 50g to the computer through the connectivity kit (with a win xp system reserved for calculators).

I couldn't connect it, on the stack there were 200 objects (the ram free was 126k), I cleaned the stack and then it worked.

Wikis are great, Contribute :)
Find all posts by this user
Quote this message in a reply
Post Reply 




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