Solving functional equation $f(x+y)+f(x-y)=2f(x)\cos y$?
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.
If you could assume (or prove) that $f$ belongs to $\mathcal{C}^2(\mathbb{R})$, then you could do something like this:
Fix an arbitrary $x$, and apply $\frac{\mathrm{d}}{\mathrm{d}y}$ to both sides
\begin{align} f(x+y) + f(x-y) &= 2f(x)\cos(y)\\ f'(x+y) - f'(x-y) &= -2f(x)\sin(y)\\ f''(x+y) + f''(x-y) &= -2f(x)\cos(y) \end{align}
adding the first and last equality together yields
$$f''(x+y) + f''(x-y) + f(x+y) + f(x-y) = 0$$
for any $x \in \mathbb{R}$. Now substitute $y = 0$ to get $f''(x) + f(x) = 0$ with general solution $$f(x) = c_1 \sin(x) + c_2 \cos(x).$$
I hope this helps $\ddot\smile$