Functional equation $f(x)+f(y)-f(x+y)=4f\left(\frac{x}{2}\right)f\left(\frac{y}{2}\right)f\left(\frac{x+y}{2}\right)$ Find all functions $f:\mathbb R\rightarrow \mathbb R$ such that for all reals $x$ and $y$:
$$f(x)+f(y)-f(x+y)=4f\left(\frac{x}{2}\right)f\left(\frac{y}{2}\right)f\left(\frac{x+y}{2}\right)$$
Thank you.
 A: When $x\to 2x$ and $y\to 0,$ we have $f(0)=4f(0)(f(x))^2$ which implies $f(0)=0$ or $f(x)=\pm\dfrac12.$ Hence we have three constant function solutions $$f(x)=0, \dfrac12, -\dfrac12$$ and for all non-constant solutions $f(0)=0.$  
Now consider non-constant solutions. There when $y\to-x,$ we have $f(-x)=-f(x)$ which says $f$ must be an odd function. Hence if we can determine $f(x)$ for all $x\ge 0$ then we have the complete solution. On the other hand, the given functional equation implies if $f$ is a solution, then $-f$ is also a solution.  
Form here we solve the given functional equation under the following two (reasonable) conditions:  

1) $f$ is continuous.
  2)  There is a smallest positive zero $a$ for $f.$ 

Then without loss of generality we can assume that $f(x)\gt 0$ in the interval $x\in (0,a).$ Also now letting $y\to x$ we have $f(2x)=2f(x)(1-2(f(x/2))^2)\tag 1$ and this implies $f(2a)=0$ and by mathematical induction we can claim that $f(na)=0$ for all $n\in\Bbb{N}.$ Furthermore by $y\to 2a$ we can have $$f(x)=f(2a+x).$$ Hence $f$ must be $2a$ periodic. Further $x, y\to 2(a+x)$ implies $f(a+x)=\pm f(x).$ Therefore $f$ has no zeros between $a$ and $2a,$ hence $$f(x)=0 \iff x\in\{na : n\in\Bbb{Z}\}.$$ Also $y\to a,$ gives us $f(x)-f(a+x)=4f(a/2)f(x/2)f((a+x)/2)\neq 0$ for $x\in(0,a)$ and therefore $$f(x)=-f(a+x)=f(a-x)$$ and $f(x)=2f(a/2)f(x/2)f((a+x)/2)\tag 2.$ Also by $(1), (2)$ we have $$\dfrac{f(2x)}{2f(x)}=f(a/2)f(x+a/2)=1-2(f(x/2))^2\tag 3$$
At this point we can evaluate $f$ at some special values.
i) When $x\to 0$ by $(3)$ we have $f(a/2)=1.$
ii) When $x\to a/2$ by $(1)$ we have $f(a/4)=\sqrt 2/2.$
More importantly, by the third equation, we can claim that $0\lt f(x)\lt 1$ for all $x\in (0, a).$

Now we are ready to prove that $f(x)=\sin(\pi x/a).$  

First note that this is true for $x=a, a/2, a/4.$ Using mathematical induction with $(3)$ we can prove this for all $x=a/2^m,   m\in\Bbb{Z}.$ Also using the fact $$f(x+y)=f(x)+f(y)-4f\left(\frac{x}{2}\right)f\left(\frac{y}{2}\right)f\left(\frac{x+y}{2}\right)$$ we can extend our result for all $x=an/2^m,   m,n\in\Bbb{Z}.$
Note that every real number is a limit of sequence of Dyadic rationals and hence by continuity, we have the result. 
