Source: https://www.i3s.unice.fr/~bernot/Teaching/2014-GB3_Python-Bernot.pdf