Post Reply 
Micro-challenge: Special Event
12-16-2022, 10:03 PM
Post: #1
Micro-challenge: Special Event
Something will happen next week which will not happen again in most of our lifetimes. It is not a visible phenomenon but everyone on Earth will be able to experience it. This is a very simple puzzle, no research required, just a bit of thought.

Not related to HP calculators per se but to subjects that are frequently discussed on these Forums.
Find all posts by this user
Quote this message in a reply
12-19-2022, 03:46 PM
Post: #2
RE: Micro-challenge: Special Event
Any further hint?

I am thinking only about the dates (the it depends on the format of the date) that may make a neat combination, but I do not see any special one.

If I try to remember the discussed topics on the forum I cannot pick any that is often discussed that is related to this week dates (if it was March, I could have said PI day).

Wikis are great, Contribute :)
Find all posts by this user
Quote this message in a reply
12-19-2022, 04:05 PM
Post: #3
RE: Micro-challenge: Special Event
I see the head post is timestamped at 22:03 - which perhaps just missed the intended time!
Find all posts by this user
Quote this message in a reply
12-19-2022, 06:34 PM
Post: #4
RE: Micro-challenge: Special Event
(12-19-2022 04:05 PM)EdS2 Wrote:  I see the head post is timestamped at 22:03 - which perhaps just missed the intended time!

That must be GMT, it was 16:40 here. You are both on the right track, though. Smile
Find all posts by this user
Quote this message in a reply
12-22-2022, 03:04 PM
Post: #5
RE: Micro-challenge: Special Event
Only a few hours left! Final hint: do not think in base 10.
Find all posts by this user
Quote this message in a reply
12-22-2022, 03:34 PM
Post: #6
RE: Micro-challenge: Special Event
This week has date that only use 0,1,2.
Next time this will happen is 77 years later: 1/1/2100

Today, MMDDYYYY format: (12222022)-3 = -(1111)10
Find all posts by this user
Quote this message in a reply
12-22-2022, 08:37 PM
Post: #7
RE: Micro-challenge: Special Event
Bingo! More specifically, at 22:22:22 or 11:22:22 pm (one hour later) depending on whether one uses 24- or 12-hour format. Also neat that it's a repunit (or q-integer) in base 10 when expressed in base -3, which I hadn't noticed. Thanks, Albert!
Find all posts by this user
Quote this message in a reply
12-22-2022, 08:41 PM
Post: #8
RE: Micro-challenge: Special Event
(12-22-2022 08:37 PM)John Keith Wrote:  Bingo! More specifically, at 22:22:22 or 11:22:22 pm (one hour later) depending on whether one uses 24- or 12-hour format. Also neat that it's a repunit (or q-integer) in base 10 when expressed in base -3, which I hadn't noticed. Thanks, Albert!

What's a negative base???

(...he asked, slightly fearful of a mind-bending reply...)

--Bob Prosperi
Find all posts by this user
Quote this message in a reply
12-22-2022, 10:05 PM
Post: #9
RE: Micro-challenge: Special Event
Negative base is not special. It is coded the same way.

n = d0 + b*(d1 + b*(d2 + b*(d3 + b*(d4 + ...

1111 = 1-6*(1-6*(1-6*(1-6*(1)))) = (11111)-6
Find all posts by this user
Quote this message in a reply
12-23-2022, 04:02 AM
Post: #10
RE: Micro-challenge: Special Event
For input

1953
1
-10

on the 49G, this programme

https://www.hpmuseum.org/forum/thread-40...light=XdYB

returns

-10:{ -1 9 -5 3 "." }
Find all posts by this user
Quote this message in a reply
12-23-2022, 07:08 AM
Post: #11
RE: Micro-challenge: Special Event
Ah, I was thinking of a palindrome: 2022-12-22 21:22:02... but probably they turn up more often. And as ever, one sees variability in date formats.

So the base 3 observation is nice for being date-format neutral!

And the idea that it won't happen for a long time is subtle - it doesn't say that it hasn't happened more recently! John could have posted three days earlier, but no earlier than that...
Find all posts by this user
Quote this message in a reply
12-23-2022, 06:45 PM
Post: #12
RE: Micro-challenge: Special Event
(12-22-2022 10:05 PM)Albert Chan Wrote:  Negative base is not special. It is coded the same way.

n = d0 + b*(d1 + b*(d2 + b*(d3 + b*(d4 + ...

1111 = 1-6*(1-6*(1-6*(1-6*(1)))) = (11111)-6

Thanks for replying Albert, and while this answer no doubt is useful to math-heads, I was hoping for an English explanation of the meaning of a negative base. Equations can show and even prove many things, tragically only a small percent of them are meaningful to the rest of is.

--Bob Prosperi
Find all posts by this user
Quote this message in a reply
12-24-2022, 05:43 PM (This post was last modified: 12-24-2022 05:43 PM by johnb.)
Post: #13
RE: Micro-challenge: Special Event
(12-23-2022 06:45 PM)rprosperi Wrote:  Thanks for replying Albert, and while this answer no doubt is useful to math-heads, I was hoping for an English explanation of the meaning of a negative base. Equations can show and even prove many things, tragically only a small percent of them are meaningful to the rest of is.

Okay, here you go! Merry Christmas, Bob!

Being super pedantic here, so that everything is clear.

We already know how to handle positive bases. Base 10 means that there the 1's place (10^0), the 10's place (10^1), 100's place (10^2), and so on. Same for base 2: 2^0, 2^1, and so on.

[At this point, the reader is supposed to say, "DUH, John. So what?"]

So let's take base -8.

(-8)^0 = (+)1's place.
(-8)^1 = -8's place.
(-8)^2 = (+)64's place.
(-8)^3 = -512's place.

Thinking about it a bit, it makes counting a BEAR.

0,1,2,3,4,5,6,7, then what? -10? Yup. Because the leading 1 here is in the -8's place, so you have to negate the entire string of digits.

Encoding and decoding by hand is a bear, too. (So glad we have calculators!)

What is 411 (base 10) in base -8?

Daily drivers: 15c, 32sII, 35s, 41cx, 48g, WP 34s/31s. Favorite: 16c.
Latest: 15ce, 48s, 50g. Gateway drug: 28s found in yard sale ~2009.
Find all posts by this user
Quote this message in a reply
12-24-2022, 05:50 PM (This post was last modified: 12-24-2022 05:51 PM by johnb.)
Post: #14
RE: Micro-challenge: Special Event
For those new to negative bases, HINT: the rounding rules are screwy.

411/64 = 6.4219, so if this were base 8, the first digit would be 6 and the digits to the right would handle the 0.4219 remainder.

But this is base -8, and the first digit isn't 6...

Daily drivers: 15c, 32sII, 35s, 41cx, 48g, WP 34s/31s. Favorite: 16c.
Latest: 15ce, 48s, 50g. Gateway drug: 28s found in yard sale ~2009.
Find all posts by this user
Quote this message in a reply
12-24-2022, 07:20 PM
Post: #15
RE: Micro-challenge: Special Event
(12-24-2022 05:50 PM)johnb Wrote:  411/64 = 6.4219, so if this were base 8, the first digit would be 6 ...
But this is base -8, and the first digit isn't 6...

Algorithm for base digits are the same, if we do least significant digits first.

411 = -51*-8 + 3
-51 = 7*-8 + 5
7 = 0*-8 + 7

We can also do positive base, negate "odd" digits for negative base, then normalize.
Below, bar on top signified negative number.

\( 411/64 = (6.33)_8 = (6.\bar{3}3)_\bar{8} + (1.8)_\bar{8}= (7.53)_\bar{8}\)

Gerald H example, 1953 to base -10

Cas> [0, -1, 9, -5, 3]
Cas> Ans + [1, 10, 1, 10]      → [1, 9, 10, 5, 3]
Cas> Ans - [0, 1, 10]             → [1, 8, 0, 5, 3]
Cas> horner(Ans, -10)           → 1953 // confirmed (18053)-10 = 1953

BTW, radix can be non-integers too. see Weird Number Bases
Find all posts by this user
Quote this message in a reply
12-26-2022, 12:31 AM
Post: #16
RE: Micro-challenge: Special Event
(12-24-2022 05:43 PM)johnb Wrote:  
(12-23-2022 06:45 PM)rprosperi Wrote:  Thanks for replying Albert, and while this answer no doubt is useful to math-heads, I was hoping for an English explanation of the meaning of a negative base. Equations can show and even prove many things, tragically only a small percent of them are meaningful to the rest of is.

Okay, here you go! Merry Christmas, Bob!

Being super pedantic here, so that everything is clear.

We already know how to handle positive bases. Base 10 means that there the 1's place (10^0), the 10's place (10^1), 100's place (10^2), and so on. Same for base 2: 2^0, 2^1, and so on.

[At this point, the reader is supposed to say, "DUH, John. So what?"]

So let's take base -8.

(-8)^0 = (+)1's place.
(-8)^1 = -8's place.
(-8)^2 = (+)64's place.
(-8)^3 = -512's place.

[snip]

So it's a bit like Roman numerals where some letters mean 'subtract from the following one'. Who knew the Romans were so advanced as to be using pseudo-negative bases? ;-)
Find all posts by this user
Quote this message in a reply
12-26-2022, 02:00 PM (This post was last modified: 12-26-2022 02:03 PM by Thomas Klemm.)
Post: #17
RE: Micro-challenge: Special Event
(12-24-2022 07:20 PM)Albert Chan Wrote:  BTW, radix can be non-integers too.

This example is from \(\pi\) Unleashed.
Quote:6.1 The spigot algorithm in detail

(…)

But occasionally we come across numbers in which this factor is not constant,
e.g. the numbers which correspond to the expression "2 weeks, 3 days, 4 hours and 5 minutes".
Because the ratio of weeks to days = 1 : 7, days to hours = 1 : 24 and hours to minutes = 1 : 60,
when converting this number to a decimal number (with the unit "weeks"),
three different factors have to be considered, namely 1/7, 1/24 and 1/60.
Hence, to answer the question how many weeks are in the example, we have to calculate the following:

\(
\begin{align}
2 + \frac{1}{7}\left(3 + \frac{1}{24}\left(4 + \frac{1}{60}\left(5\right)\right)\right)
\end{align}
\)

The Spigot algorithm makes it possible to calculate the base-10 representation digit by digit.
In each step, the "digits" are multiplied by 10 and divided by their basis.
Quote:On every division, the remainder is retained and the integer quotient is carried over to the next decimal place.

Here's a Python program that does this:
Code:
def spigot(d, b, n):
    z = []
    for _ in range(n):
        for i in range(len(d)):
            d[i] *= 10
        for i in range(len(d)-1, 0, -1):
            d[i-1] += int(d[i] / b[i])
            d[i] %= b[i]
        z.append(int(d[0] / b[0]))
        d[0] %= b[0]
    return z

Example

Code:
b = [7, 24, 60]
d = [3, 4, 5]

spigot(d, b, 20)

Code:
[4, 5, 2, 8, 7, 6, 9, 8, 4, 1, 2, 6, 9, 8, 4, 1, 2, 6, 9, 8]

Compare this to the calculated value:
Code:
2.45287 698412 698412 69841 …
Keep in mind that the initial digit 2 is omitted.

We can list the intermediate results and see how the calculation becomes periodic:
Code:
[3, 16, 50]
[2, 0, 20]
[6, 3, 20]
[5, 9, 20]
[4, 21, 20]
[6, 21, 20]
[5, 21, 20]
[2, 21, 20]
[0, 21, 20]
[1, 21, 20]
[4, 21, 20]
[6, 21, 20]
[5, 21, 20]
[2, 21, 20]
[0, 21, 20]
[1, 21, 20]
[4, 21, 20]
[6, 21, 20]
[5, 21, 20]
[2, 21, 20]

Calculating Digits of \(\pi\)

Here's the interesting relation to \(\pi\):

\(
\begin{align}
\pi = 2 + \frac{1}{3}\left(2 + \frac{2}{5}\left(2 + \frac{3}{7}\left(2 + \cdots \right)\right)\right)
\end{align}
\)

Thus we can write in this specific basis: \(\pi = 2.2222\cdots\).

We can use the same function to calculate \(\pi\) digit by digit:
Code:
from mpmath import mp

n = 20
N = 10 * n // 3 + 1
mp.dps = n

b = [mp.mpf(2*k+1)/k for k in range(1, N+1)]
d = [2] * N

spigot(d, b, n)

Code:
[11, 4, 1, 5, 9, 2, 6, 5, 3, 5, 8, 9, 7, 9, 3, 2, 3, 8, 4, 6]

Imperial Units

There are many ways to use this algorithm when it comes to converting imperial units:

[Image: attachment.php?aid=11530]


Warning: I've skipped over some details. So I recommend using a proper implementation instead of my Python program if you want to calculate more digits of \(\pi\).


Attached File(s) Thumbnail(s)
   
Find all posts by this user
Quote this message in a reply
12-26-2022, 07:59 PM
Post: #18
RE: Micro-challenge: Special Event
(12-24-2022 07:20 PM)Albert Chan Wrote:  BTW, radix can be non-integers too. see Weird Number Bases

Interesting link, thanks! Here's a negative base that will really make your heads explode: NegaFibonacci
Find all posts by this user
Quote this message in a reply
12-27-2022, 08:28 PM (This post was last modified: 12-27-2022 08:29 PM by John Keith.)
Post: #19
RE: Micro-challenge: Special Event
(12-26-2022 02:00 PM)Thomas Klemm Wrote:  This example is from \(\pi\) Unleashed.
Quote:6.1 The spigot algorithm in detail

(…)

But occasionally we come across numbers in which this factor is not constant,
e.g. the numbers which correspond to the expression "2 weeks, 3 days, 4 hours and 5 minutes".
Because the ratio of weeks to days = 1 : 7, days to hours = 1 : 24 and hours to minutes = 1 : 60,
when converting this number to a decimal number (with the unit "weeks"),
three different factors have to be considered, namely 1/7, 1/24 and 1/60.
Hence, to answer the question how many weeks are in the example, we have to calculate the following:

\(
\begin{align}
2 + \frac{1}{7}\left(3 + \frac{1}{24}\left(4 + \frac{1}{60}\left(5\right)\right)\right)
\end{align}
\)


Example

Code:
b = [7, 24, 60]
d = [3, 4, 5]

spigot(d, b, 20)

Code:
[4, 5, 2, 8, 7, 6, 9, 8, 4, 1, 2, 6, 9, 8, 4, 1, 2, 6, 9, 8]

Compare this to the calculated value:
Code:
2.45287 698412 698412 69841 …
Keep in mind that the initial digit 2 is omitted.

The expression in your example can be reduced to a single fraction, in this case 4945/2016, hence the repeating decimals. This is a natural fit for Gerald H's program ratio2decimal. Here is a simple program using similar inputs to your Python program. Usage: HP 49 or 50 in exact mode.
Level 3: the leading digit, 0 if there is none, in this case 2.
Level 2: a list of bases, e.g. {7 24 60}
Level 1: a list of "digits", e.g. {3 4 5}

Result: a string, "2.45287_698412_", where the underscores surround the repeating digits.

Code:

\<< DUP SIZE \-> n
  \<< 2.
    \<<                     @ Empty program for DOLIST interleaves lists.
    \>> DOLIST EVAL         @ Dump all terms onto stack.
    1. n
    START SWAP / +          @ Divide and sum over each pair of terms.
    NEXT EVAL RATIO2DECIMAL @ Convert to decimal with repeating digits if any.
  \>>
\>>
Find all posts by this user
Quote this message in a reply
12-27-2022, 10:42 PM
Post: #20
RE: Micro-challenge: Special Event
(12-27-2022 08:28 PM)John Keith Wrote:  4945/2016, hence the repeating decimals ,,,,
Result: a string, "2.45287_698412_", where the underscores surround the repeating digits.

Assuming fraction fully reduced., here is the math to convert to repeating decimals.

Denominator 2016 = (25 * 50) * 63

non-repeating digits (after decimal point) = max(5, 0) = 5

We wanted smallest exponent k, such that 10^k ≡ 1 (mod 63)
1 (mod 63) is equivalent to 1 (mod 9) and 1 (mod 7), but 10^k ≡ 1^k ≡ 1 (mod 9)

1/7 = 0.(142857)      --> repeating digits = k = order of 10 (mod 7) = 6

lua> 4945 / 2016
2.452876984126984  --> 4945/2016 = 2. 45287 (698412)
Find all posts by this user
Quote this message in a reply
Post Reply 




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