Step 1: Rewrite f in one variable:
Use the identity $\cos 2x = 2\cos^2 x - 1$. Put $t = \cos x$.
\[ f = t - \tfrac{1}{2}(2t^2 - 1) = -t^2 + t + \tfrac{1}{2} \]
Step 2: Find the range of t:
As $x$ goes from $0$ to $\frac{\pi}{2}$, $\cos x$ falls steadily from $1$ to $0$.
So $t$ takes every value in $[0, 1]$.
Step 3: Study the quadratic in t:
Let $g(t) = -t^2 + t + \frac{1}{2}$. This is a downward parabola.
Complete the square: \[ g(t) = -\left(t - \tfrac{1}{2}\right)^2 + \tfrac{3}{4} \]
The vertex is at $t = \frac{1}{2}$, which lies inside $[0, 1]$. So the maximum is $g\left(\frac{1}{2}\right) = \frac{3}{4}$.
Step 4: Find the minimum:
A downward parabola is smallest at the end of the interval farthest from the vertex. Both ends are the same distance from $t = \frac{1}{2}$.
\[ g(0) = \tfrac{1}{2}, \qquad g(1) = -1 + 1 + \tfrac{1}{2} = \tfrac{1}{2} \]
So the minimum is $\frac{1}{2}$.
Step 5: Multiply:
Maximum $\times$ minimum $= \frac{3}{4} \times \frac{1}{2} = \frac{3}{8}$.
Final Answer:
The maximum is $\frac{3}{4}$ (at $x = \frac{\pi}{3}$) and the minimum is $\frac{1}{2}$ (at $x = 0$ and $x = \frac{\pi}{2}$), so the product is $\frac{3}{8}$.
\[ \boxed{\frac{3}{8}} \]