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
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
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 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.
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.
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).
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.
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.
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?
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.
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.
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.
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 (....)
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:
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:
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
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.
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 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
"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.
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.
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.
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..
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.
The reason it works is that 9998 = 10^4 - 2. You can expand as
which gives the observed pattern. It breaks down when 2^k has more than n digits, which happens approximately when which comes out to 4 * log(10)/log(2) = 13.28 when n = 4.---
Another pattern can be generated from the power series expansion
setting x = 1/10^n gives the infinite series which leads to the neat fact that ---Another example is the fraction
which goes through the triangle numbers[0] in its expansion, or which goes through the Fibonacci numbers[1].---
Getting the squares is harder, but you can do it with
[0] http://en.wikipedia.org/wiki/Triangle_number[1] http://en.wikipedia.org/wiki/Fibonacci_number