Rediscovering the Joy of Math: A Journey with Lisp
Math Is Fun
When I was in high school, I hated math. In fact, I had lost my enthusiasm for studying at school altogether, not just math. It was just so boring. The teachers focused on exam techniques to get high scores, and I didn’t find any joy in that kind of studying. I was a dropout. But now, I love math. Not just math, but also physics, chemistry, biology — everything is fun. What changed so much? It’s thanks to Lisp. I’ll talk about my enjoyment of math, using Lisp and calculus as topics.
Teaching Computers
One way to deeply understand something is to teach it to others. You need to have a solid understanding of the fundamentals to explain it clearly. As humans, we find it frustrating to hear poor explanations. However, computers don’t feel that frustration. They obediently follow human instructions.
Here’s some Lisp code to let a computer perform basic high school-level differentiation. It’s a topic from that famous MIT textbook, SICP. I’m using pattern matching from a library to avoid writing redundant code with cond
(import "elixir")
(defpattern derive
(((/ 1 _x) _x) `(/ -1 (^ ,_x 2)))
(((sqrt _x) _x) `(/ 1 (* 2 sqrt (,_x))))
(((sin _x) _x) `(cos ,_x))
(((cos _x) _x) `(- (sin ,_x)))
(((tan _x) _x) `(/ 1 (^ (cos ,_x) 2)))
(((exp _x) _x) `(exp ,_x))
(((^ _a _x) _x) `(* (^ ,_a ,_x) (log ,_a)))
(((log _x) _x) `(/ 1 ,_x))
(((log _a _x) _x) `(/ 1 (* ,_x (log ,_a))))
(((* _k (_f _x)) _x) (when (numberp _k)) (let ((d (derive `(,_f ,_x) `,_x)))
`(* ,_k ,d) ))
(((+ (_f _x) (_g _x)) _x)
(let ((d1 (derive `(,_f ,_x) `,_x))
(d2 (derive `(,_g ,_x) `,_x)) )
`(+ ,d1 ,d2)))
(((* (_f _x) (_g _x)) _x)
(let ((d1 (derive `(,_f ,_x) `,_x))
(d2 (derive `(,_g ,_x) `,_x)) )
`(+ (* ,d1 (,_g ,_x)) (* (,_f ,_x) ,d2))))
(((/ (_f _x) (_g _x)) _x)
(let ((d1 (derive `(,_f ,_x) `,_x))
(d2 (derive `(,_g ,_x) `,_x)) )
`(/ (+ (* ,d1 (,_g ,_x))
(* (,_f ,_x) ,d2 (^ (,_g ,_x) 2)))))))
(Example)
I haven’t taught anything beyond the differentiation rules for elementary functions, so it can’t handle complex calculations. Let’s try solving some school problems with the computer. The computer might make mistakes. It’s up to humans to teach the correct code. This is when we dive deep into understanding why it’s correct. Humans will do that by thinking deeply.
Going Deeper
With some improvements, you can handle high school-level differentiation quite well. Now, let’s talk about proving those differentiation formulas. Unfortunately, the computer is just applying differentiation rules according to patterns. Current digital computers don’t have the capability to think about proofs. This is where humans come in. Many test preparation books in Japan skip fundamental proofs. Books aimed at general math education for non-exam purposes provide more detailed explanations. Speaking of which, there was an introductory math book in American comics. In Japan, it was sold as “Dr. Max Kaledo’s Introduction to Analysis.” I was deeply impressed by this book. It explained the concept of limits using epsilon-delta in a clear and understandable way. I was amazed by the high quality of education in the United States.
Reflecting on High School Days
I can feel the difference between Japanese and American education. Japanese test preparation books focus mainly on exam techniques. Most math reference books in Japan don’t provide proper proofs. On the other hand, I’ve heard that American education encourages students to think critically. This is clearly reflected in the American comic book on math that I mentioned earlier.
I believe Lisp, in particular, can empower Japanese individuals to think critically and independently. Thinking is inherently enjoyable for humans. Recently, a full-fledged AI called ChatGPT has emerged. It sometimes provides incorrect answers. Let’s take this as a lesson. Ultimately, whether something is correct or not should be thoroughly thought through by oneself. I believe that Lisp and ChatGPT can be immensely helpful in instilling this attitude at a young age.
Easy-ISLIsp
I ‘ve been developing Easy-ISLisp for larning purpos. It is BSD license.Feel free to use. sasagawa888/eisl: ISLisp interpreter/compiler (github.com)