If g(y1)=g(y2), the first equality yields y1=y2, hence g is injective. Analogously, f is injective, as well.
Plugging y=0 in the first equality gives f(g(x)+g(0))=f(g(x)), hence g(x)+g(0)=g(x), so that g(0)=0; similarly, f(0)=0.
Plugging x=0 in both equalities yields f(g(y))=g(f(y))=y, for all y, therefore f and g are bijective and g=f−1.
The initial equalities become
f(g(x)+g(y))=x+y,g(f(x)+f(y))=x+y,
for all x,y∈Q, and we deduce
g(x+y)=g(x)+g(y),f(x+y)=f(x)+f(y),
for all x,y∈Q. Setting a=f(1),b=g(1), it is easy to prove that f(x)=ax,g(x)=bx, for all x∈Q.
Since g=f−1, we obtain ab=1. Finally, the functions are
f(x)=ax,g(x)=ax,
where a∈Q∗, and it is easy to see that they satisfy the initial equalities.