Introduction to Python

An important part of MA2501 Numerical Methods is the implementation of numerical methods as computer programs. For that we will use Python, a multi-purpose programming language which offers an extensive computing environment designed for numerical computations.

Python is already installed at certain computer labs at NTNU. You may also install it on your own computer.

Installing Python

Python is free and can be downloaded from the internet. All the relevant packages for numerical computation can be installed by downloading the Anaconda launcher. Anaconda also includes Jupyter notebooks, which we will use during the course.

However, you may also choose to install Python without the additional packages included in Anaconda, though you will need to learn how to install relevant packages and Jupyter yourself.

Installing Autograd

Some of the exercises will make use of the library autograd . If you know how, you should install this in a separate environment to the default Anaconda environment for python.

On mac/linux, use the terminal. If you are on windows, you need to use Anaconda Prompt. With this open, use the command

pip install autograd

Learning Python

There are plenty of resources for learning Python. The Python wiki lists some resources for those who are new to programming, and for those who have more experience.

We also recommend the following textbooks:

  • Magnus Lie Hetland, Beginning Python, Apress (2017) Available online
  • Robert Johansson, Numerical Python, Apress (2015) Available online
  • Svein Linge, Hans Petter Langtangen, Programming for Computations - Python, Springer (2016) Available online
  • Hans Petter Langtangen, A Primer on Scientific Programming with Python, Springer (2016) Available online
  • Hans Petter Langtangen, Python Scripting for Computational Science, Springer (2008) Available online

The three first ones are quite basic and give a comprehensive introduction to Python and its usage for scientific computation. For further documentation on matplotlib, NumPy and SciPy, we recommend the following internet sites:

2021-01-27, matthewt