$f$ is defined on a stack and its value changes on a push operation.
Initially $f(S) = 1$ when no element is present.
After first push, 4, $f(S) =\max(1,1) \times 4 = 4$.
After second push, -2, $f(S) = \max(4,1) \times -2 = -8$.
After third push, 9, $f(S) = \max(-8, 1) \times 9 = 9$.