6. Given $f(n)=\cos \frac{n \pi}{4}$. Calculate:
$$
f(1) f(3) \cdots f(2 n-1)=
$$
6. $\left\{\begin{array}{ll}\left(-\frac{1}{2}\right)^{\frac{n}{2}}, & n \text { is even; } \\ \left(\frac{1}{2}\right)^{\frac{n}{2}}, & n \text { is odd. }\end{array}\right.$

When $k \in \mathbf{Z}_{+}$,
$$
\begin{array}{l}
f(2 k-1) f(2 k+1) \\
=\cos \frac{(2 k-1) \pi}{4} \cdot \cos \frac{(2 k+1) \pi}{4} \\
=\frac{1}{2}\left(\cos k \pi+\cos \frac{\pi}{2}\right)=\frac{(-1)^{k}}{2} .
\end{array}
$$

In particular, we have
$$
\begin{array}{l}
f(1) f(3)=f(5) f(7)=\cdots \\
=f(4 k+1) f(4 k+3)=-\frac{1}{2} .
\end{array}
$$

Therefore, when $n$ is even,
$$
f(1) f(3) \cdots f(2 n-1)=\left(-\frac{1}{2}\right)^{\frac{n}{2}} \text {; }
$$

When $n$ is odd,
$$
\begin{array}{l}
f(1) f(3) \cdots f(2 n-1)=\left(-\frac{1}{2}\right)^{\frac{n-1}{2}} \cos \frac{(2 n-1) \pi}{4} \\
=\left(-\frac{1}{2}\right)^{\frac{n-1}{2}} \cos \left(\frac{n-1}{2} \pi+\frac{\pi}{4}\right) \\
=\left(-\frac{1}{2}\right)^{\frac{n-1}{2}}(-1)^{\frac{n-1}{2}} \times \frac{\sqrt{2}}{2}=\left(\frac{1}{2}\right)^{\frac{n}{2}} .
\end{array}
$$