Write y=f(x), solve for x in terms of y, then rename the input of the inverse. Domain and range exchange roles. Verify by composition on the appropriate domains.
Example
For f(x)=3x−5, solve y=3x−5 to get x=(y+5)/3. Hence f−1(x)=(x+5)/3. For g(x)=x2 on x≥0, take the nonnegative branch: g−1(x)=x, also defined for x≥0.
Avoid this mistake
Writing both ±x does not define a single inverse function; the original domain decides which branch to use.