There are good resources about this equation, that have studied the solutions of
$$f(x+y)+f(x-y)=2f(x)f(y)\tag0\label0$$
or its generalizations. For example, Functional Equations in
Several Variables by J. Aczel and J. Dhombers, or Introduction to
Functional Equations by P. Kannappan and P. Sahoo, and of course many
other books and papers which can be found on the internet. Here, I try to
solve the equation for two more common cases.
- Every continuous function $f:\mathbb R\to\mathbb R$ satisfying \eqref{0} is
of the form $f(x)=0$, $f(x)=\cos(\alpha x)$ or $f(x)=\cosh(\alpha x)$.
Letting $x=y=0$ in \eqref{0} we find out that $f(0)=0$ or $f(0)=1$. If
$f(0)=0$, then letting $y=0$ in \eqref{0}, we infere that $f$ is the constant zero function. So let's suppose $f(0)=1$. Letting $x=0$ in \eqref{0}, we find
out that $f$ is an even function. Also, since $f$ is continuous, there is a positive $t$ such that for every $-t\leq y\leq t$ we have $f(y)>0$. Now, $f$ is locally integrable because it's continuous. Thus we have:
$$\int_{-t}^tf(x+y)\,dy+\int_{-t}^tf(x-y)\,dy=2f(x)\int_{-t}^tf(y)\,dy$$
$$\therefore\quad2\int_{x-t}^{x+t}f(y)\,dy=2f(x)\int_{-t}^tf(y)\,dy\tag1\label1$$
So by the fundumental theorem of calculus, the left hand side of \eqref{1} is a
differentiable function of $x$, because $f$ is continuous. Hence the right
hand side is differentiable too and we have:
$$f(x+t)-f(x-t)=f^\prime(x)\int_{-t}^tf(y)\,dy\tag2\label2$$
$$\therefore\quad f(t)-f(-t)=f^\prime(0)\int_{-t}^tf(y)\,dy$$
But since $f$ is even and $\int_{-t}^tf(y)\,dy>0$, we have $f^\prime(0)=0$.
Again, since $f$ is differentiable, so the left hand side of \eqref{2} is a
differentiable function of $x$ and thus the right hand side is so, which
yields that $f$ is two times differentiable (continuing this way, we can
prove that $f$ has derivatives of any order). Now, differentiating \eqref{0}
twice, with respect to $y$ we get:
$$f^{\prime\prime}(x+y)+f^{\prime\prime}(x-y)=2f(x)f^{\prime\prime}(y)$$
$$\therefore\quad f^{\prime\prime}(x)=f^{\prime\prime}(0)f(x)\tag3\label3$$
It's a well-known result of elementry differential equations that if $f$
satisfies \eqref{3} and $f(0)=1$ and $f^\prime(0)=0$, then
$f(x)=\cosh\left(\sqrt{f^{\prime\prime}(0)}x\right)$ when $f^{\prime\prime}(0)\geq0$ and
$f(x)=\cos\left(\sqrt{-f^{\prime\prime}(0)}x\right)$ when $f^{\prime\prime}(0)\leq0$.
- A function $f:\mathbb R\to\mathbb C$ is a solution of \eqref{0} iff it's of
the form $f(x)=\frac{E(x)+E(-x)}2$ for some $E:\mathbb R\to\mathbb C$
satisfying $E(x+y)=E(x)E(y)$ for all $x$ and $y$.
Assume that $E:\mathbb R\to\mathbb C$ satisfies $E(x+y)=E(x)E(y)$. we have:
$$\frac{E(x+y)+E(-x-y)}2+\frac{E(x-y)+E(-x+y)}2\\
=\frac{E(x)E(y)+E(-x)E(-y)+E(x)E(-y)+E(-x)E(y)}2\\
=2\cdot\frac{E(x)+E(-x)}2\cdot\frac{E(y)+E(-y)}2$$
So $\frac{E(x)+E(-x)}2$ satisfies \eqref{0}. Conversly, suppose that $f$
satisfies \eqref{0}. If $f$ is the constant zero function, then we let $E$ be
the constant zero function and we would have $f(x)=\frac{E(x)+E(-x)}2$ and
$E(x+y)=E(x)E(y)$. Otherwise, $f(0)$ must be equal to $1$. Now, letting $y=x$
in \eqref{0} we get:
$$f(2x)=2f(x)^2-1$$
Replacing $x$ by $x+y$ and $y$ by $x-y$ in \eqref{0} we have:
$$f(2x)+f(2y)=2f(x+y)f(x-y)$$
$$\therefore\quad f(x+y)f(x-y)=f(x)^2+f(y)^2-1$$
Thus we conclude that:
$$\big(f(x+y)-f(x)f(y)\big)^2\\
=f(x+y)^2-2f(x)f(y)f(x+y)+f(x)^2f(y)^2\\
=f(x+y)^2-\big(f(x+y)+f(x-y)\big)f(x+y)+f(x)^2f(y)^2$$
$$\therefore\quad\big(f(x+y)-f(x)f(y)\big)^2=\left(f(x)^2-1\right)
\left(f(y)^2-1\right)\tag4\label4$$
Now, if for every $x$ we have $f(x)=-1$ or $f(x)=1$, then by \eqref{4} we have
$f(x+y)=f(x)f(y)$. Since in this case $f(x)f(-x)=1$, if we let $E(x):=f(x)$
then $f(x)=\frac{E(x)+E(-x)}2$ and $E(x+y)=E(x)E(y)$. So let's suppose that
for some $x_0$ we have $f(x_0)\neq-1$ and $f(x_0)\neq1$. We define
$\alpha=f(x_0)$, $\beta^2:=\alpha^2-1$ and $E(x):=\frac1\beta\big(f(x+x_0)+
(\beta-\alpha)f(x)\big)$. By \eqref{4} we have:
$$\big(E(x)-f(x)\big)^2=\frac1{\beta^2}\big(f(x+x_0)-f(x_0)f(x)\big)^2=f(x)^2-1$$
$$\therefore\quad E(x)^2-2f(x)E(x)+1=0$$
$$\therefore\quad f(x)=\frac{E(x)+E(x)^{-1}}2$$
Next we consider:
$$E(x)E(y)=\frac1{\beta^2}\big(f(x+x_0)+(\beta-\alpha)f(x)\big)
\big(f(y+x_0)+(\beta-\alpha)f(y)\big)\\
=\frac1{\beta^2}\Big(f(x+x_0)f(y+x_0)+(\beta-\alpha)\big(f(x)f(y+x_0)+f(y)f(x+x_0)\big)+
(\beta-\alpha)^2f(x)f(y)\Big)\tag5\label5$$
We also note that by \eqref{0}:
$$2f(x+x_0)f(y+y_0)=f(x+y+2x_0)+f(x-y)\\
=\big(2f(x_0)f(x+y+x_0)-f(x+y)\big)+\big(2f(x)f(y)-f(x+y)\big)\\
=2\big(\alpha f(x+y+x_0)+f(x)f(y)-f(x+y)\big)\tag6\label6$$
And again by \eqref{0}:
$$2\big(f(x)f(y+x_0)+f(y)f(x+x_0)\big)\\
=2f(x+y+x_0)+f(x_0+x-y)+f(x_0-x+y)\\
=2f(x+y+x_0)+2f(x_0)f(x-y)\\
=2\Big(f(x+y+x_0)+\alpha\big(f(x)f(y)-f(x+y)\big)\Big)\tag7\label7$$
Combining \eqref{5}, \eqref{6} and \eqref{7} we get:
$$E(x)E(y)\\
=\frac1{\beta^2}\Big(\left((\beta-\alpha)^2+2\alpha(\beta-\alpha)+1\right)
f(x)f(y)+\beta f(x+y+x_0)-\big(1+\alpha(\beta-\alpha)\big)f(x+y)\Big)\\
=\frac1{\beta^2}\Big(\left(\beta^2-\alpha^2+1\right)f(x)f(y)+\beta
f(x+y+x_0)-\left(\alpha\beta+1-\alpha^2\right)f(x+y)\Big)\\
=\frac1{\beta^2}\big(\beta f(x+y+x_0)+\beta(\beta-\alpha)f(x+y)\big)$$
$$\therefore\quad E(x)E(y)=E(x+y)$$
Since $E(x)E(-x)=1$ we have $f(x)=\frac{E(x)+E(-x)}2$.