Romanian Selection 2006

Let $s$ and $r$ be your favorite rationals. Find all functions $f: \mathbb{Q} \rightarrow \mathbb{Q}$ such that for all rationals $x, y$ we have

$$
f(x+f(y))=f(x+r)+y+s
$$
We are trying to reduce to a Cauchy equation. We set \( x = 0 \). Then we set \( y = f(z) \). Combining the two, we find

\[
f(x + y + f(r) + s) = f(x + r) + f(y) + s
\]

If \( a := f(r) - r \), we have \( f(x + y + a + s) = f(x) + f(y) + s \). Setting \( y = 0 \) gives here \( f(x + a + s) = f(x) + s + f(0) \), from which we deduce:

\[
f(x + y) = f(x) + f(y) - f(0)
\]

The function \( g = f - f(0) \) satisfies the Cauchy equation, so it is linear over \( \mathbb{Q} \), it follows that \( f \) is affine. A verification gives \( x \mapsto x + r + s \) and \( x \mapsto -x + r - s \) as the only solutions.