# Math 480b: Programming for the Working Mathematician

## Course Description

We’re going to try to give you a view of the parts of the computer science world that we think are the most important for mathematics. We’ll be using the programming language Python, and the math software system Sage. Our goal is for you to all leave this course with the feeling that you now know much more about how to use a computer to help you attack mathematical problems, and enough “programming culture” to know what tools and techniques are available to make that easier.

Of course, this is a Herculean task. Computer science is its own discipline for a good reason – there’s a whole world of amazing and interesting things to learn, and there’s no way we could cover it all in a quarter. This means that we won’t be able to give you all the details of anything we’re doing; instead, we’ll have to settle for giving you the highlights, providing references if you want to know more, and trying to give you the chance to “get your feet wet” and learn about it all firsthand.

## Course Info

Location: Mueller Hall 153: http://www.washington.edu/maps/?l=MUE

Instructors: Craig Citro and William Stein

Time and Place: MWF 1:30 - 2:20 in MUE 153

- Office/Office Hours:
- Craig: Padelford C-424, W 10-11
- William: Padelford C-423, F 11-12

- IRC Sage chatroom -- SERVER: irc.freenode.net, CHAT ROOM: #sage-devel

The syllabus is here.

## Schedule and Lectures

3/29 First Day Business

Introductory stuff: introduce ourselves, talk about course structure, etc. Introduce Python as a calculator, mention that they should go home and try to get Python installed. Tell everyone to go home and read their first Python program (

`collatz.py`).

- Walk through our first Python program, introducing basic syntax and language constructs. Ask students to guess at how it works. Talk through the program line-by-line, and at least hint at what each piece is for.

4/2 A little Python, a little grading

- Continue deconstructing our first Python program, and discuss peer grading system.

- A quick crash course in the basics of using a UNIX-like command line. Introduce the notion of hierarchical filesystems.

4/7 The Sage Notebook, Python Installfest

- Introduce the Sage Notebook, and then make sure everyone's successfully installed Python.

- First HW is due -- talk about what we expect from the students in terms of how they should grade one another. After that, try to write a simple function (factorial) in several ways, each based on a different "natural" definition of factorial.

4/12 Python Basics, I

Start introducing the basics of programming in Python. Talk about lists and strings, explain how to find out more about the methods available on each.

*Added after the fact*: we also talked about list comprehensions,`map`/`filter`, and`import`.

4/14 Python Basics, II

Continue touring basics of Python. We followed our nose through several other parts of Python, including files, more on strings, and

`print`. Mention how much is available in the Python standard library, and use some of the parts of the`os`module. Start talking about line endings.

4/16 Python Basics, III

Putting together bits and pieces of what we've done in the previous two classes, write a simple program to convert files back and forth from DOS to UNIX line endings. Talk about types and

`isinstance`. Make sure to mention`os.path.isdir`,`os.walk`, and`shutil.copy`. Introduce`reduce`.

4/19 Introducing Sage (and Sympy!)

Here is a copy of the Sage worksheet linked to above.

Start off with ~5 minutes about the project. Introduce Sage, and give a

**brief**overview of the architecture of Sage. Ondrej Certik is in town, so save 15 minutes at the end for Ondrej to provide a quick introduction to Sympy.

4/21 Notebook Interacts and Python Decorators

Here is a copy of the Sage worksheet linked to above.

Take a few more minutes to describe the notebook in more detail. Talk about

`@interact`, and give several examples showing how easy it is to use, introducing Python decorators in the process.

4/23 Classes and Object Oriented Programming

Here is a copy of the Sage worksheet linked to above.

Talk a bit about classes in general, highlighting several basic facts everyone should know about object-oriented programming. Introduce the

`__`methods in Python, and explain how to use them to customize the behavior of your classes.

4/26 Digging In, I

- Start talking about Python in more depth. Talk about doctesting, dictionaries, and use the Python standard library to do something interesting with, e.g., web scraping.

4/28 Digging In, II

- More on Python: exceptions and exception handling, differences between Python 2 and Python 3. Odds and ends.

4/30 Sage Datatypes

- Introduce some of the more interesting datatypes provided by Sage, such as matrices, graphs, and types for arbitrary-precision arithmetic.

5/3 TBD

5/5 Symbolic Calculus Using Sage

Here is a copy of the Sage worksheet linked to above.

5/7 Cython

Here is a copy of the Sage worksheet linked to above.

5/10 TBD

5/12 TBD

5/17 Matrices

Here is a copy of the Sage worksheet above.

5/19 Solving linear systems: Worksheet at 480.sagenb.org and Worksheet at tutorial.sagenb.org

And a local copy. And here is the worksheet I actually used in class.

5/21 Numpy

Here is a copy of the Sage worksheet above.

5/24 The Sage Package Management System

Note that Sage Days 21 is this week here in Seattle.

5/26 Contributing to Sage, part 1

Here is a copy of the Sage worksheet above

- 5/28 Contributing to Sage, part 2
- 5/31 MEMORIAL DAY (no class)
- 6/2 Student Presentations
- 6/4 Student Presentations
- 6/7 This is unlikely to be necessary: Student Presentations (final exam slot)

## Handouts

collatz.py, the first handout

collatzwindows.py, the first handout - for windows (corrected line endings)

## Grading and Project Info

Your grade will be determined by 50% project and 50% homework. Specific project details are coming soon.

## Assignments

Assignments should be submitted by email to whoever your assigned grader is for that assignment. (If it's less than two days before the HW is due, and you haven't yet received your grader assignment, e-mail Craig and remind him to send those out.) You can also cc `[email protected]` if you'd like to have a backup, in the event that your grader doesn't receive your assignment.

Graded assignments should be submitted by email to `[email protected]`.

Assignment 0, .pdf version, Due 3/31

Assignment 1, .pdf version, Due 4/7 4/9

Assignment 2, .pdf version, Due 4/19

Assignment 3, .pdf version, Due 4/28 4/30

Assignment 4, .pdf version, Due 5/13 (by 11:30PM)

Assignment 5, Sage Worksheet Version, Due Thursday 5/27 (by 11:30PM)

## Useful Software Links

If you're looking for a good link to install something, you might find one here. If you find a useful link somewhere, let us know and we'll post it.

Python: you can't do better than this page.

Look here for more info about getting tab complete to work in Python.

- Emacs:
VIM: I'd start here. Someone forwarded along this interesting

*visual*tutorial, originally from here.IPython: Again, they have an excellent download page with instructions.

Sage: The download page is the place to look. (Stay tuned for more info on a Cygwin Sage.)

Cygwin: Look no further than the homepage.

## References

## Previous 480s

2008: See the year before -- past projects!!

2009: See last year's Math480 wiki.