# MAS212 Scientific Computing and Simulation (2016/17)

## Lecturer: Dr Sam Dolan

This is the course web page for MAS212 Scientific Computing and Simulation in 2016/17.

## Course Information

MAS212 is a 10-credit, Level 2, first-semester module which covers various techniques in scientific computing, and their implementation in Python. The course is intended to follow on from MAS115 Mathematical Investigation Skills.

## Software and setup

We will be using the Anaconda distribution of Python (version 3.5), which includes Jupyter Notebook and Spyder.

Anaconda3 is available on (the majority of) Managed Desktop machines. From "All Programs" on the Start Menu, select the folder "Anaconda3 (64-bit)".

To install Anaconda on your own computer, use the link below, and choose the Python 3.5 version

## Learning Resources

There are many books on Python and scientific computing. For this course, I recommend Learning Scientific Programming with Python by Christian Hill (Cambridge University Press, 2015). Copies are available in the library.

For help from classmates and tutors, please use the Discussion Board

A range of material is available on the web, including:

## Notebooks

In this course we will use Jupyter notebooks to combine code, text, plots and media. To view a notebook in the browser, click on the links in the left column. (Alternatively, copy-and-paste the notebook's URL in to the box at nbviewer.jupyter.org).

TitleDescriptionnotebook
Curve_Fit_Example Shows how to (a) generate a data set with simulated noise; (b) save and then re-load the data; (c) fit the data to a simple model using scipy.optimize.curve_fit(). .ipynb
ODE_Example Shows how to (a) solve a first-order single-variable ODE using scipy.integrate.odeint, and plot; (b) solve a second-order equation by writing as a pair of first-order equations; (c) solve predator-prey equations. .ipynb
Media_Example Shows how to load and interact with various media: data, images, web pages, YouTube videos and maps. .ipynb
Fern The Barnsley Fern: an image of a fern with self-similar (fractal) properties, generated by iterating certain affine transformations. .ipynb

## Lectures and Lab Classes

(Draft / subject to revision)
Week Lectures Computer labs Solutions
1 Lab Class 1: Getting started
2 Lecture 2: Functions, objects and arrays.
Class test 1 (2016)
3 Lecture 3: matplotlib.
Lab Class 3: Plotting
4 Lecture 4: ODEs and scipy.integrate.
Lab Class 4: Solving ODEs numerically .html .ipynb
5 Lecture 5: Numerical methods for ODEs.
Lab Class 5: Numerical methods for ODEs: (a) explicit methods .html .ipynb
6 Lecture 6: Explicit and implicit methods.
Lab Class 6: (b) implicit methods / multistep methods .html .ipynb
7 Lecture 7: Curve fitting.
Lab Class 7: Fitting Data
8 Lecture 8: Conditioning.
Lab Class 8: Ill-conditioned problems.
poly_example.py
9 Lecture 9: Animations with matplotlib.animate.FuncAnimation.
Lab Class 9: Animations Codes 1,4,5 by J Vanderplas .html .ipynb
10 Lecture 10: Discrete Fourier Transforms.
Class test 2 (2016)
Lab Class 10: The Discrete Fourier Transform.

## Class Tests

A short video (from 2014) shows how to take the test on the managed desktop machines.

(2016) Class Test 2 with answers .ipynb
.html
--
(2016) Class Test 2 .ipynb 5pm Mon 12th Dec
(2016) Class Test 1 with answers .ipynb
.html
Marker's notes
--
(2016) Class Test 1 .ipynb 5pm Mon 10th Oct

To attempt a test, right click on ".ipynb" link, save the file in your notebooks directory, and then open the notebook. To view a test, left click on the ".html" link. Completed tests will be submitted here.

## Assignments

# Title Summary Due Feedback
1 Newton-Raphson method Use Python to implement the Newton-Raphson method for finding the roots of differentiable functions. Sun 23rd Oct (23:59pm). Feedback points
Example code
2 Dynamics of two-species models Investigating properties of predator-prey equations Sun 20th Nov (23:59pm) Report (.pdf)
Source (.tex)
Code (.ipynb)
3 Detecting extrasolar planets Model-fitting and orbital dynamics. Sun 18th Dec (23:59pm) Report