Source: http://www.iro.umontreal.ca/~sahraouh/cours/ift3030/08_fonctions.pdf