Cached inverse function was added

The functions of calculating the inverse and caching were added.