The way to verify something like that is to check the definitions one by one and see if $g(x)$ satisfies the needed properties.
Recall that $F\colon A\to B$ is a bijection if and only if $F$ is:
- injective: $F(x)=F(y)\implies x=y$, and
- surjective: for all $b\in B$ there is some $a\in A$ such that $F(a)=b$.
Assuming that $R$ stands for the real numbers, we check.
Is $g$ injective?
Take $x,y\in R$ and assume that $g(x)=g(y)$. Therefore $2f(x)+3=2f(y)+3$. We can cancel out the $3$ and divide by $2$, then we get $f(x)=f(y)$. Since $f$ is a bijection, then it is injective, and we have that $x=y$.
Is $g$ surjective?
Take some $y\in R$, we want to show that $y=g(x)$ that is, $y=2f(x)+3$. Subtract $3$ and divide by $2$, again we have $\frac{y-3}2=f(x)$. As before, if $f$ was surjective then we are about done, simply denote $w=\frac{y-3}2$, since $f$ is surjective there is some $x$ such that $f(x)=w$. Show now that $g(x)=y$ as wanted.
Alternatively, you can use theorems. What sort of theorems? The composition of bijections is a bijection. If $f$ is a bijection, show that $h_1(x)=2x$ is a bijection, and show that $h_2(x)=x+2$ is also a bijection. Now we have that $g=h_2\circ h_1\circ f$ and is therefore a bijection.
Of course this is again under the assumption that $f$ is a bijection.
Ed and Aaron, thank you very much for explaining the practical benefits of injectivity and surjectivity.
I have taken what I learned from you and cast it into my own thoughts and experiences. Please let me know of any errors.
Motivation
When I go hiking, I want to be able to retrace my steps and get back to my starting point.
When I go to a store, I want to be able to return home.
When I swim out from the shore, I want to be able to get back to the shore.
Going somewhere and then coming back to where one started is important in life.
And it is important in mathematics.
And it is important in functional programming.
Domain, Codomain, and Inverse
If a function maps a set of elements (the domain) to a set of values (the codomain) then it is often useful to have another function that can take the elements in the codomain and send them back to their original domain values. The latter is called the inverse function.
In order for a function to have an inverse function, it must possess two important properties, which I explain now.
The Injective Property
Let the domain be the set of days of the week. In Haskell one can create the set using a data type definition such as this:
data Day = Monday | Tuesday | Wednesday | Thursday | Friday | Saturday | Sunday
Let the codomain be the set of breakfasts. One can create this set using a data type definition such as this:
data Breakfast = Eggs | Cereal | Toast | Oatmeal | Pastry | Ham | Grits | Sausage
Now I create a function that maps each element of the domain to a value in the codomain.
Here is one such function. The first line is the function signature and the following lines is the function definition:
f :: Day -> Breakfast
f Monday = Eggs
f Tuesday = Cereal
f Wednesday = Toast
f Thursday = Oatmeal
f Friday = Pastry
f Saturday = Ham
f Sunday = Grits
An important thing to observe about the function is that no two elements in the domain map to the same codomain value. This function is called an injective function.
[Definition] An injective function is one such that no two elements in the domain map to the same value in the codomain.
Contrast with the following function, where two elements from the domain -- Monday and Tuesday -- both map to the same codomain value -- Eggs.
g :: Day -> Breakfast
g Monday = Eggs
g Tuesday = Eggs
g Wednesday = Toast
g Thursday = Oatmeal
g Friday = Pastry
g Saturday = Ham
g Sunday = Grits
The function is not injective.
Can you see a problem with creating an inverse function for g :: Day -> Breakfast
?
Specifically, what would an inverse function do with Eggs? Map it to Monday? Or map it to Tuesday? That is a problem.
[Important] If a function does not have the injective property then it cannot have an inverse function.
In other words, I can't find my way back home.
The Surjective Property
There is a second property that a function must possess in order for it to have an inverse function. I explain that next.
Did you notice in the codomain that there are 8 values:
data Breakfast = Eggs | Cereal | Toast | Oatmeal | Pastry | Ham | Grits | Sausage
So there are more values in the codomain than in the domain.
In function f :: Day -> Breakfast
there is no domain element that mapped to the codomain value Sausage.
So what would an inverse function do with Sausage? Map it to Monday? Tuesday? What?
The function is not surjective.
[Definition] A surjective function is one such that for each element in the codomain there is at least one element in the domain that maps to it.
[Important] If a function does not have the surjective property, then it does not have an inverse function.
[Important] In order for a function to have an inverse function, it must be both injective and surjective.
Injective + Surjective = Bijective
One final piece of terminology: a function that is both injective and surjective is said to be bijective. So, in order for a function to have an inverse function, it must be bijective.
Recap
If you want to be able to come back home after your function has taken you somewhere, then design your function to possess the properties of injectivity and surjectivity.
Best Answer
You can't, as commenters said. There is no bijective function between two finite sets with different number of elements. There is no bijective function between a finite and an infinite set, either.
This observation extends to a definition of cardinality, where two sets have the same cardinality if there is a bijection between them. In view of the above, cardinality captures the concept of "number of elements", extending this concept for arbitrary sets.