translating example code to matrix inverse