Live data from Hacker News

987654321 / 123456789

johndcook.com

81–90 of 120 posts

Re: 987654321 / 123456789

#81
post #8
post #4

I like to think of 0.987654... and 0.123456... as infinite series which simplify to 80/81 and 10/81, hence the ~8 ratio.

I didn't get where this comes from until I saw the second answer from the StackOverflow question another commenter shared. https://math.stackexchange.com/a/2268896 Apparently 1/9^2 is well known to be 0.12345679(012345679)... EDIT: Yes it's missing the 8 (I wrote it wrong intially): https://math.stackexchange.com/questions/994203/why-do-we-mi... Interesting how it works out but I don't think it is anywhere close to a…

Also 12345679*x*9 = xxxxxxxxx

Eg 12345679*6*9 = 666666666

Re: 987654321 / 123456789

#82
post #8

Earlier quoted context omitted.

I didn't get where this comes from until I saw the second answer from the StackOverflow question another commenter shared. https://math.stackexchange.com/a/2268896 Apparently 1/9^2 is well known to be 0.12345679(012345679)... EDIT: Yes it's missing the 8 (I wrote it wrong intially): https://math.stackexchange.com/questions/994203/why-do-we-mi... Interesting how it works out but I don't think it is anywhere close to a…

Also 12345679*x*9 = xxxxxxxxx Eg 12345679*6*9 = 666666666

I think your formatting is off.

Re: 987654321 / 123456789

#83

Somewhat interesting, 123456789 * 8 is 987654312 (the last two digits are swapped). This holds for other bases as well: 0x123456789ABCDEF * 14 is 0xFEDCBA987654312. Also, adding 123456789 to itself eight times on an abacus is a nice exercise, and it's easy to visually control the end result.

> the last 2 digits are swapped

They are also +9 away from being in order.

And then 12345678 * 8 is 98765424 which is +9 away from also being in order.

Re: 987654321 / 123456789

#84
TIL 0x denotes hexadecimal E.g.

> 0xFEDCBA987654321 / 0x123456789ABCDEF

(somehow I'd seen the denotation for years yet never actually known what it was).

Re: 987654321 / 123456789

#85
post #60

> The exact ratio is not 14, but it’s as close to 14 as a standard floating point number can be. How do you get around limitations like that in science?

For rational numbers, Python has a Fraction class in the standard library that performs exact integer arithmetic:

    >>> from fractions import Fraction
    >>> f = Fraction(0xFEDCBA987654321, 0x123456789ABCDEF)
    >>> f%1
    Fraction(1, 5465701947765793)
    >>> f - f%1
    Fraction(14, 1)
That shows that 0xFEDCBA987654321 / 0x123456789ABCDEF = 14 + 1/5465701947765793 exactly.

    >>> math.log(5465701947765793, 2)
    52.279328213174445
Shows that the denominator requires 52 bits which is slightly more than the number of mantissa bits in a 64-bit floating point number, so the result gets rounded to 14.0 due to limited precision.

Re: 987654321 / 123456789

#87
post #74

Earlier quoted context omitted.

The even simpler example is more striking imo. (147 + 369) / 2 = 258 and (741 + 963) / 2 = 852

But this is obvious? (741 + 963)/2 = (700+900)/2 + (40+60)/2 + (1+3)/2, it's just average in each decimal place.

Obvious now and really cool in hindsight.

Re: 987654321 / 123456789

#88

Earlier quoted context omitted.

The even simpler example is more striking imo. (147 + 369) / 2 = 258 and (741 + 963) / 2 = 852

The decimal digits clearly have a conspiracy going on.

That would work in any base, I even think we would find way more interesting coincidences in base 12 (as Sumerians preferred), because it's divisible by 2,3,4,6.

It's unfortunate that we have 5 fingers.

Re: 987654321 / 123456789

#89
Here is a correction which m akes it exactly 8.0:

  > 987654320 / 123456790
  8.0
I've decremented the numerator and incremented the denominator:

   ( 987654321 - 1 )
   -----------------  = 8
   ( 123456789 + 1 )
Works in other bases. TXR Lisp, base 4:

  1> (/ (poly 4 '(3 2 1)) (poly 4 '(1 2 3)))
  2.11111111111111
  2> (/ (poly 4 '(3 2 0)) (poly 4 '(1 2 4)))
  2.0
It also works for base 2, which is below the lowest base used in the article: the Python code goes from 3.

For base 2, the ratio is 1/1. When we apply the correction, we get (1 - 1) / (1 + 1) = 0, which is 2 - 2.

Post reply on HN