I use the following definition of the matrix derivative of $f(Q)$
$(\delta f)(Q) = \lim_{t \to 0} f(Q+t \delta Q)-f(Q)$
where, $ \delta Q $ is a symmetric not necessarily positive definite matrix.
It is important to notice that the matrix derivative operator $\delta$ obeys the Leibniz rule.
Furthermore, in the following, the cyclicity of the trace, and the identity
$\delta Q^{-1} = - Q^{-1} \delta Q Q^{-1}$ obtained from the matrix differentiation of $Q Q^{-1} = 1$ are used.
The first matrix derivative of $f(Q)$ is given by:
$\delta f(Q) = tr(-W Q^{-1} \delta Q Q^{-1} W + \delta Q )= tr((-Q^{-1} W^2 Q^{-1}+1) \delta Q )$
Therefore, the condition $\delta f(Q) = 0$, implies:
$-Q^{-1} W^2 Q^{-1} = 1$
which is equivalent to:
$Q^2 = W^2 $.
Now, $Q = W $ is the only solution, because both $Q$ and $W$ are defined to be positive definite. To verify that this solution is a minimum,
we check the second matrix derivative is positive for an arbitrary $\delta Q$:
$\delta^2 f(Q) = tr((Q^{-1} \delta Q Q^{-1} W^2 Q^{-1}+Q^{-1} W^2 Q^{-1}\delta Q Q^{-1}) \delta Q ) = 2 tr(Q^{-1} (\delta Q)^2)$
Where, the second equality is obtained after the substitution of the solution.