2016-10-31

Response Time

Years ago I cobbled up a web-based version of the timeless classic, the addictive video game Tetris. Now I'm starting again from scratch. Programming an AVR microcontroller makes the matter slightly more difficult/interesting. My motivation was to re-use the monochrome Liquid-Crystal Display of a twentieth century cell phone, the Nokia 5110.

Its bare-bones resolution of 84*48 sufficed for the tetraminos to look half decent. But the initial tests proved disappointing. There was a visible flicker as the blocks moved down the screen. I assumed it had something to do with the code. Perhaps storing the bitmaps in flash memory was too slow? Or some routines in the Adrafruit_GFX library sucked? I tried different things, without changing the outcome one bit.

I even tried with a different monochrome display. Exactly the same result. Then it hit me. The issue was not the software, but the hardware. In the datasheet of the second display, the response time is stated: 200 to 300 milliseconds. Pretty awful. It's the time pixels take to fully turn on or off. Meanwhile, a tetramino falling at 40 pixels/second has already traveled far. In consequence, the display is simply incapable of showing a sharp image at this speed. The response time should be at least five times smaller to make it enjoyably playable.

I learned that I cannot repurpose any display. I have to pay attention to more than just the resolution. Cheap LCDs cannot handle animations. TFT LCDs are faster. OLED displays, even more so. Hmm. A good STN LCD could be enough, since the Game Boy sported one.

2016-10-23

Blown Away

Nihil novi sub sole. This result was already known since the 18th century, but I've only heard about it last week: `1+2+3+4+\cdots=-1/12`

The infinite sum of all the natural numbers is somehow equal to negative one twelfth. I happened upon this crazy science on Youtube:



I tried to make sense out of this. I wanted a graphical representation of this infinite sum. If the result is not infinity, there should be a way to visualize the limit, right?! Well, I failed to find one. The only thing I could do was to show that the growth is logarithmic: $$\begin{align} A[n]&=n, \forall n\in\mathbb{N}_{>0} \\ B[n]&= A[n]+\cases{0 & \text{if } n = 1 \cr B[n-1] & \text{if } n > 1}, \forall n\in\mathbb{N}_{>0} \\ C[n]&=\frac{A[n]}{B[n-1]}, \forall n\in\mathbb{N}_{>1} \\ \\ A&=1,2,\ 3,\ 4,\ \ 5,\cdots \\ B&=1,3,\ 6,\ 10,15,\cdots \\ C&=\ \ \ \frac{2}{1},\frac{2}{2},\frac{2}{3},\frac{2}{4},\cdots \end{align} $$ Adding the `n`-th integer (thus `n`) to the sum means adding `2/{n-1}` time(s) the current sum to the sum. In other words, the sum increases by a factor of `{n+1}/{n-1}` at each step. When `n` tends towards infinity, this factor approaches `1`. The infinity we're adding is nothing but an epsilon...

Graphically, if we plot `B[n]` against `n`, the gradient of the curve (it's not actually a curve, just a set of points, but I guess the notion of gradient/slope still makes sense in this discrete context?) is equal to `n` (or `n-1`, or `n-1/2`? Not sure. Not important.) at each step. The gradient is ever increasing, so the series seems to increase exponentially. Absolutely no sign of a plateau; the slope gets more and more "vertical", forever. No limit. Yet our analysis above shows that the growth slows down. Well. The growth rate does decrease... but a smaller growth factor (which is by definition always greater than `1`) multiplied by an ever-bigger base yields an ever-bigger result. Oh, and not a trace of `-1/12`!

I was hooked. I youtube'd some more. The following video vulgarizes related mathematical concepts such as Cesàro mean, Cesàro sum, Riemann zeta function:



John Baez elaborates on the relevance of this equivalence in quantum mechanics, and how this result yields that string theory is 26-dimensional:



I am not very good at maths, nor knowledgeable in physics. Yet I find these explanations surprisingly clear and simple. It does makes sense... And at the same time it does not make sense. How can we can get a negative result by summing only positive numbers? As a programmer, my first thought was that we ran into a glitch in the Matrix. More likely, this is a clue about how the universe is really shaped. There is no reason for human mathematics to accurately represent a universe largely unknown to humans. If there are indeed 26 dimensions, why would our numbers only have two dimensions, "real" and "imaginary"?... [Edit 2016-10-25: I've just read about hypercomplex numbers] Who knows, a great discovery might be for tomorrow. That's exciting! It makes me want to brush up on my calculus.