Caching the Inverse of a Matrix

Computing the inverse of a square matrix can be done with the solve function in R. For example, if X is a square invertible matrix, then solve(X) returns its inverse. 
For validating whether the results are correct, A*A-1 should be equal to 1.