functions made according to example.
solve function used to calculate the inverse.