using Lisp in math education
Dec. 18th, 2005 12:30 pmTomorrow, after my last session with my math tutee, I will teach him to play around with Lisp. Hopefully, it will replace his calculator.
download (Can anyone suggest a better Lisp environment for Windows?)
Lisp, because of its prefix notation, makes it possible to express empty additions and multiplications. This makes it easier to see why the value of an empty addition is 0, while the value of an empty multiplication is 1.
Other advantages:
* using formal languages prevents notational confusion
* with a formal language, the communication between teacher and student can be completely precise, at least AFA procedures are concerned. For expressing arguments or proofs, something like Coq would be needed. For communicating about intuitions, I have no idea.
Here's some code I'm hoping to go over with him:
download (Can anyone suggest a better Lisp environment for Windows?)
Lisp, because of its prefix notation, makes it possible to express empty additions and multiplications. This makes it easier to see why the value of an empty addition is 0, while the value of an empty multiplication is 1.
Other advantages:
* using formal languages prevents notational confusion
* with a formal language, the communication between teacher and student can be completely precise, at least AFA procedures are concerned. For expressing arguments or proofs, something like Coq would be needed. For communicating about intuitions, I have no idea.
Here's some code I'm hoping to go over with him:
;; BASIC STUFF
(defun ^ (x y) (expt x y))
(defun eqn-true? (eqn)
(= (eval (second eqn)) (eval (third eqn))))
;;;;;;;;;;;;;;;;;;;;;;;;;;
;; OPERATIONS
;;;;;;;;;;;;;;;;;;;;;;;;;
;;addition
(+ 1 1)
(+ 2 7)
(+ 0 4)
(+ 4 6 1)
(+)
;;multiplication
(* 3 4 2)
(* 1 0)
(* 5)
(*)
;;adding negative numbers
(+ 5 -3)
(+ 2 -3)
(+ 3 -3)
(+ -1 5)
(+ -7 5)
(+ -3 -3)
(+ -8 8)
;;multiplying negative numbers
(* 5 -1)
(* 4 -3)
(* -7 2)
(* -4 -1)
(* -10 -3)
(* -5 5)
;;;;;;;;;;;;;;;;;;;;;;;;;;
;; MORE COMPLEX EXPRESSIONS
;;;;;;;;;;;;;;;;;;;;;;;;;
(+ 1 (* -2 3))
(* (+ 1 -2) 3)
(* (+ 1 1) (+ 2 1) (+ 3 1) (+ 4 1))
(+ (* 0 -1) (* 1 2) (* 2 -3) (* 3 4))
(+ (* 2 1) (* 2 (+ 1 1)))
;;;;;;;;;;;;;;;;;;;;;;;;;;
;; FUNCTIONS
;;;;;;;;;;;;;;;;;;;;;;;;;
(defun square (x)
(* x x))
(square 5)
(square 7)
;;EXERCISE: write a 'cube' function
;; BONUS: see what happens when you do...
(mapcar #'square '(1 2 3 4 5 6))
;;--------------
(defun substs (tokens expr)
(reduce #'(lambda (xpr tok) (subst (second tok) (first tok) xpr))
tokens :initial-value expr))
;;;;;;;;;;;;;;;;;;;;;;;;;;
;; SUBSTITUTIONS
;;;;;;;;;;;;;;;;;;;;;;;;;
(subst 3 'x '(+ x x))
(eval *)
(substs '((x 1) (y 3)) '(+ x y))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; EQUATIONS
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(= 1 1)
(= 2 (+ 1 1))
(= (square 3) 8)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; EQUATIONS WITH VARIABLES
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; you can use substs to test whether equations are valid!
(substs '((x 1)(y 1)) '(= (^ (+ x y) 2) (+ (^ x 2) (^ y 2))))
(eqn-true? *)
;; whenever you are in doubt if an equation is valid, test it this way:
;; * plug-in values for all your variables, and check if it works...
;; * if it works, it's probably true, but do check again with different values!
Which LISP?
Date: 2005-12-21 12:17 am (UTC)http://www.plt-scheme.org
Enjoy,
_Greg
lisp
Date: 2006-01-22 12:52 pm (UTC)I'll give it a try.
Visit My Blog (http://mundomatematicas.blogspot.com)
Re: lisp
Date: 2006-01-22 12:59 pm (UTC)How did you find my blog?