reckless intuitions of an epistemic hygienist ([info]gustavolacerda) wrote,
@ 2005-12-18 12:30:00
Previous Entry  Add to memories!  Tell a Friend!  Next Entry
Entry tags:education

using Lisp in math education
Tomorrow, 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:

;; 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!


(Post a new comment)

Which LISP?
[info]_greg
2005-12-21 12:17 am UTC (link)
It seems that one of the great stumbling blocks to the success of LISP is its unbridlable malleability: too many dialects, too much variation among implementations of supposedly the same dialect and too much unique tool-building underlying every project. Despite all of that, and also because of it, LISP is one of my long-time favorite languages. I prefer the Scheme-based dialects. A particularly good set is here:

http://www.plt-scheme.org

Enjoy,

_Greg

(Reply to this)

lisp
(Anonymous)
2006-01-22 12:52 pm UTC (link)
Good to know that there is a windows implementation for LISP.

I'll give it a try.

Visit My Blog (http://mundomatematicas.blogspot.com)

(Reply to this) (Thread)

Re: lisp
[info]gustavolacerda
2006-01-22 12:59 pm UTC (link)
hi. Glad to be of help!
How did you find my blog?

(Reply to this) (Parent)


Create an Account
Forgot your login or password?
Login w/ OpenID
English • Español • Deutsch • Русский…