Does there exist a function $s\colon \mathbb{Q} \rightarrow \{-1,1\}$ such that if $x$ and $y$ are distinct rational numbers satisfying ${xy=1}$ or ${x+y\in \{0,1\}}$, then ${s(x)s(y)=-1}$? Justify your answer. Proposed by Dan Brown, Canada
Problem
Source: IMO ShortList 2004, algebra problem 3
Tags: function, number theory, continued fraction, algebra, functional equation, IMO Shortlist
18.03.2005 18:24
Where did you find this problem? It is realy interesting. I believe the answer to be 'yes', and I think I have a way of constructing the function, but it's only verified empirically, and I haven't fixed my ideas well enough to provide a full proof. Here's what I thought we could do: It suffices to determine the function on the positive rationals, of course, so let's restrict our attention to those. Construct the Stern-Brocot tree step by step. At each step, to each leaf you attach a leaf to the left and a leaf to the right. Label the leaf to the left with $-1$ and the leaf to the right with $1$. It seems to work.
18.03.2005 20:41
We have $s(x)=s(1+x)=-s(1/x)$. I see a direct way to use continuous fractions here, since having these rules we can obtain $s(x)$ from $s(1)$. Did I say something stupid?
19.03.2005 11:44
Solution: Let x=a/b be a positive rational, where a,b are coprime positive integers. Consider the squence of consecutive remainders given by euclidean algorithm for the ordered pairs (a,b). if u mod v denotes the least non negative remainder of u modulo v, this sequence can be written as r_0=a, r_1=b, r_2=a mod b, ... , r_(i+1)=r_(i-1) mod r_i, ... , r_n=1, r_(n+1)=0 (1) the index n=n(x) of the least nonzero remainder r_n=1 is uniquily determined by x, so t(x)=(-1)^n(x) is a well-defined function from the positive rationals into {-1,1}. Now define s: Q-->{-1,1} by s(x)=t(x) for x in Q, x>0 or s(x)=-t(-x) for x in Q, x<0 or s(0)=1 We prove that s has the desired properties. Let x and y be distinct rational numbers. * If x+y=0, let x>0 and y<0 (x,y are nonzero). Then , by definition, s(x)=t(x), s(y)=-t(-y)=-t(x), hence s(x)s(y)=-1. **If xy=1 then x and y are of the same sign and neither equals 1 or -1. Suppose first that x=a/b >0, y=b/a >0, with a,b coprime positive integers, one may also assume that a>b. Euclidean algorithm for (a,b) starts a,b, (a mod b), ... .On the other hand, the algorithm for pair (b,a) gives b,a,b,(a mod b)m,... . Because a>b implies r_2=(b mod a)=b. Each term in (1) depends only on the previous two, so the sequence for x has length by 1 less than the sequence for y, that is, n(y)=n(x)+1. Hence t(y)=-t(x), and so s(y)=-s(x), as needed. Now the case of x,y follows from the definition... **If x+y=1 then .... by the same logic it'll be true...
19.03.2005 12:08
We see that $t(x)$ is a number of subfractions in the continuous fraction representing $x$.
19.03.2005 12:44
absolutely...
13.09.2008 01:23
I knew it's imoral relive topic but I have a question: we can prove that $ s(1) = 0$ if we use $ s(x) = - s(\frac {1}{x})\Leftrightarrow s(1) = - s(1)\Leftrightarrow s(1) = 0$ contradiction. I dont really understand
11.10.2008 17:45
x and y are distinct rational numbers if you use s(x) =-s(1/x) for x=1 then we have x=1=1/1=1/x=y.
07.08.2014 08:27
Every positive rational number has a unique continued fraction of the form $ a_0 + \frac{1}{a_1 + \frac{1}{a_2 + \frac{1}{\ddots\frac{1}{a_{m - 1} + \frac{1}{a_m}}}}} $ for some $ m \in \mathbb{N} $ where $ a_i \in \mathbb{N} $ for all $ i $. From now on this will be denoted as $ [a_0; a_1, a_2, \dots, a_m] $. For every $ a \in \mathbb{Q}^{+} $, let $ s(a) = (-1)^m $. Then let $ s(0) = -1 $ and for all $ b \in \mathbb{Q} \setminus \{0\} $ let $ s(-b) = -s(b) $. I claim that this $ s $ satisfies the desired properties. To prove this, consider two rational numbers $ x < y $. $ 1) $ If $ x + y = 0 $ then by definition $ s(x)s(y) = -1 $ as desired. $ 2) $ If $ x + y = 1 $ and $ x = 0 $ then by definition $ s(x)s(y) = -1 $ as desired since $ s(1) = 1 $. $ 3) $ If $ x + y = 1 $ and $ x < 0 $ then to prove that $ s(x)s(y) = -1 $ it suffices to show that $ s(-x) = s(y) $. Let $ -x = [a_0; a_1, a_2, \dots, a_m] $. Then $ y = [a_0 + 1; a_1, a_2, \dots, a_m] $ and so $ s(-x) = s(y) = (-1)^m $ as desired. $ 4) $ If $ x + y = 1 $ and $ x > 0 $ we can let $ y = [0; 1, a_2, \dots, a_m] $ so that $ x = [0; a_2 + 1, a_3, \dots, a_m] $ so $ s(y) = (-1)^m $ and $ s(x) = (-1)^{m - 1} $ which implies that $ s(x)s(y) = -1 $ as desired. $ 5) $ If $ xy = 1 $, we can assume WLOG that $ 0 < x < 1 $. Then letting $ x = [0; a_1, a_2, \dots, a_m] $ we have that $ y = [a_1; a_2, a_3, \dots, a_m] $ so $ s(x) = (-1)^m $ and $ s(y) = (-1)^{m - 1} $ which implies that $ s(x)s(y) = -1 $ as desired. This implies that my claim is true and so we are done. Note that this also implies that Grobber's idea about the Stern-Brocot tree works as well.
20.09.2014 13:39
Note also that this function $s$ is unique up to multiplication by $-1$. Indeed let $x\in\mathbb{Q}^{+}$ and $x=[a_0;a_1,\ldots,a_m]$. Using $s(x+1)=s(x)$ and $s(x)=-s(1/x)$ it's easily obtained $s(x)=(-1)^m s(1)$.
29.03.2020 11:53
Fake alg, pure NT . Anyway, here's my solution: For two integers $0<p<q$, let $f(p,q)$ denote the number of steps taken in the Euclidean Algorithm to find $\gcd(p,q)$. In other words, if we let $b_0=q,$ $b_1=p$ and write the system of equations $$b_r=a_{r+1}b_{r+1}+b_{r+2} \text{ such that } 0<b_{r+1}<b_r \quad \forall r \in \{0,1, \dots ,n\} \text{ and } b_{n+2}=0$$then $f(p,q)=n,$ where $n \geq 0$. Then we claim that the following function works- The ProGawd Function wrote: $s(n)=1$ for $n \in \mathbb{N},$ and $s(-m)=-1$ for $m \in \mathbb{N} \cup \{0\}.$ $\text{ }$ $s \left(\frac{-1}{2} \right)=1.$ $\text{ }$ $s(1+x)=s(x)$ for $x \neq \frac{-1}{2},0.$ $\text{ }$ For integers $p,q$ with $0<p<q$, $$s \left (\frac{p}{q} \right)=(-1)^{f(p,q)+1}$$ It's easy to see that this uniquely defines the image of all rationals. Now we show that this indeed satisfies all the given properties. First we prove $s(x)s(-x)=-1$ when $x \neq 0$. For $x \in \mathbb{N}$ and $x=\pm \frac{1}{2}$, this easily follows from the definition, so we can ignore these cases. WLOG assume $x>0$ and suppose $x \in (n-1,n)$ for some $n \in \mathbb{N}$ with $2x \neq 1$. Then from property 3 of our function, we have $s(x)=s(x-(n-1))$ and $s(-x)=s((n-1)-x)$. Since $0<x-(n-1)<1,$ so it suffices to show that $s(x) \cdot s(-x)=-1$ for $x \in (0,1)$. Take $x=\frac{p}{q}$ for $0<p<q$, and first suppose $p< \frac{q}{2}$. We have $$s \left( \frac{-p}{q} \right)=s \left(1-\frac{p}{q} \right)=(-1)^{f(q-p,q)+1}$$But, as $q-p>\frac{q}{2}>p$, so the first step of our Euclidean Algorithm while finding $\gcd(q-p,q)$ will be $q=(q-p)+p$. So $f(q-p,q)=1+f(p,q-p)$. Also, using $q>2p$, we get $f(p,q-p)=f(p,q)$. Thus, we have $$s \left( \frac{-p}{q} \right)=(-1)^{f(q-p,q)+1}=(-1)^{1+f(p,q)+1}=-s \left( \frac{p}{q} \right)$$Thus, for $x \in \left(0, \frac{1}{2} \right),$ we have $s(x)s(-x)=-1$. Finally, if $x \in \left(\frac{1}{2},1 \right),$ then $s(x)=s(x-1)$ and $s(-x)=s(1-x)$. Since $0<1-x<\frac{1}{2}$, then the previous result gives $s(1-x)s(-(1-x))=-1$. Combined with the above equalities, we get $s(x)s(-x)=-1$. Thus, the result is true for all $x \in \mathbb{Q}$. $\text{ }$ Now we show that $s(x)s(1-x)=-1$ for $x \neq \frac{1}{2}$. For $x=1$, the result is true by definition. And for $x \neq 1,\frac{1}{2}$, by the above result, we have $s(1-x)=-s(x-1)=-s((x-1)+1),$ which directly gives the desired property. $\text{ }$ Finally we show that $s(x)s \left(\frac{1}{x} \right)=-1$ when $x \neq 0,\pm 1$. Since $s(-x)=-s(x)$ (proved before), so it suffices to show the result for positive $x$. Also, WLOG we can take $0<x<1$, and write $x=\frac{p}{q}$ with $p<q$ and $p,q \in \mathbb{N}$. Then $$s \left(\frac{1}{x} \right)=s \left( \frac{q}{p} \right)=s \left( \frac{q}{p} -1\right)= \dots =s \left( \frac{q \pmod{p}}{p} \right)=(-1)^{f(q \pmod{p},p)+1}$$But, while finding $\gcd(q\pmod{p},p)$ we simply start from the second step in the Euclidean Algorithm to find $\gcd(p,q)$. So we have $f(q \pmod{p},p)+1=f(p,q)$. This gives us $$s \left(\frac{1}{x} \right)=(-1)^{f(q \pmod{p},p)+1}=(-1)^{f(p,q)}=-s \left(\frac{p}{q} \right)=-s(x)$$Thus, we have $s(x)s(-x)=-1$ as desired. $\blacksquare$
14.10.2020 01:25
05.11.2020 07:03
The answer is yes, and we construct such a function. First, note that the only condition on $s(0)$ is that $s(0)=-s(1)$, which we can manually enforce at the end. Thus, we assume that the inputs to $s$ are nonzero rationals. Write $x=a/b$ where $\gcd(a,b)=1$ and $b>0$. We set \[s(x) = \begin{cases}1 &\text{if } (a^{-1}\mod b)\le b/2 \\ -1 &\text{if } (a^{-1}\mod b)>b/2.\end{cases}\]From this definition, it is clear that $s(x)= - s(-x)$ and $s(x)=-s(1-x)$, so it suffices to show that $s(x)=-s(1/x)$. Since we know $s$ is odd, it suffices in fact to show $s(x)=-s(1/x)$ for $x>0$. Lemma: If $a,b\ge 1$ are relatively prime positive integers, then \[a\cdot(a^{-1}\mod b) + b\cdot(b^{-1}\mod a) = ab+1.\] Proof: Indeed, letting $T$ be the left side of the above equation, we see that $T\equiv 1\pmod{a}$ and $T\equiv 1\pmod{b}$, so $T\equiv 1\pmod{ab}$ since $\gcd(a,b)=1$. Furthermore, we have \[a+b\le T\le a(b-1)+b(a-1)<2ab,\]so we must in fact have $T=ab+1$, as desired. $\blacksquare$ The above lemma implies that $(a^{-1}\mod b)\le b/2$ if and only if $(b^{-1}\mod a)>a/2$, which implies that $s(a/b) = -s(b/a)$. Remark: The condition is basically the same as ISL 2017 N8, which motivates the classification of $s$.
19.05.2023 06:38
We define $n(x)$ on the positive rational numbers to be the number of terms in the continued fraction of $x$. Then let $s(x)=-1^{n(x)}$ and $s(-x)=-s(x)$. Then, clearly $s(x)s(-x)=-1$. If $xy=1$ and $x>1$ then $y = 0+\tfrac{1}{x}$ and therefore $n(y)=1+n(x)$, so $s(x)s(y)=-1$. Suppose $x+y=1$. WLOG, $x > \tfrac{1}{2}$. If $x < 1$ then $x=[0;1,a,\dots]$ and $y=[0;1+a,\dots]$ where the $\dots$ is the same. If $x>1$ then $x=(-y)+1$ so they have the same number of terms in the continued fraction, thus $s(x)=s(-y)=-s(y)$ as desired.
02.06.2024 19:59
The answer is yes. We construct $s$ directly. First assume $s(0)=1$. For any $x>0$ we have \[s(x)=-s(-x)=s(x+1)\]and we also have $s(1)=-1$. Hence for any $n\in \mathbb{N}$ we have $s(n)=-1$. For each $q\ge 2$ (starting from the smallest), we now choose $s\left(\frac{p}{q}\right)$ for $p$ starting from $1$ and relatively prime to $q$ according to the following rules: If $p<q$ then $s\left(\frac{p}{q}\right)=-s\left(\frac{q}{p}\right)$. If $p>q$ then $s\left(\frac{p}{q}\right)=s\left(\frac{p-q}{q}\right)$. Evidently all outputs for nonnegative inputs have been chosen with no problems. Now we prove that for distinct positive rationals $x$ and $y$ the conditions hold. Importantly our selection of outputs satisfies $s(x)=s(x+1)$ as well. (The only restriction on $s(0)$ is $s(0)=-s(1)$ which clearly holds.) If $xy=1$ then WLOG $x=\frac{p}{q}$ with $p<q$. From the first rule in the previous section we are fine. Notice that $x+y=0$ cannot hold. If $x+y=1$ then write $x=\frac{a}{a+b}$ and $y=\frac{b}{a+b}$. Then \[s(x)=-s(1/x)=-s(1/x-1)=-s(b/a)\]\[s(y)=-s(1/y)=-s(1/y-1)=-s(a/b)\]thus $s(x)s(y)=-1$. Now we write $s(-x)=-s(x)$ for positive $x$. If $x$ and $y$ are distinct, negative and satisfy $xy=1$ we are okay: $s(-x)s(-y)=-1\implies s(x)s(y)=-1$. If $x$ and $y$ are distinct and satisfy $x+y=0$ we are okay by definition. If $x+y=1$ and WLOG $x$ is negative while $y$ is positive, then \[s(y)=s(y-1)=-s(1-y)=-s(x)\]and we are okay. All cases are exhausted and the construction works. $\blacksquare$