I'm new to solving functional equations and found the following functional equation from a collection of functional equations.
Find all functions $f: \mathbb{Q}\to \mathbb{R}$ for $$f(x+y)=f(x)f(y)-f(xy)+1$$ for all $x,y\in \mathbb{Q}$.
By substituting $x,y\to 0$, we get $$f(0)=f(0)^2-f(0)+1$$ $$f(0)^2-2f(0)+1=0$$ $$f(0)=1$$ And then doing the substitution $x\to 1,\ y\to -1$, we get $$f(0)=f(1)f(-1)-f(-1)+1$$ $$f(1)f(-1)-f(-1)=0$$ $$f(-1)(f(1)-1)=0$$ $$f(-1)=0\vee f(1)=1$$
So, no we have three possible cases to consider and I have no idea on how to proceed on any of them. I would appreciate any hints before giving the full solution as in the best case that's all I need right now.
$f(0)=f(0+0)=f(0)^2-f(0)+1$ so $(f(0)-1)^2=0$, $\therefore f(0)=1$.
Let $f(1)=a+1$, then noting that $f(n+1)=af(n)+1$ \begin{align}f(2)&=f(1+1)=a^2+a+1\\ f(4)&=f(3+1)=\cdots=a^4+a^3+a^2+a+1\\ &=f(2+2)=f(2)^2-f(4)+1\end{align} $$\therefore 2f(4)=f(2)^2+1$$ Solving for $a$ gives $a=-1,0,1$.
If $a=-1$, $f(1)=0$, then $f(n)=\begin{cases}1&n \textrm{ odd}\\0&n \textrm{ even}\end{cases}$. This gives the formula $f(x+1)=1-f(x)$. This function does not extend to $\mathbb{Q}$ otherwise $f(1)=f(2\times\tfrac{1}{2})=f(2)f(\tfrac{1}{2})-f(2+\tfrac{1}{2})+1$, which is the same as $0=f(\tfrac{1}{2})-f(\tfrac{1}{2})+1$.
If $a=0$, then $f(n)=1$ for all $n$. This extends to all of $\mathbb{Q}$ by noting that $f(x+1)=f(x)f(1)-f(x)+1=1$.
If $a=1$, then $f(n)=n+1$ for all $n$. This extends as in this answer to $\mathbb{Q}$.
The last two functions $f(x)=x+1$ and $f(x)=1$ satisfy the general formula for all $x\in \mathbb{Q}$.