There are a few rules for whether a function can have an inverse, though. Even though you can by anything you want in life, a function doesn't have all the same freedoms in math. Maybe they should draft a constitution or something.
First of all, it's got to be a function in the first place. For a review of that, go here.
Second, that function has to be one-to-one. That is, for every x-value, there's got to be a unique y-value.
This is a one-to-one function.
This is not. Notice how multiple x values can yield the same y value.
Figuring out if a function is one-to-one is as simple as drawing a straight line. No, really—give it a shot. It's called the horizontal line test. Draw any function, and then draw a straight horizontal line through it. If there's anywhere that the line passes through the function more than once, it is not a one-to-one function.
This function passes the horizontal line test
Which of the following is not a one-to-one function? Try drawing them if you have trouble.
a. x2 + 4
The answer is a. Because this function is even, or symmetric across the y-axis, the horizontal line test fails, and it is not one-to-one. Don't worry, the function won't be punished, it's just part of a different circle of friends.
If a function isn't one-to-one, though, there's a simple way to make it conform: remove the parts that fail the horizontal line test. For example, if we have the function x2 + 4 from the sample problem:
This function fails the horizontal line test. No re-takes either—bummer.
All we've got to do is restrict the domain of the function so that it does pass the test with flying colors.
Here we restrict the domain to either x < 0 or x > 0, and now it's one-to-one.