A function $F:\mathbb{Q} \rightarrow \rm numerators$ Is it possible to express explicitly a function that takes as its input a rational number and outputs the numerator (or denominator) of that number)?
Edit: I want something that will give me, for example, f(.5)=1 or f(1/2)=1 (but since this is a single valued function we can't know beforehand what is in the numerator and denominator of a number in the domain).
Edit: To further clarify what I mean, let me give a naive non-example:
y=7x is a function that will take (5/7) to 5. However this function will not output the numerator of every rational. I seek a function that will do this. I am not asking the function to recognize (at least to begin with) what the numerator or denominator of the fraction is. The function can't simply be "given a rational $x,$ convert $x$ to fraction form in lowest form and read off the numerator. 
 A: Sure, but you need to make sure the function is well defined by declaring one must write $\frac ab $ in lowest terms, i.e. $\gcd(a,b)=1$, and say $a\in\Bbb Z,b\in\Bbb N^*$. Else we may write elements in various ways, $(-2)/1,2/(-1),4/(-2)$ yielding an ill-defined function.
A: Is there a polynomial function with that property? No: it has to take the value $1$ infinitely often, and if a polynomial takes a value infinitely often, the polynomial must be the constant function.
Proof: Suppose there are infintiely many $\xi$ such that $f(\xi) = a$. Then every $\xi$ is a root of the polynomial $g(x) = f(x) - a$. However, nonzero polynomials can only have finitely many roots: therefore $g(x) = 0$, and thus $f(x) = a$ is the constant polynomial.
Is there a rational function with that property? No: again, taking the value $1$ infinitely often implies that the rational function would have to be constant.
Is there a function? Yes: "f(x) = the numerator of $x$ when written in lowest terms" defines it.
Another short expression of this function is "$f(p/q) = p$ whenever $p,q$ is in lowest terms". Another one in a similar vein is:
$$ f\left(\frac{p}{q} \right) = \operatorname{sgn}(q) \frac{p}{|\gcd(p,q)|} $$
where $p$ ranges over all integers and $q$ ranges over all nonzero integers, with no joint condition on the variables.
Is there an algorithm that can obtain the numerator of a rational function, using only addition, subtraction, multiplication, equality testing, and the numbers $0$ and $1$? Yes: in pseudocode
def numerator(q):
    x = 1
    loop forever:
        spawn new thread to check is_integer(q*x)
            return q*x when the first thread answers "yes"
        x = x + 1

def is_integer(q):
    spawn new thread to check is_natural(q)
        if this thread ever answers "yes", then return "yes"
    execute is_natural(-q)
        if this ever answers "yes", then return "yes"

def is_natural(q):
    x = 0
    loop forever:
        if q = x then return "yes"
        x = x + 1

This, however, assumes that you're given exact arithmetic; no algorithm can possibly work, of course, if you're only given an approximation to the true value.
Just to emphasize, all three of the functions I list above are the same mathematical function; I just wrote it in three different ways.
A: Something like that wouldn't even be a function, because $1/2 = 2/4$, but $f(1/2) = 1$ and $f(2/4) = 2$. If we require that $p/q$ be a reduced fraction, then we lose that problem and the function would just be $f(p/q) = p$.
