changed function file to calculate matrix inverse and cache