4. Bivariate function
$$
\begin{array}{l}
f(x, y) \\
=\sqrt{\cos 4 x+7}+\sqrt{\cos 4 y+7}+ \\
\quad \sqrt{\cos 4 x+\cos 4 y-8 \sin ^{2} x \cdot \sin ^{2} y+6}
\end{array}
$$

The maximum value is . $\qquad$
4. $6 \sqrt{2}$.

Let $\cos ^{2} x=a, \cos ^{2} y=b$.
Then $0 \leqslant a, b \leqslant 1$,
$$
\begin{array}{l} 
f= 2 \sqrt{2}\left(\sqrt{a^{2}-a+1}+\sqrt{b^{2}-b+1}+\right. \\
\left.\sqrt{a^{2}-a b+b^{2}}\right) .
\end{array}
$$

From $0 \leqslant a \leqslant 1 \Rightarrow a^{2} \leqslant a \Rightarrow \sqrt{a^{2}-a+1} \leqslant 1$.
Similarly, $\sqrt{b^{2}-b+1} \leqslant 1$.
Notice that,
$$
\begin{array}{l}
\sqrt{a^{2}-a b+b^{2}} \leqslant \sqrt{a-a b+b} \\
=\sqrt{1-(1-a)(1-b)} \leqslant 1 .
\end{array}
$$

Thus, $f \leqslant 6 \sqrt{2}$.
When $a=b=1$ or $a=0, b=1$ or $a=1, b=0$, $f$ achieves the maximum value $6 \sqrt{2}$.