Showing posts with label math. Show all posts
Showing posts with label math. Show all posts

Thursday, May 2, 2013

Polynomial roller coaster


Hello readers!

Another comic! Now using a Post-it and mechanical pencil.


Hope you liked it!

Till the next post!
Ronald Kaiser

Tuesday, April 30, 2013

To infinity and beyond!

When you have an opportunity, ask a child if he wants to win one or two candies.*
If the child is rational, it seems quite obvious that he will take 2. "More is better", he would think.

This kind of reasoning doesn't hold in a special world; the magical world of infinites.
When we come into this subject any basic arithmetic is useless.

Georg Cantor left many insights to humankind about the conundrums of infinite. He once said, shocked with his own discoveries: "I see it, but I do not believe it". And unsatisfied with a lack of understanding of infinite, he came with the idea that there is an infinity of infinites. Yes, you read it right, an infinity of infinites.

In order to give you a simple example of how our basic arithmetic doesn't work in this strange world, let's take two sets:

E = { 2, 4, 6, ... }
N = { 1, 2, 3, 4, 5, 6, ... }

Which one has more elements, N or E?

The common reasoning is to think that E has fewer elements than N because E is a subset of N; a valid thought if they were finite sets. But here, our intuition doesn't suit. 

N and E, surprisingly, have the same number of elements! In other words, the number of natural numbers is equal to the number of even numbers!
But, but...how can it be?!




The key to understand this idea is one-to-one correspondence. An even number always has a half representation in the natural numbers. If we map all the even numbers to their half representations, we can check that for each element in set E there is an element in the set N. Hence, they have the same number of elements, or technically speaking, the same cardinality.

Strikingly simple as that, and at the same time mysterious. 
Counterintuitive.

Despite all Cantor's et al endeavours, we still have a lot more to learn from 


Till the next post!
Ronald Kaiser


* Please, don't do that if you do not have 2 candies in hand, =P

Friday, April 26, 2013

Buffon's needle simulation

Hello readers!
Have you ever heard about the Buffon's needle?
This is a very interesting experiment. In a nutshell, it is a fun approximative method to calculate the value of π. 

Watch this video to understand what is going on:



After playing for 20 minutes I came with a simulation in python and I thought I could share it with you. Please, be nice. It was a quick hacking, ;)

The code:

import sys
import math
import random


def get_random(l, k):
    return random.random()*(l - 2*k) + k

def get_point(w, h, k):
    return (get_random(w, k), get_random(h, k))

def get_angle():
    return random.random()*2*math.pi

def intercept(p1, p2, h, k):
    for line in range(0, h+1, k):
        if (line >= p1[1] and line <= p2[1]) or \
           (line <= p1[1] and line >= p2[1]):
            return True

def drop_and_check(w, h, k):
    p1 = get_point(w, h, k)
    angle = get_angle()
    p2 = (p1[0] + (k/2.0)*math.cos(angle), 
          p1[1] + (k/2.0)*math.sin(angle))
    return intercept(p1, p2, h, k)

def repeat(times):
    w = h = 1000
    k = 10
    count = 0
    for i in range(times):
        if drop_and_check(w, h, k): count += 1
    return float(times)/count

if __name__ == "__main__":
    print(repeat(int(sys.argv[1])))

It is available via github too.

Hope you liked it! =)

Till the next post!
Ronald Kaiser

Absolute value

Hello readers!

This is my second comic experiment. Now, in a xkcd style. Hope your elementary math is ok, ;)


Leave a comment if it made you laugh, ;)


Till the next post!
Ronald Kaiser