Get more practice in the Calculator Sandbox, then start making your own Jupyter Notebooks!
Most of what you'll want to know you will find in the School of Yesterday.
Caveat: if you data mine in the recent past only, you might miss out on number bases (a big part of New Math).
Some elements within the Lower48 in North America, for example, perpetrated a base-10-only restrictum that many professionals chose to ignore.
Number bases, as a concept, need some focus and attention.
This work is licensed under a Creative Commons Attribution-NonCommercial 2.5 License.
This means you're free to copy and share these comics (but not to sell them). More details.
We begin our investigation of numbers expressed in different bases, with the hexademicals. Binary digital devices use 0-F to symbolize the 16 permutations of four bits of 1 or 0. 1100, 1010, 0011... are examples of such permutations.
Two hexadecimal numbers side by side represent strings of eight bits, such as 0100 1001. Such bit combinations are used to encode not only numbers, but other symbolic content such as alphabets.
Emoji have their unique bitwise signatures, in the various Unicode encodings.
base10 = int('FF', 16) # in base 16 but give us decimal output (the default format)
base10
255
hex(base10) # string output, with 0x prefix meaning hexadecimal
'0xff'
eval(hex(base10))
255
%matplotlib inline
import matplotlib.pyplot as plt
def make_squares(all_axes, the_color):
"""Side Effect City"""
all_axes = all_axes.ravel()
[axi.xaxis.set_visible(False) for axi in all_axes]
[axi.yaxis.set_visible(False) for axi in all_axes]
[axi.set_facecolor(the_color) for axi in all_axes]
f, axarr = plt.subplots(4,4, figsize=(4,4), facecolor=(.18, .31, .31))
make_squares(axarr, 'xkcd:salmon' ) #ff796c
plt.show();
f, axarr = plt.subplots(4,4, figsize=(4,4), facecolor=(.18, .31, .31))
make_squares(axarr, 'xkcd:burnt sienna' ) #b04e0f
plt.show();
from IPython.display import YouTubeVideo
YouTubeVideo("UIKGV2cTgqA")
Mathematicians Discover the Perfect Way to Multiply by Kevin Hartnett, Senior Writer, April 11, 2019
YouTubeVideo("FKGRc867j10")
A plot is what we also call a graph.
However Graph Theory has a meaning for graph worth giving the spotlight, so why waste two words for "plotting"?
Now "plot" has other meanings as well, such as:
[note use of Markdown]
We use splots to graphically show relationships between co-variables such as x and y, as in:
y = rule depending on x somehow
Sometimes, in data mining the "textbooks of yesterday", you will see the notation:
"f(x)" = "some expression involving x"
where "f(x)" is read as "function of x".
A formal mathematical definition of "function" includes the feature that it's deterministic in the following sense:
Given all the same inputs (a point in n-d space perhaps), you always get precisely the same output, no exceptions. f(2) gives 4 when f(x) = x + 2.
Caveat: You're not allowed to change the base or basis, as that might indeed change the answer. The base is considered part of the environment, nor are we permitted to change the meaning of __add__
mid-stream, to make it mean "modulo N" as we might in cryptography.
For more plotting, see isotope decay.
def func(x): # to be vectorized later
return x + 2
x = the_input = 6
y = the_output = func(x)
print(f"func({x}) returns {y}")
func(6) returns 8
x = the_input = int('FF',16)
y = the_output = eval(hex(func(x)))
print(f"func({x}) returns {y}")
func(255) returns 257
Examples of a mathematical not-function (which we might still call a function in Python), are:
>>> datetime.datetime.now() # full date/time
>>> datetime.date.today() # date only, BIOS
>>> time.clock() # CPU clock as float
import datetime, time
print(
datetime.datetime.now(),
datetime.date.today(),
time.clock(),
sep = "\n")
2019-06-30 18:43:28.969660 2019-06-30 5.004325
The code cell below is all about trying out different arguments in the sixteen cells (assuming 4 by 4 as the default -- you're free to change the code of course). Lets experiment with marker sizes and shapes, and different vectorized, linear functions.
A vectorized function is one trained to automatically apply to every element in any ndarray fed to it.
import numpy as np
vf = np.vectorize(func)
domain1 = np.arange(0,1,0.1)
domain2 = np.linspace(-1,1,10)
fig, axarr = plt.subplots(4,4, figsize=(4,4), facecolor=(.18, .31, .31))
make_squares(axarr, 'xkcd:burnt sienna' ) #b04e0f
#=== ROW 0 ==========
plt.sca(axarr[0,0])
plt.scatter([0],[0])
plt.sca(axarr[0,1])
plt.scatter([0,1,10],[0,1,10])
plt.sca(axarr[0,2])
plt.scatter(domain1,domain1**2)
plt.sca(axarr[0,3])
plt.scatter(domain2,domain2**2)
#=== ROW 1 ==========
plt.sca(axarr[1,0])
plt.scatter([0],[0], s=500, marker="^")
plt.sca(axarr[1,1])
plt.scatter([0],[0], s=1000, marker="2")
plt.sca(axarr[1,2])
plt.scatter([0],[0], s=1000, marker="s")
plt.sca(axarr[1,3])
plt.scatter([0],[0], s=1000, marker="p")
#=== ROW 2 ==========
plt.sca(axarr[2,0])
plt.scatter([0],[0], s=500, marker="P")
plt.sca(axarr[2,1])
plt.scatter([0],[0], s=1000, marker="+")
plt.sca(axarr[2,2])
plt.scatter([0],[0], s=1000, marker="D")
plt.sca(axarr[2,3])
plt.scatter([0],[0], s=1000, marker="d")
#=== ROW 3 ===========
plt.sca(axarr[3,0])
plt.scatter(np.array([0.1, 0.2]), np.array([0.5, 0.2]))
plt.sca(axarr[3,1])
plt.scatter(domain1, vf(domain1)) # vf defined up top
plt.sca(axarr[3,2])
plt.scatter(domain1, np.vectorize(lambda x: -x)(domain1));
plt.sca(axarr[3,3])
plt.scatter(domain1, np.vectorize(lambda x: 0)(domain1));
The numpy package arrives with many vectorized functions, such as np.sqrt
but what if you want to roll your own lambda? np.vectorize
will outfit any callable with what it takes to apply to whole arrays, or to indexed subarrays thereof.
Whence comes this meaning of "vectorize"? Is this the linear algebra concept? Yes and no. Computer science comes with its own concerns about workflow. What operations must wait for other operations, to proceed? Vectorizable operations are those that might be done "in parallel" (without waiting for other operations to complete).
Vector processors take this concept one step further. Instead of pipelining just the instructions, they also pipeline the data itself. The processor is fed instructions that say not just to add A to B, but to add all of the numbers "from here to here" to all of the numbers "from there to there". Instead of constantly having to decode instructions and then fetch the data needed to complete them, the processor reads a single instruction from memory, and it is simply implied in the definition of the instruction itself that the instruction will operate again on another item of data, at an address one increment larger than the last. This allows for significant savings in decoding time.
# instead of tab20, try: hsv, jet, your choice of others
cs = iter(plt.cm.tab20(np.linspace(0, 1, 16))) # snip a canned strip into "paint samples"
fig, axarr = plt.subplots(4,4, figsize=(4,4), facecolor='black')
make_squares(axarr, 'xkcd:burnt sienna' ) # we'll be replacing the burnt siennna, but go ahead
all_axes = axarr.ravel()
[axi.set_facecolor(next(cs)) for axi in all_axes]; # applying snipped paint samples
Since we're on the topic of arithmetic (one of the "three Rs") in more than one base, lets take a more zoomed out view, while we celebrate Euler in particular. Why not?
YouTubeVideo("OmJ-4B-mS-Y")
YouTubeVideo("JAr512hLsEU")
YouTubeVideo("d-o3eB9sfls")
In the School of Yesterday, 2nd and 3rd powering were inevitably associated with squares and cubes respectively. As you learned in Martian Math, we have a choice to introduce a different paradigm. Below are models of 3rd and 2nd powering respectively, or of any $A * B * C$ or $A * B$.
See "Dimension" in Synergetics (Google Slides)
The Oregon Curriculum Network was headquartered in what many of us informally called the Asylum District. That's because Oregon's first state mental hospital was nearby and staffed by one Dr. Hawthorne, for which Hawthorne Boulevard is named.
The meaning of asylum includes "sanctuary" as in the science fiction movie Logan's Run.
YouTubeVideo("nHDaRPQ8aiM") # https://youtu.be/nHDaRPQ8aiM
What might not be clear from the above video is Descartes' Secret Notebook suggests that V + F == E + 2, attributed to Euler, was actually known to Descartes.
But he was afraid to publish. Instead, he encrypted his notebooks. Leibniz found these notebooks, the story goes, and decrypted what he was permitted to see. But then his notes were lost... A twisted tale.
YouTubeVideo("FOU5j-Qtsxs") # https://youtu.be/FOU5j-Qtsxs