4. Let $f(x)=x^{4}-\frac{3}{4} x^{2}-\frac{1}{8} x+1$. Then $f\left(\cos \frac{\pi}{7}\right)=$ $\qquad$

Translate the text above into English, please retain the original text's line breaks and format, and output the translation result directly.
4. $\frac{15}{16}$.

Let $x=\cos \frac{\pi}{7}$. Then
$$
\begin{array}{l} 
x^{4}=\left(\cos ^{2} \frac{\pi}{7}\right)^{2}=\left(\cdot \frac{1+\cos \frac{2 \pi}{7}}{2}\right)^{2} \\
=\frac{1+2 \cos \frac{2 \pi}{7}+\cos ^{2} \frac{2 \pi}{7}}{4} \\
=\frac{3+4 \cos \frac{2 \pi}{7}+\cos \frac{4 \pi}{7}}{8}, \\
-\frac{3}{4} x^{2}=\frac{-3-3 \cos \frac{2 \pi}{7}}{8},-\frac{x}{8}=-\frac{\cos \frac{\pi}{7}}{8} .
\end{array}
$$

Therefore, $x^{4}-\frac{3}{4} x^{2}-\frac{1}{8} x$
$$
\begin{array}{l}
=\frac{1}{8}\left(-\cos \frac{\pi}{7}+\cos \frac{2 \pi}{7}+\cos \frac{4 \pi}{7}\right) \\
=\frac{1}{8}\left(\cos \frac{2 \pi}{7}+\cos \frac{4 \pi}{7}+\cos \frac{6 \pi}{7}\right) \\
=\frac{1}{8}\left(\cos \frac{12 \pi}{7}+\cos \frac{10 \pi}{7}+\cos \frac{8 \pi}{7}\right) \\
=\frac{1}{16} \sum_{k=1}^{6} \cos \frac{2 k \pi}{7}=\frac{1}{16} \sum_{k=0}^{6} \cos \frac{2 k \pi}{7}-\frac{1}{16} \\
=-\frac{1}{16} .
\end{array}
$$

Thus, $x^{4}-\frac{3}{4} x^{2}-\frac{1}{8} x+1=\frac{15}{16}$, that is
$$
f\left(\cos \frac{\pi}{7}\right)=\frac{15}{16}
$$