For two n-by-n matrices A and B , it was known before that their numerical radii satisfy the inequality w(AB)≤4w(A)w(B), and the equality is attained by the 2-by-2 matrices and . Moreover, the constant “4” here can be reduced to “2” if A and B commute, and the corresponding equality is attained by and . In this paper, we give a complete characterization of A and B for which the equality holds in each case. More precisely, it is shown that w(AB)=4w(A)w(B) (resp., w(AB)=2w(A)w(B) for commuting A and B) if and only if either A or B is the zero matrix, or A and B are simultaneously unitarily similar to matrices of the form and (resp.,
with w(A′)≤|a|/2 and w(B′)≤|b|/2. An analogous characterization for the extremal equality for tensor products is also proven. For doubly commuting matrices, we use their unitary similarity model to obtain the corresponding result. For commuting 2-by-2 matrices A and B , we show that w(AB)=w(A)w(B) if and only if either A or B is a scalar matrix, or A and B are simultaneously unitarily similar to and with |a1|≥|a2| and |b1|≥|b2|.