search


Learning and the Scientific Method
Wed Mar 07 00:00:00 UTC 2018

The scientifc method is an important and useful tool. Like many good ideas, it is obvious in retrospect but there was a time when humanity did not have it. Even the great Greek philosophers of antiquity were not privy to this tool. The scientific method in its current form was a gift from the Islamic world.

The diagram above describes the scientic method as an ongoing process with no beginning and no ending. However, for me it starts with a problem or a question. Today everybody had difficulty with functions. You all claim to understand functions but the coding exercise on drawing a triangle shows otherwise. It is OK to not understand. My dad gave me good advice when I was a kid and I will share it with you: the first step to understanding anything is to embrace your ignorance and acknowledge that you don't understand. There is no shame in acknowledging your ignorance. It takes a wise and courageous person to acknowledge their own ignorance. Only a fool knows everything.

How to know you understand something?

The scientifc method provides an answer. You understand something if you can make correct predictions from your hypothesis and theories. Correctness is determined with observation of your experimental results.

Another good test of understanding is if you can teach it to someone who doesn't understand. In this respect, I don't understand the topic myself because I have failed to explain it in a way you understand. Я не понимаю!

Another way of understanding is if you can find homomorphisms between new knowledge and your existing knowledge. Homorphisms sound scary but it is just another way of saying equality or an equivalence relationship. Examples of equivalence relationship are analogies, metaphors, stories and parables. If I give you the relationship, cold and hot, you can give me many homomorphic relationships like white and black, good and bad, dog and cat, man and woman etc, etc... There can be many homomorphisms. The more homomorphisms you can find to bridge a new idea to your existing knowledge the better your understanding can be. There are limitation to these technique because a new idea can be so foreign that you cannot relate it with your existing knowledge. Sometimes your homomorphisms are inaccurate or completely wrong but that is perfectly OK because you can use the scientific method to refine your understanding or eliminate inaccurate or wrong ideas. Even when we can create metaphors to help us understand something, how do we know the metaphors are accurate? Metaphors don't have to be accurate or true to be useful. Metaphors gives language to think and question about a problem even if the metaphor is wrong.

Fictional stories are not real but can relate to things in real life. In other words, fictional stories can be homomorphic to real life. Even though these stories are not real, they can help us understand things in real life better than real-life itself. Examples of these are biblical parables. Another popular form of story telling is the Hero's Journey:

Yet another way to test your understanding is to create or reproduce it. For example, the idea of a neural network is simple but it is easy to fool yourself into thinking you understand it. You must be able to build it yourself from scratch to know for sure that you understand.

Before we can proceed to more advance topics, you need to understand two things about Clojure functions

  • how to execute/call functions?
  • how to define/create your own functions?

Homework
  • Apply the scientific method to help you understand and answer the two questions about functions.
  • Write a fictional story about clojure functions. Do your own research on the history of lambda calculus, LISP, Clojure and create a short story. Be creative but it must teach how to execute a function and how to define a function.
  • Write a function to draw a pentagon.
Homework extra credit *
  • Write a function called polygon that takes a number n and draws an n sided regular polygon. Regular polygons are polygons with sides that are equal in length. Calling (polygon 3) draws an equilateral triangle, (polygon 4) draws a square. (polygon 5) draws a pentagon , etc etc
    • Use that polygon function to create a function to draw a circle with radius r
  • Teach your parents what you learned about Clojure functions
    • No cheating because they will be tested!
  • Do your own research on Clojure and teach your classmates how to write a function to add up numbers from 0 to 1000

* Anyone who completes any of the extra credit homework assignment will get a surprise prize



Equality and The Substitution Principle
Mon Mar 05 00:00:00 UTC 2018

Equality and the Substituion Principle are two important and closely related ideas. Einstein used these ideas to reason about gravity and formulate the General Theory of Relativity

The Substitution Principle says if two things are equal then those things can substitute for each other. This idea is so simple it borders on the obvious. Discovering this idea is what got me through high school algebra despite having terrible math teachers. At the time, I did not know it had a name. Keep the idea of equality and the substitution principle in mind when you're studying algebra and higher level mathematics because it will help you understand

So what does it mean for two things to be equal? It depends on the problem or system you're modeling and sometimes it is up to you to define what it means. The concept of equality can be generalized to the concept of Isomorphism or sometimes homomorphism depending on your domain and context

What does this have to do with programming? Functions are evaluated using the substitution principle. It means symbols are replaced with values. Let's illustrate with an example.

(defn square [x] (* x x)) (square 3)

When we are evaluating (square 3), 3 is substitued for the symbol x in the function definition. Then in the body of the function, we apply the substitution principle again and replace all occurance of x with 3 which gives us this expression (* 3 3). Since there's no other unknown symbols the function evaluates (* 3 3) which gives 9.

Sometimes we are not substituting a symbol with a simple value but code block that evaulates to an value. We will see this later. Everything in clojure is an expression meaning everything evaluates to some value. Clojure has no statements. Even control structures are expressions