9. (16 points) Given the function
$$
f(x)=a \cos x+b \cos 2 x+c \cos 3 x,
$$

and $f(x) \geqslant-1$ always holds. Find the maximum value of $a-b+c$.
Let $x=\pi$. Then
$$
f(\pi)=-a+b-c \geqslant-1 \Rightarrow a-b+c \leqslant 1 \text {. }
$$

Thus, the maximum value of $a-b+c$ does not exceed 1.
Let $a=1, b=0, c=0$, at this point,
$$
f(x)=\cos x \geqslant-1
$$

always holds.
Therefore, the maximum value of $a-b+c$ is 1.