Source: https://www.mathsgenie.co.uk/resources/a-pure-r-formulae.pdf