Programming for Mathematics

Course timings from 18th August: 11:30-12:30; Mondays, Wednesdays and Fridays (media room, IMSc)

Live Stream for the course
This will not work unless course is streaming live at this time. The next session is scheduled for 10:30am on Friday.
Sage server (accessible only from within IMSc).

Jump to:

  1. Introduction to Sage (4 Aug)
  2. Introductory Programming Tutorial (6 Aug)
  3. Advanced Prgramming Tutorial (8 Aug)
  4. Sharing and Interacting in Sage (11 Aug)
  5. Toward the Code (13 Aug)
  6. Classes in python-1 (18 Aug)
  7. Classes in python-2 (20 Aug)
  8. Classes in python-3 (22 Aug)
  9. Inheritance (24 Aug)
  10. Inheritance 2 (26 Aug)
  11. Exceptions and Iterators (1 Sept)
  12. List Methods and Functions (3 Sept)
  13. Iterators for Partitions and Lattice Paths (5 Sept)

Lecture 1: Introduction to Sage

Monday, 4th August 2014, 10:30am - 11:30am.
Notes for Lecture 1


Please come to the next class with code, not just answers. The point is to learn how to do this consistently; many you could do "by hand", after all.
  1. Find three topics in the combinatorics directory you didn't know about, but should. Be ready to show someone else how to compute it.
  2. Find a tutorial in the Sage documentation written by Anne Schilling, one of the presenters at Sage Days 60.
  3. What was your favorite function in calculus? Can you calculate its integral?
  4. Solve one of the harder Sudoku puzzles linked, using Sage.
  5. How many graphs are there of order five? (Up to isomorphism.)
  6. How many graphs are there of order five and size six?
  7. Do Project Euler's problem seven.
  8. Compute the sum of the primes below n, where n=30,100,1000, and two million. For the last few, you may want to learn about a "list" from a good Python tutorial, such as this one, this one, or another one from this list.
  9. Use Sage to calculate the determinant of the diagonal matrix of ranks one through ten with all ones on the diagonal. (You know the answer, but get Sage to do it for you!)
  10. Look up the list of programs which Sage uses internally or has interfaces to. Have you used any of them?

Video Recording

The video for lecture 1 will be up soon on our YouTube channel, and will be linked from this page.

Lecture 2: Introductory Programming Tutorial

Wednesday, 6th August 2014, 10:30am-11:30am.
Notes for Lecture 2 and homework

Lecture 3: Advanced Programming Tutorial

Friday, 8th August 2014, 10:30am-11:30am.
Notes for Lecture 3 and homework

Lecture 4: Sharing and Interacting In Sage

Monday, 11th August 2014, 10:30am-11:30am.
Notes for Lecture 4 and homework

Lecture 5: Toward the Code

Wednesday, 13th August 2014, 10:30am-11:30am.
Notes for Lecture 5 and homework

Lecture 6: Classes in python

Monday, 18 August 2014, 11:30am-12:30pm.
Lecture notes
Home work

Lecture 7: Classes in python

Wednesday, 20 August 2014, 11:30am-12:30pm.
Lecture Notes

Lecture 8: Persistent variables in classes, mutable and immutable objects

Lecture notes

Lecture 9: Inheritance

Sample file with class inheritance

Lecture 10: Inheritance 2


Lecture 11: Exceptions and Iterators

Code from the class

Lecture 12: List Methods and Functions

Code from the class

Lecture 13: Iterators for partitions and Lattice Paths

Code for the class
Homework: Create (in pure python) and iterator for permutations.