Optimisation: reduce dictionary lookups for repeatedly used maths functions