Problem Formulation
under what conditions can we solve $\mathrm{trace}(\mathbf{AB})=0$ ? or more specifically, when will $\mathrm{trace}(\mathbf{AB})=0$ implies that $\mathrm{trace}(\mathbf{B})=0$.
Related Art
This occurs to me when $\mathbf{A}$ was a Positive semidefinite matrix, and $\mathbf{B}$ was a symmetric matrix with a parameter $\lambda$. I want to solve a partial derivatives equations which constrains that $\mathrm{trace}[\mathbf{AB}(\lambda)] = 0$, i.e., \begin{equation} \frac{\partial \mathcal{L}(i)}{\partial \gamma_i} = \mathrm{Tr}\left[ (\mathbf{I}_{d_i} + \gamma_i\mathbf{B}_i\mathbf{s}_i)^{-1}\mathbf{B}_i\mathbf{s}_i\right] - \mathbf{q}_i^T(\gamma_i^{-1}\mathbf{B}_i^{-1} + \mathbf{s}_i)^{-1}\frac{\mathbf{B}_i^{-1}}{\gamma_i^2}(\gamma_i^{-1}\mathbf{B}_i^{-1} + \mathbf{s}_i)^{-1}\mathbf{q}_i, \end{equation} where $\mathbf{s}_i$ and $\mathbf{B}_i$ are symmetric PSD matrix, $\mathbf{q}_i$ is a column vector, $\gamma_i$ is a scalar, $\mathbf{I}_d$ is an identity matrix with size $d$. I want to solve \begin{equation} \frac{\partial \mathcal{L}(i)}{\partial \gamma_i} = 0. \end{equation} with $\gamma_i$ derived in a closed-form.
Using cyclic product properties of the trace norm, I could only go this far, \begin{equation} \frac{\partial \mathcal{L}(i)}{\partial \gamma_i} = \mathrm{Tr}\left[ (\mathbf{B}_i^{-1} + \gamma_i\mathbf{s}_i)^{-1}\mathbf{B}_i^{-1}(\mathbf{B}_i^{-1} + \gamma_i\mathbf{s}_i)^{-1}\left( \mathbf{s}_i + \gamma_i\mathbf{s}_i\mathbf{B}_i\mathbf{s}_i - \mathbf{q}_i\mathbf{q}_i^T \right) \right] \end{equation} I sensed that the closed form solution of $\gamma_i$ might be related with \begin{equation} \mathrm{trace}\left( \mathbf{s}_i + \gamma_i\mathbf{s}_i\mathbf{B}_i\mathbf{s}_i - \mathbf{q}_i\mathbf{q}_i^T \right) = 0. \end{equation}
Counter Example
plus, I can also give a counter example. Let $$ \mathbf{A} = \begin{pmatrix} 2 & 1 \\\ 1 & 2 \end{pmatrix}, \quad \mathbf{B} = \begin{pmatrix} 1+\lambda & -2 \\\ -2 & \lambda - 3 \end{pmatrix}, $$ where $\mathrm{trace}(\mathbf{AB})=0$ implies $\lambda=2$, $\mathrm{trace}(\mathbf{B})=0$ implies $\lambda=1$.