600.103 FUNDAMENTALS OF PRACTICAL COMPUTING Ken Church
• Intended audience: – Students considering a major in • science, engineering or medicine • Small Class • Diversity: Geeks Mainstream – like Calculus &“typing” – College High School Elementary School – Fun (not too much work) Sell the field • Prac cal: – Please bring laptops to class if you can • Familiarize students with lots of stuff (breadth) • Not just a single programming language (not depth) • Fundamentals: – Lots more to Computer Science than hacking Teamwork, Web‐work, etc.
• Encourage teamwork, Google, Wikipedia, etc. • Homework: – Submit by email to [email protected] – Due Tuesday morning at sunrise • So I have me to adjust my Tuesday lectures (if necessary) – Target: 2 hours per hour of class • 1 hour installing so ware, plus • 1 hour of exercises (as opposed to problem sets) – Homework comes with hints (as opposed to recipes) • Feel free to ask for more hints ([email protected]) – Example: Use Google to figure out how to install • R (a stat package) • LISP (h p://www.newlisp.org/) • cygwin (Unix for Windows) Chea ng
• Please don’t, but if you do, you are only chea ng yourself • I want to encourage teamwork & web‐work – Because they are great ways to learn – “Although you may work in small groups, each student must submit his/her own program and the code may not be a copy of others’ code. You may share ideas and help – but you must write your own code and your assignment MUST be SUBSTANTIALLY different from all others.” – Ok to submit a team effort (especially if you tell me who you are working with) • If you can’t do the homework, explain why – My bad – So ware package doesn’t work for your machine – I asked for more than 2 hours (feel free to stop a er 2 hours) • Homework is for your benefit (and mine) • Homework will be graded: sa sfactory (or not) • Exams (mid‐term & final) Grades – Goal: Learn from the homework You’ll do fine on the exams First Four Weeks • Symbolic Programming (how CS was taught in 1970s) – Prac cal: Familiarize students with stat package(s), • As well as symbolic alterna ves: LISP & Wolfram Alpha – Fundamental: • Stuff you can’t do with your favorite stat package • LISP: Recursion, Eval, Symbolic Differen a on • Lambda Calculus (“Small is Beau ful” beyond reason; Church’s Thesis & Computability) • Unix for Poets (“Small is Beau ful”) – How to program (without realizing that it is programming) – How to use tr, awk & those other crazy Unix u li es (pipes) – Examples: count words (and ngrams); find interes ng word associa ons. • More Unix for Poets • Python & NLTK (Natural Language Toolkit): – Unix for Poets (without Unix) – Formal Language Theory & Chomsky Hierarchy Symbolic Features (Bet you can’t do this with your favorite sta s cs package) • Complex Numbers: Sqrt(‐1) • Roots (without approxima ons) • Differen a on (without approxima ons) • Integra on (without approxima ons) • The On‐Line Encyclopedia of Integer Sequences • Eval Sqrt(‐1) Error (for many tools) Roots (without approxima ons) Numerical Methods: Approxima ons such as Newton’s Method Complex Roots Newton’s Method h p://archives.math.utk.edu/visual.calculus/3/newton.5/ sqrt(5) 3
2.9
2.8
2.7
2.6
2.5
Es mate of sqrt(5) 2.4
2.3
2.2 1 3 5 7 9 11 13 15 Itera on (n) Newton’s Method h p://archives.math.utk.edu/visual.calculus/3/newton.5/
3 16 14 2.9 12 2.8 10 2.7 8 6 2.6 4 2.5 2 Es mate of sqrt(5) 2.4 0 Es mate of sqrt(‐5) ‐2 2.3 ‐4 2.2 ‐6 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 Itera on (n)
sqrt(5) sqrt(‐5) 3 20 2.8 15 Symbolic 10 2.6 5 Alterna ve 2.4 0 Es mate of sqrt(5) 2.2 ‐5 Es mate of sqrt(‐5) 1 3 5 7 9 11 13 15 Itera on (n)
sqrt(5) sqrt(‐5)
Symbolic Methods Search Recursion (define (fact x) (if (<= x 1) 1 (* x (fact (- x 1))))) More Recursion Lecture3/recursive_examples.lsp (define (fib x) (if (<= x 2) 1 (+ (fib (- x 1)) (fib (- x 2)))))
(define (len x) (if (empty? x) 0 (+ 1 (len (rest x)))))
(define (rev x) (if (empty? x) x (append (rev (rest x)) (list (first x))))) The Roots of LISP Eval Symbolic Differen a on Symbolic Differen a on Lecture1/deriv.lsp h p://mitpress.mit.edu/sicp/full‐text/sicp/book/node39.html Syntax h p://www.allisons.org/ll/FP/Lambda/ Seman cs Surprise: Church’s Thesis • Effec ve Procedure Church’s Thesis – always give some answer h p://en.wikipedia.org/wiki/Effec vely_calculable – always give the right answer – always be completed in a finite number of steps – work for all instances of problems of the class • Recursively Computable – Three defini ons later found to be equiv to one another • general recursion • Turing machines • λ‐calculus • Church's thesis: – Effec vely Procedure = Recursively Computable – Not a mathema cal statement No proof
Recursion & Factorial h p://www.allisons.org/ll/FP/Lambda/Introduc on/ Summary: Symbolic Features (Bet you can’t do this with your favorite sta s cs package) • Complex Numbers: Sqrt(‐1) • Roots (without approxima ons) • Differen a on (without approxima ons) • Integra on (without approxima ons) • The On‐Line Encyclopedia of Integer Sequences • Eval First Four Weeks • Symbolic Programming (how CS was taught in 1970s) – Prac cal: Familiarize students with stat package(s), • As well as symbolic alterna ves: LISP & Wolfram Alpha – Fundamental: • Stuff you can’t do with your favorite stat package • LISP: Recursion, Eval, Symbolic Differen a on • Lambda Calculus (“Small is Beau ful” beyond reason; Church’s Thesis & Computability) • Unix for Poets (“Small is Beau ful”) – How to program (without realizing that it is programming) – How to use tr, awk & those other crazy Unix u li es (pipes) – Examples: count words (and ngrams); find interes ng word associa ons. • More Unix for Poets • Python & NLTK (Natural Language Toolkit): – Unix for Poets (without Unix) – Formal Language Theory & Chomsky Hierarchy Homework: Ques ons [email protected]
• Install (hint: Google) – R (a stat package) – LISP (h p://www.newlisp.org/) – cygwin (Unix for Windows); skip if you have Unix • Send me an email with: – Subject: 600.103 Homework #1 from
• Screenshots of sqrt(4) and sqrt(‐4) from – R – Wolfram Alpha – Newton’s Method h p://archives.math.utk.edu/visual.calculus/3/newton.5 – LISP • For Newton’s Method, what se ngs generate – sqrt(4) 2 v. sqrt(4) ‐2 – Are there any se ngs so that sqrt(4) NaN? • In R, show me the following plot – x = seq(‐4,4,1/10) – plot(x, x^2 ‐ 4) – abline(h=0) – abline(v=c(‐2,2), col="red") Fibonacci
• Use NewLisp & Encyclopedia of Integer Sequences to compute Fibonacci – F(n) = F(n‐1) + F(n‐2), F(0)=F(1)=1 – What is F(15)? Readings
• The Roots of LISP – Use Google to find the ar cle – “The unusual thing about Lisp‐‐ in fact, the defining quality of Lisp‐‐ is that it can be wri en in itself.” • The Hal ng Problem (Wikipedia) – What does this have to do with Computability?