# Is $f:\mathbb{Q}\to\mathbb{Q}$ defined by $f(x)=\frac{x}{x^2+1}$ one-to-one? Onto?

I've been having trouble with determining if a function is one-to-one or onto. I found an example and would like to see how to go about this problem. If we have $f(x)=\frac{x}{x^2+1}$ where $f:\mathbb{Q}\rightarrow\mathbb{Q}$, is $f$ one-to-one? Onto? What about if $f:\mathbb{Z}\rightarrow\mathbb{Q}$?

-

The function is onto if and only if every rational can be obtained as the image of the function.

Considering for a second the function as a function over all of $\mathbb{R}$, consider $$f'(x) = \frac{(x^2+1) - 2x^2}{(x^2+1)^2} = \frac{1-x^2}{(x^2+1)^2}.$$ So $f'(x)$ has critical points at $x=1$ and $x=-1$. It is now easy to verify that $f(x)$ has a local maximum at $1$ and a local minimum at $-1$.

Since $f$ is decreasing on $(-\infty,-1)$, increasing on $(-1,1)$, and decreasing on $(1,\infty)$, and $\lim\limits_{x\to \infty} f(x) = \lim\limits_{x\to-\infty}f(x) = 0$, the function is bounded.

Since the function is bounded over $\mathbb{R}$, it is bounded when restricted to $\mathbb{Q}$ and $\mathbb{Z}$, so it cannot be onto.

Restricted to the integers, the function is one-to-one, because it is one to one and positive on $[1,\infty)$, and one-to-one and negative on $(-\infty,-1]$.

A little experimentation to decide if $f$ is one-to-one over $\mathbb{Q}$: assume that $$\frac{q}{q^2+1} = \frac{r}{r^2+1}$$ Then $qr^2 + q = q^2r + r$, hence $$r(qr-1) = q(qr-1).$$ If $qr-1\neq 0$, then this forces $q=r$. But if $qr=1$, i.e., if $r = \frac{1}{q}$, then we have: $$f\left(\frac{1}{q}\right) = \frac{\frac{1}{q}}{\frac{1}{q^2}+1} = \frac{\frac{1}{q}}{\quad\frac{1+q^2}{q^2}\quad} = \frac{q^2}{q(1+q^2)} = \frac{q}{1+q^2} = f(q),$$ so $f(1/2) = f(2)$, hence $f$ is not one-to-one when restricted to the rationals either. That is, in fact we have that $f$ takes every value except $0$, $\frac{1}{2}=f(1)$ and $-\frac{1}{2}=f(-1)$, twice.

-

For this particular problem, it's not hard to solve $\frac{x}{x^2+1} = \frac{y}{y^2+1}$ directly; the equation you get, $y x^2 - (y^2+1)x +y=0$ is a quadratic in $x$, and you already know $x=y$ is a solution, so you can factor that out, giving $y(x-y)(x-1/y) = 0$.

So as a function on the rationals, it fails to be injective, because, for example, $f(2)=f(1/2)$. It is, however, injective on the integers, because $x = 1/y$ implies $x = y = \pm 1$.

-

For ontoness: Given a rational $q$, you want to know if there is a rational $x$ such that ${x \over x^2 + 1} = q$. This translates into the quadratic equation $x^2 + {1 \over q}x + 1 = 0$ (We can ignore $q = 0$ since it is the image of $x = 0$). By the quadratic formula, you'd have to have $x = -{1 \over 2q} + {1 \over 2}\sqrt{{1 \over q^2} - 4}$ or $x = -{1 \over 2q} - {1 \over 2}\sqrt{{1 \over q^2} - 4}$. These don't have to be rational; all you have to do is take some $q$ for which the expression ${1 \over q^2} - 4$ inside the radical is not a square of a rational; say $q = {1 \over 3}$. So the function is not onto.

For one-to-oneness, like the others mention it eventually reduces to $f(x) = f(1/x)$, so it won't be one-to-one either.

-