September 7 lecture notes - intro programming w/ mathematica ------------------------------------------------------------- I) initial business 1) bookstore and textbooks 2) experience so far with running and exploring the software 3) this week a) overview of computers and how they work b) general "how to use" mathemtica, especially the "front end" c) logic basics : not, and, or, truth tables II) overview of computers 1) hardware cpu memory (fast, transient) disk/filesystem (slower, bigger) 2) cpu gazillions of "transistors" each a hardware logic "gate" (two different metals, 2 input wires, 1 output wires) very, very primitive operations 3) turing machine a few simple things it can do (read/write/move/change state) any digital computer has same (though faster) capability 4) general computer inputs: (keyboard, mouse clicks, ...) outputs: (screen, speakers, printer, ...) 5) computer science all about getting simple pieces to do complex things 6) how to manage complexity ? *** layers *** break problem into pieces, and those pieces into smaller pieces, ... each piece has an API : how to invoke it and what it can do testing documentation 7) algorithms and data structures 8) programming languages, operating systems low level - close to machine hardware ( assembly ) intermediate - better, but still machine specific ( C, C++ ) system services - disk, memory, multi-tasking, ... ( unix, ... ) high - abstract representation of problem ( Java, ... ) 9) applications with a GUI (Graphical User Interface) point'n'click - cartoons command line - words 10) typical steps computer programming (a) create source code file with editor (b) compile code (i.e. translate to assembly) to an executable file (c) run executable 11) IDE - interactive development environment application to combine these three together example: Mathematica application III) using Mathematica 1) Kernel vs Front End 2) Notebook (.nb) files 3) Cells and their types : text, input, output, ... 4) Preferences and the Option Inspector 5) Help help browser typing ?*foo* 6) Traditional Form vs Standard Form (under "Cell" menu) 7) Palettes and typing tricks control-^ control-space esc a esc for alpha 8) Function[arguments] - huge number of them 9) strings ("This is a string"), integer (3/5), float (3./5.) 10) assignments: a=10; 11) semi-colon: do it without showing me 12) {"This", "is", "a", "list", 1, 2, 3} 13) symbolic vs integer vs numeric results: 14) postfix (Pi//N) , prefix ( Sin @ Pi ), infix ( 10 ~Mod~ 3 ) 15) rules ( a+b/.{a->2,b->3} ) and Options ( Options[Plot] ) IV) programming logic 1) we'll need it for writing algorithms: if (...) then (...) 2) primitives Mathematica versions and && or || not ! true, false True, False Note: also set-like math notations 3) examples x = 10; y = 7; x<10 && y>5 x<10 || y>10 true or false? 4) more of formal logic * Implies[p,q], also written as "p => q" * ForAll, Exists