TITLE: Solving functional equation $f(x+y)+f(x-y)=2f(x)\cos y$?
QUESTION [7 upvotes]: How can I solve this functional equation, where $x,y$ are any real numbers and $f:\mathbb{R}\to \mathbb R$ is a function such that :
$$f(x+y)+f(x-y)=2f(x)\cos y$$

I tried substituting $x=0$ to get $f(y)+f(-y)=2f(0)\cos y$ . Taking $x=y$ gives $f(2x)+f(0)=2f(x)\cos x$. I similar get some more relations like that, but its not really helping me in finding anything useful. I also think the function must either be $\sin$ or $\cos$ looking at the product to sum formulae. Can anyone tell me how should I solve this?

REPLY [7 votes]: Let $P(x,y)$ be the functional equation
$$f(x+y)+f(x-y)=2f(x)\cos y\text{,}\tag{0}\label{0}$$ $A=f(0)$ and $B=f\left (\frac{\pi}{2}\right )$.
$$P(0,x)\implies f(x)+f(-x)=2A\cos x\text{.}\tag{1}\label{1}$$
$$P\left (x+\frac{\pi}{2},\frac{\pi}{2}\right )\implies f(x+\pi)+f(x)=0\text{.}\tag{2}\label{2}$$
$$P\left (\frac{\pi}{2},x+\frac{\pi}{2}\right )\implies f(x+\pi)+f(-x)=-2B\sin x\text{.}\tag{3}\label{3}$$
So, by $\frac{\eqref{1}+\eqref{2}-\eqref{3}}{2}$,
$$f(x)=A\cos x+B\sin x\text{.}\tag{4}\label{4}$$
Substituting \eqref{4} in \eqref{0}, the functional equation works, regardless of the values of $A$ and $B$. So we have found all the solutions.