Source: https://www.math.cmu.edu/~mradclif/teaching/127S19/Notes/Functions.pdf