First go at implementing the cached inverse, just based on the example code for mean but using a different operation