Tutorial on Numerical Computation doing maths with computer


Welcome to the tutorial on numerical computation for undergrads in Physics, Maths and Engineering.

The aim of this tutorial is to learn to do mathematics with the computer. In real life applications of mathematics, most of the time the calculations are too hard to be completed with pencil and paper. Thus, we will learn how to use a computer to help us.

In order to take the tutorial you will need to have access to a computer with GNU-octave installed. The first node of the tutorial provides some help with the installation. Luckily, it is free software It runs on Linux, MacOS, Windows… it even runs on Android!

Follow the tutorial with the octave window open: learning to program without access to the software is a frustrating experience. Whenever you have questions, you may email the authors (jrlaguna at fisfun dot uned dot es).

Example carotid

This webpage offers an online octave window… try it!

Using Octave

In this first unit we will discuss our tools. Of course, the really important part is the logic behind numerical computation, but nonetheless the calculations can not be done on our heads!

Plotting functions and curves

Plotting mathematical objects is both useful and beautiful. Today we will just scratch the surface of the vast area of mathematical computer graphics, but we hope to give you a hint of what it looks like.


Water is flowing from a tap at a rate of $10 \mathrm{l/s}$. After 5 seconds, how much water has flown? You just multiply: $10 \times 5 = 50 \mathrm{l}$. But, what if we are told that the flow rate is changing continuously with time? Let us say that for time t the flow rate $r(t)$ is given by

Root finding

Our purpose in this section will be to solve equations numerically, using Newton’s method

Vectors and Matrices

In this section we are going to cover some linear algebra stuff. Octave is especially well designed for those purposes.

Differential Equations

This is most difficult part of the tutorial… So, please, pay a lot of attention and do all the exercises as you read.

Monte-Carlo techniques

Can randomness help us solve a problem? Yes, and in surprising ways. Of course, it can help us solve problems related to probability. For example:

Advanced plotting

In this last part of the tutorial, we are going to discuss more about plotting in octave. This part is optional. But when you see the pictures, I hope you’ll feel compelled to try it :)


In this part we review the basic functions in Octave in order to obtain the eigenvectors and eigenvalues of matrices, i.e. to diagonalize matrices.