Matrix inverse opt

Cached duplicate multiplications (saved 1% of runtime)