Optimize `equivalent_units()`

The tool function equivalent_units() currently uses more then 10% of the simulation time in the minimal example.

Either, we could accept only fitting units, or try to optimize further (already did some optimizations in !222 (merged)).

As a first idea: we could cache units pairs with their result, as in most cases we will just have the same pair over and over again. The same could be done for compatible_units(), which has a similar run time.

Edited by Martin Lange