Hacker News new | past | comments | ask | show | jobs | submit login
1/9998 = 0.0001 0002 0004 0008 0016 0032 0064 0128 0256.. (wolframalpha.com)
617 points by rsiqueira on Jan 29, 2014 | hide | past | favorite | 96 comments



The pattern will break down once you get past 8192, which is 2^13. That means that the pattern continues for an impressive 52 significant figures (well, it actually breaks down on the 52nd digit, which will be a 3 instead of a 2).

The reason it works is that 9998 = 10^4 - 2. You can expand as

    1 / (10^n - 2) = 1/10^n * 1/(1 - 2/10^n)
                   = 1/10^n * (1 + 2/10^n + 2^2 /10^2n + 2^3 /10^3n + ...)
which gives the observed pattern. It breaks down when 2^k has more than n digits, which happens approximately when

    2^k > 10^n   =>   k > n log(10) / log(2)
which comes out to 4 * log(10)/log(2) = 13.28 when n = 4.

---

Another pattern can be generated from the power series expansion

    x / (1 - x)^2 = x + 2x^2 + 3x^3 + 4x^4 + ...
setting x = 1/10^n gives the infinite series

    1/10^n + 2/10^2n + 3/10^3n + ...
which leads to the neat fact that

    1 / 998001 = 0.000 001 002 003 004 005 006 007...
---

Another example is the fraction

    1000 / 997002999 = 0.000 001 003 006 010 015 021 ...
which goes through the triangle numbers[0] in its expansion, or

    1 / 998999 = 0.000 001 001 002 003 005 008 013 021 ...
which goes through the Fibonacci numbers[1].

---

Getting the squares is harder, but you can do it with

    1001000 / 997002999 = 0.001 004 009 016 025 036 049 ...

[0] http://en.wikipedia.org/wiki/Triangle_number

[1] http://en.wikipedia.org/wiki/Fibonacci_number


If you'd like to continue the pattern beyond 52 digits, just keep adding 9s to the original fraction... 1/9999999999998 = 1.0000000000002 0000000000004 0000000000008 0000000000016 0000000000032 0000000000064 0000000000128 0000000000256 0000000000512 0000000001024 0000000002048 0000000004096 0000000008192 0000000016384 0000000032768 0000000065536 0000000131072 00000002621440... × 10^-13


For the fibonacci, add a 9 on both sides of the denomator

1/998999 1/99989999 1/9999899999

To get more 0 spacing and avoid overflow


This should be denominator ;-)


interestingly, this works the other way around too: 1/98 = 0. 01 02 04 08 16 32 65...

and even further? 1/8 = 0.125


That's because 1=1

If I'm not mistaken. We should utilize the self-similarity much more often.


The pattern is not really breaking. What happens is that 16384 doesn't fit in a 4 digit space so it's first digit "1" jumps to 8192 and it becomes 8193. Then the next number (32768) add it's first digit "3" to 16384 and it becomes 16387 and so on, so the sequence appears strange after 4096: ...409681936387...


I think that's what you would call a break in a pattern though. Of course, the infinite series will stay infinite.


I agree, but what I took from it is that it continues to be defined by that series even after that point (just in a less recognizable way). It could have just been a remarkable coincidence that it follows that series for so long.


> The pattern will break down

It doesn't actually:

      4096 8193 6387
    = 4096+8192
    +         1 6384
    +           …


I noticed this on the last bit of wolframs display space also. The fact that it continues and is basically infinite sequence arithmetic overflow is insanely beautiful.


1/7 does it too. 14 28 56 128 <- too big


[deleted]


The same. It's simply regular addition that happens to overflow.


You can seemingly increase the digit space by doing 1/99998 or so.


Perhaps this explanation is helpful:

    1 / (10000 - 2) = 1/10000 * 1/(1 - 2/10000)
Notice that the sum of a geometric series is:

    1/(1 - x) = sum_k( x^k )
    1/(1 - 2/10000) = sum_k( (2/10000)^k )
So:

    1/10000 * 1/(1 - 2/10000) = 1/10000 * (1 + 2/10000 + 2^2/10000^2 + 2^3/10000^3 + ...)


1 in 8192 is the chance of encountering a wild shiny pokémon.


  1/9998 is
  1/(10000-2) is
  (1/10000) / (1 - 2/10000)
which is an infinite sum of geometric progression with an initial value of 1/10000 and ratio of 2/10000. In other words,

  x1 = 1/10000;            //  0.0001
  x2 = x1 + x1 * 2/10000;  //  0.0001 0002
  x3 = x2 + x2 * 2/10000;  //  0.0001 0002 0004 0008
  ...
Magic

  O_O
[0] http://en.wikipedia.org/wiki/Geometric_progression


In high school, I was pretty fond of plugging 11^n to get rows of Pascal's triangle. It breaks down at row 5, but inserting 0's in the middle extends it (e.g. 101^n, 1001^n, 10001^n).

		11^0             1
		11^1            1 1
		11^2           1 2 1
		11^3          1 3 3 1
		11^4         1 4 6 4 1


On a vaguely similar, yet less practical note: 111,111,111 * 111,111,111 = 12,345,678,987,654,321 :)


On most pocket calculators, 11111111×= will yield 12345678. People are often surprised that that sequence is accepted. To me, it exposes something about the calculator's internal architecture.

It's also a useful self-test if you think the battery might be going.


The sequence is a shortcut accepted by the vast majority of regular calculators for most of operations. It simply takes the second operand to be the same as the first and repeated pressing of the = key repeats the operation ad infinitum. Ie. 1+== is 3.

I have written an iOS calculator app and had very interesting times trying to find and mimic these shortcuts. I have thought for a long time they had to follow from some simple implementation detail, as all the calculators got them precisely the same, but I never found this one consistent rule, I had to implement the features in a series of hacks.


This site [1] reveals the secret to that pocket calculator shortcut and a few others, and also provides useful algorithms for calculating things such as square roots and logarithms.

[1] http://tedmuller.us/Math.htm


Wonderful! That site gives tests that can be performed from the keyboard to distinguish between Casio and non-Casio architectures, mentions the invisible 9th digit of precision, and notes that some calculators get it wrong.

The old Sinclair pocket calculators had some known arithmetic inaccuracies.


i'm interested now - what does that expose about the internal architecture for you?


Well, clearly the display is an addressable register, not merely an output through a latch.(I say that because I assume the design goals of an inexpensive calculator include kaizen-ing the bill of materials down to the absolute minimum. So it's probably a visible register. Similarly, it's probably a digit-serial architecture (maybe BCD), also for parts count reasons, but yielding supplemental advantages when it comes to verification.

Different operations take noticeably different amounts of time; a "timing attack" like those used for cryptanalysis might yield clues to what's in the black box.

The way new digits appear on the display when typed in suggests it might be implemented as a shift register. It would be interesting to look at high speed video of the display when the answer to a long computation appears; do the answer digits appear (rapidly) one at a time? Do they shift in from the left? Three caveats: (1) I've never noticed it happening; (2) LED displays are almost always multiplexed, but you could probably see through that; and (3) probably wouldn't work on an LCD because too slow. I used to have a vacuum fluorescent display calculator, though; IIRC it was not multiplexed.

There are a few articles on the web about the architecture of calculators, including the Busicom [1] and Sinclair [2]. Personally, I want to hear more about zoul's research---how did you do it?

[1] http://www.4004.com/

[2] http://files.righto.com/calculator/sinclair_scientific_simul...


While bored in middle school algebra, I figured out on my TI-30 which number, raised to itself as a power, would equal 9.9999999E99 (not sure on the precise number of nines after the decimal point, but basically it flooded the screen with all nines).

56.96124843225 ^ 56.96124843225

Wolfram confirms that it's pretty close to a full googol. Of course, you can keep adding digits to the end of the number to make it even more precise. Maybe I'll write a script to do that.


I was wondering if there was an inverse operation for tetration, and it turns out there is: https://en.wikipedia.org/wiki/Tetration#Square_super-root (what you're basically finding is 56.96124843225⇈1, which is apparently ssrt(1googol))


It actually doesn't break, you just have to do the carries as you would during normal addition. You have to read from right to left (1's place, 10's place, 100's place, and so on). So you're really just converting to base 10.

5th row: 1 5 10 10 5 1

Writing this a bit backwards, 1 * 1 + 5 * 10 + 10 * 100 + 10 * 1000 + 5 * 10000 + 1 * 100000 = 161051 = 11^5.


You can of course do this trick in any base. If we choose e.g. base 2^n for the n-th row of pascals triangle, we can use the following code for getting the n-th row of pascals triangle:

    def pascal(n):
      base = max(2, 2**n)
      row = (base+1)**n
      return [row/base**i % i for i in range(n+1)]
Nice, but hopelessly inefficient. :) You can also calculate a binomial coefficient the same way without any looping construct (the exponential operator does the looping for you).


We had a calc problem in high school on a test that would get you extra credit if you simplified the answer down to... something simple, and in order to do so you'd have to know Pascal's triangle.

Needless to say, I didn't get it, but one guy in our class, like an 8th grader, did. He was pretty smart.


The techniques of constructing such sequences have been studied formally in combinatorics under the name "generating function".

http://en.wikipedia.org/wiki/Generating_function

In this case, the sequence 1, 2, 4, ..., 2^n has the generating function,

  g(z) = sum[i = 0 to inf] (2^i * z^i) 
       = 1 + 2z + 4z^2 + ... 
       = 1 / (1 - 2z)
Substituting a small number 10^-k, such as z = 0.0001 gives 10000/9998, and then right shifting by dividing 10000 leads to 1/9998.

What more interesting is that some other useful sequences can often be obtained from the function, by operations like differentiation and integration, or adding / multiplying with other functions.

For example:

  2z + (4*2)z^2 + (8*3)z^3 + (16*4)z^4 ...
  = d/dz(g(z))
  = d/dz(z * 1 / (1 - 2z))
  = 2 / (1 - 2z)^2
Put z = 1/10000 = 0.0001, this yields 50000000/24990001 = 2. 0008 0024 0064 0160 0384 ...


Is anyone able to do this in hexadecimal?

Wolfram Alpha interprets 1/0x9999998 or 1/0xffffffe correctly as hex input, but still shows the output as decimal approximation, while a hexadecimal approximation would be more useful here. I would be really curious what this thing looks like in other numeric bases.

Unfortunately, the "Other base conversions" section only shows up to 7 or so digits after the point and doesn't allow expanding.

EDIT: found it! I didn't know bc in linux was this awesome! echo "obase=16;ibase=16;scale=1000;1/FFFE" | bc .0001000200040008001000200040008001000200040008001000200040008001000 (....)


As people have pointed out:

1/98 = 0.01 02 04 08 16 32 ...

1/998 = 0.001 002 004 008 016 032 064 128 256 ...

but there's also a degenerate case, where you have no 9s at all:

1/8 = 0.1 + 0.02 + 0.004 + 0.0008 + ...

and what's surprising here is that everything adds up and gives you the terminating decimal 0.125 that you were expecting.


> 1/8 = 0.1 + 0.02 + 0.004 + 0.0008 + ...

The sum of a convergent series is a / (1 - r) where a is the first value, and r is the ratio between the n+1th and nth term.

    a = 1/10, r = 1/5

    n = (1 / 10) / (1 - (1 / 5))
    n = (1 / 10) / (4 / 5)
    n = 5 / 40
    n = 1 / 8


I knew that. I left it as an exercise for the commenter.


Here's a generalization for any arithmetic sequence. With first term a0, difference d, and digit "padding" of n, the fraction that will result is:

(a0 + (d - a0)(1/10^n)) / (1 - 1/10^n)^2

For instance the sequence 1, 4, 7, 10, 13...

(1 + (3 - 1)(1/10^2)) / (1 - 1/10^2) = 1.02 / 0.9801 = 3400/3267 = 1.004 007 010 013 016...

For any kind of recursive sequence, you can find its generating function G(x) and then substitute some integer power of 0.1 for x to generate cool decimal expansions like this.

The generating function for the Fibonacci sequence is:

G(x) = x / (1 - x - x^2)

Substituting in 0.001 gives 0.001 / 0.998999 = 0.001 001 002 003 005 008...


Neat! Not familiar though with generating functions - can you pls explain how the generating function for the Fibonnaci sequence is x/(1 - x - x^2 ) ?


For Fibonacci sequence,

             x = 1x^1
      x * g(x) =        1x^2 + 1x^3 + 2x^4 + 3x^5 + 5x^6 + ...
  + x^2 * g(x) =               1x^3 + 1x^4 + 2x^5 + 3x^6 + ...
  ------------------------------------------------------------
  =       g(x) = 1x^1 + 1x^2 + 2x^3 + 3x^4 + 5x^5 + 8x^6 + ...
Hence,

     x = (1 - x - x^2) * g(x)
  g(x) = x / (1 - x - x^2)


Generating functions are amazing. One of the coolest topics in my entire undergrad math degree. This PDF is well written and will explain everything: http://courses.csail.mit.edu/6.042/fall05/ln11.pdf


everyone seems to be concerned with the point at which this breaks. You determine this, the size of the denominator gives you the precision you can calculate:

1 / 99998 will return:

0.00001 00002 00004 00008 00016 ....

[0]http://www.wolframalpha.com/input/?i=1%2F99998&dataset=&equa...


You are all genius. The first person found it is definitely outstanding. There are so much mathematic magic out there that always made me feel fascinating. I'm amazed by the nature of this world which can be described by math. It's unbelievable. So I made my logo utilizing one of it. http://bit.ly/1gre9Bh


You can just do 1/0.0001000200040008001600320064... to find it.


Ok, I hope somebody has a really good logical explanation of this, or maybe even some other awesome examples?


Explanation: 0.0001+0.00000002+0.00000000004 etc = 2^0/10^4 + 2/10^8 + 2^2/10^12 etc

which is a geometric sequence with common ratio 2/10000 and first term 1/10000

So it has an infinite sum of (1/10000)/(9998/10000) = 1/9998

Same for powers of 3: 1/9997

Actually 1/8 = 0.125 is an example of this; it just breaks down very early because 4+0.8+0.16+0.032+0.0064+... = 5


Similarily, 1/9999 gives you powers of 1 (which is just 1), 1/9997 powers of 3, and so on.


The fact that 10000 - 2 = 9998 probably has something to do with it. Compare and contrast the result for 1 / 99998.


Pretty much.

1/9998 = 1/(10000-2) = 1/(10000)*1/(1-2/(10000)

Since 2/10000 is very small, it is well approximated by the taylor expansion for 1/(1-x), which is simply

Sum(x^n)

Since x is 2/10000, we get powers of two, which keep getting shifted to the right. Like a bit pattern, they don't overlap when added, so we get the sequence above.


Simple high-school maths.

    S = 0.00010002000400080016...

    S = 0.0001 + 0.0000 0002 + 0.0000 0000 0004 + 0.0000 0000 0000 0008 + ...

    S = 2^0 / 10000^0 + 2^1 / 10000^1 + 2^2 / 10000^2 + 2^3 / 10000^3 + ...

    S = sum to infinity of (2/10000)^i
You might have noticed this is a geometric series with ratio 2/10000 = 0.0002.

    S = 0.0001 / (1 - 0.0002) = 0.0001 / 0.9998 = 1/9998



1/(1 - x) = 1 + x + x^2 + x^3 + x^4 + ...

so,

1/(1 - .0002) = 1 + .0002 + .0002^2 + ...

and

1/9998 = .0001/(1 - .0002).


Sorcery!


math voodoo ! it's beautifull indeed.


Since 1/9998 is a rational number, the result is a repeating decimal. The powers of 2 may sometime repeat its digits? According to according to WolframAlpha, 1/98 repeats after 42 digits. 1/998 repeats after 498 digits. And 1/9998 repeats each 357 digits.


I found other patterns!

  Powers of 3:
  1/9997 = 0.0001 0003 0009 0027 0081 ...

  Powers of 4:
  1/9996 = 0.0001 0004 0016 0064 0256 ...

  Powers of 5:
  1/9995 = 0.0001 0005 0025 0125 0625 ...
And so on...


You don't need wolfram if you have unix's bc:

echo "scale=10000;1/999999999999999999999999998" | bc


I found this division 1/9998 by chance. I was trying to remember the number from a previous HN discussion, that was 1/998001 = 1.002 003 004 005 006 007...: https://news.ycombinator.com/item?id=3514721


Way back, I found out that there are an infinity of such patterns. I was really awed by that!

http://blog.zyrthofar.com/2012/07/multiplying-recurring-deci...


Reminds me of being bored in high school.


Except your high school math teacher probably didn't know this one, and they still don't. Otherwise you wouldn't be bored. Haha :D


"Let's say you're me, and you're in math class, and you're supposed to be learning about exponential functions but you're having trouble caring..." https://www.youtube.com/watch?v=e4MSN6IImpI Vi Hart's whole channel is great, and most of the videos start like that.


Here's the general formula: (copy everything between angle brackets)

<http://texify.com/?$\frac{1}{10^n-m} = \sum_{i=0}^\infty \frac{m^i}{(10^n)^{i+1}}$>

And here's OP's result where n=4 and m=2:

http://www.wolframalpha.com/input/?i=%5Csum_%7Bi%3D0%7D%5E%5...


I gotta be that guy: Why is this the first post on the front page of Hacker News? Is basic arithmetic really so fascinating to the computer people?


In fact, you do not have to be that guy. Different people find different things interesting; just let it go.


True, however, I am also surprised that it's getting this much attention.


There is a little more going on here than basic arithmetic. See the top comment for further evidence: https://news.ycombinator.com/item?id=7144804. But yes, non-math-geeks will probably find this uninteresting. Apparently HN has a lot of math geeks ;)


If more math geeks thought these patterns were religious, we could call this Numerology. We could probably make the case that there are an infinite number of "interesting" patterns that can be generated as the result of "simple" arithmetic. That math geeks assign meaning to these numbers such as as proof of a sane, beautiful universe or a universe with a sense of humor is just human nature.

See also the Interesting number paradox[1].

1. http://en.wikipedia.org/wiki/Interesting_number_paradox


I hope you can see why this example of basic arithmetic is really neat. It reminds us that there are hidden patterns everywhere. Oftentimes, we can determine why the pattern exists with math.

It never hurts to be reminded how cool it is to learn.


After endless stuff on startups, basic arithmetic is a breath of fresh air.


I'd say that hackers are fascinated by neat tricks. Arithmetic tricks are just a subset of those.


I just put up a blog post covering this and a number of other interesting decimal expansions:

fibonacci: 100000000/99989999=1.000100020003000500080013002100340055...

integers: 1000000/998001=1.002003004005006...

square numbers: 1001000000/997002999=1.004009016025036...

explanations and proofs at: http://www.joefkelley.com/?p=635


Making new patterns is pretty easy. Just write use wolframalpha and write

sum k^3*1000^(-k) for k=1 to infinity ( = 334667000/332001998667 = 0.001 008 027 064 125 216 343 512 730 ...)

Also see if you can guess which one this is: 40920041/997002999 = 0.041 043 047 053 061 071 083 097 113 131 151 173 197 223 251 281 313 347 383 421...

Mmmh. Primes.


Using the sympygamma link also provided today, we can see why this is: http://www.sympygamma.com/input/?i=series%281%2Fx%2C+x%2C+10...

Look at the equation and then plug in (-2) for x


I'm a fan of 3^-n | n > 4. Apparently Richard Feynman (1997, p. 116) also was curious about the decimal expansion of 3^-5.

Feynman, R. P. 'Surely You're Joking, Mr. Feynman!': Adventures of a Curious Character. New York: W. W. Norton, 1997.



Breaks at 8,192 of course...


It doesn't really "break" so much as it shows the sum of partially overlapping entries, natural since they dont fit in 4 digits.


Apparently you can add 9's to increase the number of digits in the result.


To expend it all you have to do is add more nines.


You can add 9 for more digits per power of 2: http://www.wolframalpha.com/input/?i=1%2F99998


An explanation

http://www.youtube.com/watch?v=daro6K6mym8

If you wanted to extend this, make it something like 1/999999998 instead.


Just add more 9's to the divisor to make the pattern work for larger numbers: 1/99998 = 0.00001 00002 00004 00008 00016 00032 00064 00128 00256 00512..


This one is also interesting: http://www.youtube.com/watch?v=daro6K6mym8


What does this mean?


Pretty cool.

Can we use WolframAlpha to show why 0.1 cannot be represented as a floating binary?

And why floating numbers shouldn't be used for currency operations.


Yes.

http://www.wolframalpha.com/input/?i=1%2F10+in+base+2

TL;DR: 1/10 has an infinite repeating binary expansion. (think 1/3 in decimal - 0.3333333) The part that really gets you into trouble is that the repeating pattern is 0011, which means it rounds differently depending on how many digits of precision you give it.


HN just turned WolframAlpha into a porn site.


Also, 1/243 = 0.00411522633..

Source: Richard Feynman, "Surely you're joking, Mr. Feynman!"


maxima code follows

fpprintprec:100; fpprec:100; s : string(bfloat(1)/bfloat(9998)); makelist(substring(s,3+4i,7+4i),i,0,15); [0002, 0004, 0008, 0016, 0032, 0064, 0128, 0256, 0512, 1024, 2048,4096, 8193,broken pattern,6387, 2774, 5549]


with_bigfloat_precision(500) do BigInt(1)/BigInt(9998) end


Σ(2^i / (10^(5i)) = Σ(2/10^5)^i = 1/(1-(2/10^5)) = 10000/9998

(you get the idea)


Similar nicety on tartaglia's triangle, which represents infinite powers of 11


at about 10^200 decimal places in we found instructions for building an ansible.


Amazing but WTF does it mean? Are we living inside a simulation!


Not related, but 12345679 * 8 = 98765432


987654321/123456789 = 8.0000000729


And this is usefull or simply neat?




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: