Community Projects, Contributing, Math Riddles, Math Tricks, Milestones, Murderous Maths, Simon teaching, Simon's sketch book

Simon having fun solving math puzzles on Twitter.

While in Southern France, Simon really enjoyed solving this puzzle (he originally saw in a Brilliant.org vid). He was so happy with his solution he kept drawing it out on paper and in digital apps, and later shared the puzzle on Twitter. This sparked quite a few reactions from fellow math lovers, encouraged Brilliant to tweet new puzzles and now Brilliant follows Simon on Twitter, how cool is that!

Milestones, Murderous Maths, Notes on everyday life, Simon teaching, Together with sis

My little pure connections to Simon, now 10 years old

What do I love most about Simon’s learning style and being around him are the precious moments he pulls me out of my regular existence, sits me down next to him and shares a piece of his sharp vision with me. I often take notes to make sure I haven’t missed out on the details. Reading back the notes I am often surprised at the hidden layers in his razor-sharp logic that hadn’t revealed themselves to me at first or had even seemed irrelevant to my journalist mind eager to cramp everything to the size of a cocktail bite. Sometimes, Simon takes over and types the rest of the blog entry himself. Like this time.

Dad says he saw someone by the swimming pool reading the book A Mathematician’s Apology. We google it and find out it’s a 1940 essay by British mathematician G. H. Hardy about the beauty of pure mathematics. Knowing how much Simon is drawn towards pure mathematics and that he, too, prefers pure mathematics to applied mathematics, I tell him about our discovery. Simon replies that it’s a silly question to ask him whether he knows Hardy: Yes, Hardy was actually the one who invited Ramanujan!

Simon pauses his breadboard tutorial, comes to the balcony with the view across the Cote D’Azur, sits down against the wall of bright purple flowers and patiently tells me an interesting fact about Hardy. It’s just a fleeting tiny conversation, but the beauty of Simon’s precise memory, the connection I feel to Simon and the setting is so striking I would rather grab my video camera but I don’t dare move as not to lose momentum. I later ask Simon to repeat the facts he told me so spontaneously.

“Hardy came up with the total number of chess games. Well, Shannon estimated it to be 10^120, however Hardy estimated it to be 10^…, 10^50.

Clarification: the former is:

1 000 000 000 000 000 000 000 000 000 000 000 000 000 000 000 000 000 000 000 000 000 000 000 000 000 000 000 000 000 000 000 000 000 000 000 000 000 000 000 000

(1 with 120 zeros)

And the latter is:

1 with 100 000 000 000 000 000 000 000 000 000 000 000 000 000 000 000 000 zeros

(1 with, a 1 with 50 zeros, zeros)

The picture is taken on August 16 when Simon turned 10
Simon’s age in binary
history, Milestones, Murderous Maths, Simon teaching, Simon's sketch book

Another evening tea

Simon was showing Dad a graph of how technology is developing exponentially, y = a^x. Dad asked for a specific value of a, and Simon said: “All exponentials are stretched out or squished versions of the same thing.” He then quickly came up with the proof (“a few lines of relatively simple algebra”). “If all exponentials are pretty much the same, that means that all exponentials have proportionately the same derivative.”

“I’m converting a to e, because e has a place in calculus that we can work with”.
Coding, Murderous Maths, Python, Simon teaching, Simon's Own Code, Simon's sketch book

Prime Generation Algorithm in Python

Simon has written a code in Python that generates primes using the finite list from Euclid’s proof that there are infinitely many primes. “Starting with one prime (2) the code uses the finite list to generate a couple more numbers that aren’t in the list but are primes. It may not even get to all the primes in the long run!” There is only one problem with Simon’s algorithm…

Simon has written down Euclid’s proof in his own words first https://imgur.com/ML2tI6n
and then decided to program it in Python.

Resources:
https://www.programiz.com/python-programming/methods/list/remove
https://www.geeksforgeeks.org/iterate-over-a-set-in-python/
https://www.youtube.com/watch?v=OWJCfOvochA
https://numbermatics.com/n/10650056950807/
https://defuse.ca/big-number-calculator.htm

Computer Science, Crafty, Electricity, Electronics, Engineering, Logic, Milestones, motor skills, Simon teaching

Simon building an 8-bit Computer from scratch. Parts 1 & 2.

Parts 1 and 2 in Simon’s new series showing him attempting to build an 8-bit computer from scratch, using the materials from Ben Eater’s Complete 8-bit breadboard computer kit bundle.

Simon is learning this from Ben Eater’s playlist about how to build an 8-bit computer.

In Part 1, Simon builds the clock for the computer
In Part 2, Simon builds the A register (more registers to follow).
these little black things are an inverter (6 in one pack), AND gate and OR gate (4 AND and OR gates in one pack)
this schematic represents the clock of the future 8-bit computer
Simon and Neva thought the register with its LED lights resembled a birthday cake
Electricity, Electronics, Logic, Simon teaching

Simon has been bitten by the hardware bug again!

It’s all Ben Eater‘s fault! Simon is more of a software and pure math champion, but Ben Eater’s videos have sparked Simon’s interest in logic and electronics, anew. Back in mid July (yes, I know, I’m a little behind with the blog), while waiting for his Complete 8-bit breadboard computer kit bundle to arrive from the US, Simon was playing with virtual circuits that he built on two wonderful platforms: Circuitverse.org and Logic.ly. You can view Simon’s page on Circuitverse at https://circuitverse.org/users/7241

Simon’s favourite was building the Master-Slave JK Flip-Flop https://circuitverse.org/simulator/edit/20037

Simon gave me a whole lecture on the differences between Sequential and Combinational Logic: in the former, there’s a presence of a feedback loop (the output actually goes back to somewhere else in the circuit), and the latter has everything going in one direction (the inputs come in and the outputs go out).

It’s a little bit like the difference between a Feed Forward neural network where the output only depends on the input and a recurrent neural network where the output also depends on what the output was previously,

Simon explained.

Here’s a problem with sequential logic circuits: they go crazy like this very often (confused NOR gate). That’s why most sequential logic circuits have a clock in them. A clock acts like a delay so that it won’t go crazy.

That’s the power of sequential logic: you can have the same input but a different output. This is useful for storing data: I release the input, but the data is stored. It can only be archived in sequential logic.

The delay comes in error detection (on the rising edge of the square wave).

Master-Slave JK Flip-Flop
https://circuitverse.org/simulator/edit/20037

The following circuits are buit in Logicly https://logic.ly/demo

SR Latch in Logic.ly
D Flip-Flop
SR Flip-Flop
Master-Slave JK Flip-Flop
Simon building circuits together with his uncle whom he has met for the first time (Russian)
Coding, English and Text-Based Data, Python, Simon teaching, Simon's Own Code

It takes the sun to the ground, and violet on the observer’s eye.

Simon writes:

This amazing sentence is generated by a Markov Text-Generation Algorithm. What is a Markov Algorithm? Simply put, it generates the rules from a source text, and it generates a new text that also follows those rules. The rules are often called the Markov Blanket, and the new text is also called the Markov Chain. OK, how does this all work?

Let’s take an example: let’s consider the source text to be “Hello, world!”. Then we pick a number called the order. The higher the number, the more sense the text makes. We’ll pick 1 for the first examples, we’ll examine what happens with higher numbers later.

Then we generate the Markov Blanket. This is a deterministic process. We start from the beginning: “H”. So we put H in our Markov Blanket. Then we come across “e”. So we put e in our Markov Blanket, but to specify that it’s next from H, we connect H to e by an arrow. Then we stumble on “l”. So we put l in our Markov Blanket, but again, to specify that it’s next from e, we connect e to l by an arrow.

Now, here’s where it gets interesting. What’s next? Well, it’s “l” again. So now we connect l to itself, by an arrow. This is interesting because it’s no longer a straight line!

And we keep going. Once we’re done, our Markov Blanket will look something like this:

Once we’ve created our Markov Blanket, then we start generating the Markov Chain from it. Unlike the Markov Blanket, generating the Markov Chain is a stochastic process.

This is just a process of wandering about the Markov Blanket, and noting down where we go. One way to do this, is just to start from the beginning, and follow the path. And whenever we come across some sort of fork, we just spin a wheel to see where we go next. For example, here are some possible Markov Chains:

Held!
Helld!
Hellld!
Helorld!
Hello, world!
Helllo, wo, wo, world!

That was an easy one, so let’s do something more complex with code.

First, just an interface to enter in the text, and the order:

text = "" # Variable to hold the text

print("Type your text here (type END to end it):")

while True:
  line = input("") # Read a line of text from standard input
  if line != "END": text += line + "\n" # If we didn't enter END, add that line to the text
  else: break # If we entered END, signify that the text has ended

text = text[:len(text)-1] # Remove the last line break

order = int(input('Type the order (how much it makes sense) here: '))

input("Generate me a beautiful text") # Just to make it dramatic, print this message, and ask the user to hit ENTER to proceed

Next, the Markov Blanket. Here, we store it in a dictionary, and store every possible next letter in a list:

def markov_blanket(text, order):
  result = {} # The Markov Blanket

  for i in range(len(text) - order + 1): # For every n-gram
    ngram = ""
    for off in range(order):
      ngram += text[i+off]
    
    if not ngram in result: # If we didn't see it yet
      result[ngram] = []
    if i < len(text) - order: # If we didn't reach the end
      result[ngram].append(text[i+order]) # Add the next letter as a possibility
  
  return result # Give the result back

Huh? What is this code?

This is what happens when we pick a number >1. Then, instead of making the Markov Blanket for every character, you make it for every couple of characters.

For example, if we pick 2, then we make the Markov Blanket for the 1st and 2nd letter, the 2nd and 3rd, the 3rd and 4th, the 4th and 5th, and so on. When we generate the Markov Chain, we squash the ngrams that we visit together. So next, the Markov Chain:

def markov_chain(blanket):
  keys = blanket.keys()
  ngram = random.choice(list(keys)) # Starting Point
  new_text = ngram
  while True:
    try:
      nxt = random.choice(blanket[ngram]) # Choose a next letter
      new_text += nxt # Add it to the text
      ngram += nxt # Add it to the ngram and remove the 1st character
      ngram = ngram[1:]
    except IndexError: # If we can't choose a next letter, maybe because there is none
      break
  return new_text # Give the result back

# Now that we know how to do the whole thing, do the whole thing!
new_text = markov_chain(markov_blanket(text, order), num)
print(new_text) # Print the new text out

OK, now let’s run this:

Type your text here (type END to end it):
A rainbow is a meteorological phenomenon that is caused by reflection, refraction and dispersion of light in water droplets resulting in a spectrum of light appearing in the sky. It takes the form of a multicoloured circular arc. Rainbows caused by sunlight always appear in the section of sky directly opposite the sun.
Rainbows can be full circles. However, the observer normally sees only an arc formed by illuminated droplets above the ground, and centered on a line from the sun to the observer's eye.
In a primary rainbow, the arc shows red on the outer part and violet on the inner side. This rainbow is caused by light being refracted when entering a droplet of water, then reflected inside on the back of the droplet and refracted again when leaving it.
In a double rainbow, a second arc is seen outside the primary arc, and has the order of its colours reversed, with red on the inner side of the arc. This is caused by the light being reflectedtwice on the inside of the droplet before leaving it.
END
Type the order (how much it makes sense) here: 5
Generate me a beautiful text

And……..it..stops.

Why did it do that?

You see, this is not such a good method. What if our program generated a Markov Blanket that didn’t have an end? Well, our program wouldn’t even get to the end, and it would just wander around and around and around, and never give us a result! Or even if it did, it would be infinite!

So how do we avoid this?

Well, we set another much bigger number , let’s say 5000, to be a callout value. If we don’t get to the end within 5000 steps, we give up and output early. Let’s run this again…

And now, it doesn’t stop anymore! Snippets of example generated text:

It takes the sun to the ground, and violet on the observer’s eye.

This rainbow, a second arc formed by illuminated droplets resulting it.
In a primary rainbow is a meteorological phenomenon the back of the ground, and has the sky. It takes the order of its coloured circles. However, the sun.

Rainbow, a second arc shows red on a line from the section of light in water droplet and has the sun.

In a double rainbow is caused by illuminated droplet on the outer part and refracted when leaving in a spectrum of a multicoloured circles. However, the droplet of water droplets resulting it.
In a double rainbow is a meteorological phenomenon the droplets resulting in a spectrum of a multicoloured circular arc. Rainbow is caused by the inner side the observer’s eye

Play with this project online at: https://repl.it/@simontiger/Markov-Text

Crafty, Geometry Joys, Math Tricks, Murderous Maths, Simon teaching, Simon's sketch book

Inscribed angle theorem

“It reveals itself once you complete the rectangle to find the centre. Because, of course, the diagonal passes through the centre once you inscribe a rectangle inside the circle, because of the symmetry”.
Tiling the quadrilaterals Simon has crafted applying the inscribed angle theorem.
Tiling the “shapes generated by the inscribed angle theorem”
“The theorem says that if you have a circle and just three random points on it, then you draw a path between te first point to the second, to the centre, to the third point and back to the first point”.
Coding, JavaScript, Murderous Maths, Physics, Simon teaching, Simon's Own Code, Simon's sketch book

Heat Equation Visualization

A visual solution to Fourier’s heat equation in p5. Play with the two versions online:
https://editor.p5js.org/simontiger/present/EaHr9886H
https://editor.p5js.org/simontiger/sketches/EaHr9886H

https://editor.p5js.org/simontiger/present/ruN8CQV77
https://editor.p5js.org/simontiger/sketches/ruN8CQV77

Inspired by 3Blue1Brown’s Differential Equations series.