functions implemented and tested to return matrix inverse correctly