In [2]:
import numpy as np
import matplotlib.pyplot as plt
from sympy import S, solve
import plotutils as pu
%matplotlib inline

numbers on a plane

Numbers can be a lot more interesting than just a value if you're just willing to shift your perspective a bit.

integers

When we are dealing with integers we are dealing with all the whole numbers, zero and all the negative whole numbers. In math this set of numbers is often denoted with the symbol $\mathbb{Z}$. This is a countable infinite set and even though the numbers are a bit basic we can try to get some more insight into the structure of numbers.

squares

If we take a number and multiply it with itself we get a square number. These are called square because we can easily plot them as squares in a plot.


In [17]:
def plot_rect(ax, p, fmt='b'):
    x, y = p
    ax.plot([0, x], [y, y], fmt) # horizontal line
    ax.plot([x, x], [0, y], fmt) # vertical line
    
with plt.xkcd():
    fig, axes = plt.subplots(1, figsize=(4, 4))
    pu.setup_axes(axes, xlim=(-1, 4), ylim=(-1, 4))
    for x in [1,2,3]: plot_rect(axes, (x, x))


However, what happens we have a non-square number such as $5$?. We can't easily plot this as two equal lenghts, we'll have to turn it into a rectangle of $1 \times 5$ or $5 \times 1$.


In [20]:
with plt.xkcd():
    fig, axes = plt.subplots(1, figsize=(4, 4))
    pu.setup_axes(axes, xlim=(-1, 6), ylim=(-1, 6))
    for x, y in [(1, 5), (5, 1)]:
        plot_rect(axes, (x, y))


The first thing we notice is that we can take one thing and project it as two things. The fact that this happens is perfectly natural because we decided to take a single value and project it in two-dimensions in a way that suits us. Nothing really weird about it but still it's worth to think about it for a moment. Apparently it's perfectly valid to have something even though the way we got there doesn't matter. We could either take the rectangle standing up or the one lying down. Another interesting question to ask is whether we can get on the other sides of the axes. So far we have been happily plotting in the positive quadrant where $0 \le x$ and $0 \le y$ but what about the other three? Are they even reachable using just integer numbers?

We could make up some factor like $-1 \times -5$ and that would put us in the lower left. That would be equal to the same rectangles projected in the top right. And negative numbers would be either in the top left or bottom right. Although trivial this is interesting because now we find that if we project a single dimension into two dimensions we sometimes get 1 possibility, sometimes 2 and usually 4.

If we project zero we just get zero. However if we project $1$ we get either $1 \times 1$ or $-1 \times -1$. If we project $5$ we get $5 \times 1$, $1 \times 5$, $-5 \times -1$ and $-1 \times -5$.


In [ ]: