calcuate the inverse