Let $A$ and $B$ be self-adjoint $n \times n$ matrices. Let $A$ be diagonal. Suppose $A+tB$ and $tA+B$ are invertible for all $t \in \mathbb R$. What can we say about $A$ and $B$?


My guess is that $\mbox{Tr}(A) = \mbox{Tr}(B) = 0$. Definitely when $n$ is odd there exist no $A, B$ satisfying the hypothesis. Because in this case $\det(A+tB)$ is an odd-degree polynomial. I do not know what happens if $n$ is even.


If $B$ is also diagonal, then it cannot happen that $A+tB$ and $tA+B$ are invertible for all $t \in \mathbb R$. This is easy to see.



A question of invertibility of matrices
There is a Jordan-like canonical form for symmetric matrix pairs $(A,B) = (A^\*,B^\*) \in \mathbb{C}^{n\times n} \times \mathbb{C}^{n\times n}$ under the transformation $(A,B) \to (M^\*AM,M^\*BM)$, with $M$ square invertible. You can find it stated, for instance, in Lemma~3 of Thompson's paper <https://doi.org/10.1016/0024-3795(76)90021-5> . This canonical form is known today as *even Kronecker canonical form* (in a slightly different variant when $B$ is anti-Hermitian, but you can just multiply $B \gets iB$ to fix this).


Note that if you are interested in a canonical form under that transformation the requirement that $A$ is diagonal becomes superfluous, because you can always reduce to that case with another transformation of the same kind.


Each block in this canonical form determines a polynomial factor of $\det(A+tB)$, apart from type IV which is present only in pairs for which $\det(A+tB)\equiv 0$. So you just need to check which blocks correspond to factors that have no real zeros to find a complete characterization of these matrix pairs in terms of their blocks. If I am not mistaken, the allowed blocks are those of type II and III.


