# A well-defined map from rational numbers to integers

I am trying to come up with a well-defined map from $$\mathbb{Q}\to$$ $$\mathbb{Z}$$

i.e. find a map $$f$$ such that it maps $$\frac{a}{b}$$ $$\epsilon$$ $$\mathbb{Q}$$ to an integer in $$\mathbb{Z}$$. I tried a couple of things, and unfortunately, they did not work.

The one that I recently came up with is the given map:

$$f$$($$\frac{a}{b}$$)= $$\frac{a+b}{gcd(a,b)}$$

However, I just do not see how I can prove that this is indeed a well-defined map. All I am doing at this stage is randomly plugging numbers to see if this works.

Is this map well-defined? If yes, can someone help me prove it? If not, is there a well-defined map from $$\mathbb{Q}\to$$ $$\mathbb{Z}$$ $$?$$

• How about $f(x)=0$ for $x\in\Bbb Q$? Or is there something else you want from your map? Jan 26 '19 at 7:55
• Thought about it, but it seems too trivial to me. I am absolutely not saying that it cannot work, but I wanted to play with something non-trivial. Jan 26 '19 at 7:56
• Can you at least decide what to you is trivial, and what isn't? Jan 26 '19 at 7:57
• $f(\frac{5}{3})=\frac{5+3}{\gcd(5,3)}=f(\frac{1}{7})=\frac{1+7}{\gcd(1,7)}=8$. What do you want exactly? Jan 26 '19 at 7:57
• @KonstantinosGaitanas you just took a random rational number and found the functional value. I wanted to prove that the mapping I came up with is "well-defined." Jan 26 '19 at 8:02

Yes, your map is well-defined. Suppose that $$\frac ab=\frac cd$$. Let $$m=\frac a{\gcd(a,b)}$$ and let $$n=\frac b{\gcd(a,b)}$$. Then there are integers $$\alpha$$ and $$\beta$$ such that $$a=\alpha m$$, $$b=\alpha n$$, $$c=\beta m$$, and $$d=\beta n$$. Then$$\frac{a+b}{\gcd(a,b)}=\frac{\alpha m+\alpha n}{\gcd(\alpha m,\alpha n)}=\frac{m+n}{\gcd(m,n)}$$and$$\frac{c+d}{\gcd(c,d)}=\frac{\beta m+\beta n}{\gcd(\beta m,\beta n)}=\frac{m+n}{\gcd(m,n)}.$$So$$\frac{a+b}{\gcd(a,b)}=\frac{c+d}{\gcd(c,d)}.$$
Let's represent the rational numbers as $$s\frac{p}{q}$$ p,q belong to natural numbers and the GCD of p and q is 1 and s belongs to set {1,-1}. Then we define $$f: Q\rightarrow Z$$ $$f(s\frac{p}{q})=s2^p3^q$$ Done! Note that this is one among many beautiful mappings the are many other ways.
• How is this mapping well defined? For instance, if I have let's say s = 1, p = 1, and q = 2, then I have $\frac{1}{2}$ and if I take another rational number for which s = 1, p = 2, and q = 4 then I have $\frac{2}{4}$. And we know that the two rational numbers are equal. But if I know plug them in the map, the value I get are not equal, and hence the map is not "well-defined." Jan 26 '19 at 8:04
• A correspondence $f$: $A$ $\to$ $B$ is called well-defined if for all a,b $\in$ A such that if a = b then f(a) = f(b). Jan 26 '19 at 8:08