# How do I give the inverse of a bijective function

I have proved the function being bijective, but I don't know how to inverse it. So if someone could please show the steps how to do it I would be very grateful. Below is the provided proofs for injective and surjective.

Given:
f: $\mathbb{Q} \rightarrow \mathbb{Q}$, f(x) = 2x+1
Let a,b $\in \mathbb{Q}$, now assume f(a) = f(b)
Show that a=b:
2a+1=2b+1
2a=2b
Thus a=b function is injective.

Let a $\in \mathbb{Q}$, claim that $\frac{a-1}{2}$ maps to a. $\frac{a-1}{2} \in \mathbb{Q}$ since a $\in \mathbb{Q}$
f($\frac{a-1}{2}$) = 2($\frac{a-1}{2}$)+1
=a-1+1
=a
Thus function is surjective.

We want to find the inverse to the function $f$, we denote this inverse as $f^{-1}=g$. Now by definition of the inverse we have $f(g(x))=x$. This just means that $g$ 'undoes' what $f$ did with $x$. So if you apply $g$ to $x$ and then $f$ we get out original $x$ back. So the composition of a function with its inverse is by definition the identity map.
Mathematically this translates into $$f(g(x)) = x.$$ We now just use the fact that we know what the function $f$ is to obtain the following expression $$2g(x)+1=x.$$ Here we just treated $g(x)$ as a variable and filled it into the expression for $f$. We can solve this now for $g$ to get $$g(x) = \frac{x-1}{2}.$$ We can now check to see that indeed $f(g(x)) = x$ and $g(f(x))=x$. Thus the $g$ that we found is indeed the inverse of $f$.