Find the maximal value of $a+b-c+d$ Let $a, b, c, d$ be real numbers satisfying inequality $$f(x)=a\cos x+b\cos 2x+c\cos 3x+d\cos 4x\le 1$$ holds for $x\in\Bbb{R}$. Find the maximal value of $a+b-c+d$ and determine the values of $a,b,c,d$ when that maximum is attained.
Try $f(0)=a+b+c+d\le 1$, $f(\pi)=-a+b-c+d\le 1$ and
$$f\left(\dfrac{\pi}{2}\right)=-b+d\le 1$$

We claim that the maximum is 3 given by $a=1,b=\frac{1}{2},c=-1,d=\frac{1}{2}$. Using the usual formulae, we have $\cos x+\frac{1}{2}\cos2x-\cos3x+\frac{1}{2}\cos4x=f(c)$, where $f(c)=c+\frac{1}{2}(2c^2-1)-(4c^3-3c)+\frac{1}{2}(8c^4-8c^2+1)=4c^4-4c^3-3c^2+4c$, where $c=\cos x$. We have $f'(c)=16c^3-12c^2-6c+4=2(2c-1)(4c^2-c-2)$, which as zeros at $c=\frac{1\pm\sqrt{33}}{8},\frac{1}{2}$, so $f'(c)$ is negative for $-1<c-0.593$, positive for $-0.593<c<0.5$, negative for $0.5<c<0.843$ and positive for $c>0.843$. So in the range $[-1,1]$ it has two local minima and a local maximum at $\frac{1}{2}$. We find $f(-1)=f(1)=1$ and $f(\frac{1}{2})=1$, so $f(c)\le1$ for all $c\in[-1,1]$.
It remains to show that we cannot do better than that. The inequality must hold for $x=0$, so we have $a+b+c+d\le1$ (1). It holds for $x=\frac{\pi}{3}$ so $a-b-2c-d\le2$ (2), and it holds for $x=\pi$ so $-a+b-c+d\le1$ (3). Taking (1)+$\frac{2}{3}$(2)+$\frac{2}{3}$(3) we have $a+b-c+d\le3$.
