A function f is said to be one to one if for any x_0, x_1 in the domain of f, f(x_0) = f(x_1) implies x_0 = x_1. In other words, there is only one element in the domain of f that maps to any given element in the range of f.
We will first show that f(x) = 3x-1 has this property. Suppose x_0 and x_1 are real numbers such that f(x_0) = f(x_1). Then
3x_0-1 = 3x_1-1
=> 3x_0 = 3x_1
=> x_0 = x_1
Thus f(x) = 3x-1 is one to one.
As f(x) is one to one, it has an inverse function f^(-1)(x) where f^(-1)(f(x)) = f(f^(-1)(x)) = x.
One way of finding f^(-1) is to set y=f(x) = 3x-1, change all the x's to y's and vice versa, giving x = f(y) = 3y-1, and then solve for y. This results in an equation of the form y = f^(-1)(x).
Set x = f(y) = 3y-1
=> x+1 = 3y
=> y = (x+1)/3 = f^(-1)(x)
Notice that given f^(-1)(x) = (x+1)/3 we have f^(-1)(f(x)) = f(f^(-1)(x))=x, as desired.