# When are two diagonal matrices congruent?

This is probably a question that does not admit a simple answer. However, I'd like to know whether there exist criteria that determine when two diagonal matrices are congruent. I have the suspicion that, if such criteria exist, they depend strongly from the base field. In fact, over a quadratically closed field two diagonal matrices are congruent iff they have the same rank and over real closed fields Sylvester theorem answers completely the question. But over other fields?

By Witt decomposition, we can restrict ourselves to consider only the case in which $A$ and $B$ are anisotropic. Hence the question is:

Let $\mathbb{K}$ be a field and let $A = \mathrm{diag}(a_1, \dots, a_n)$ and $B = \mathrm{diag}(b_1,\dots,b_n)$ be two diagonal matrices over the field $\mathbb{K}$ such that $^t x A x \neq 0$ and $^t x B x \neq 0$ for all $x \in \mathbb{K}^n \setminus \{ 0 \}$. (In particular $a_i \neq 0$ and $b_i \neq 0$). What are necessary or sufficient conditions to have that $A$ and $B$ are congruent?

-

One necessary condition is that $\prod_ia_i=c^2\prod_ib_i$, for some $c\in\mathbb{K}$. When $\mathbb{K}$ is a finite field, this condition is also sufficient.
Over $\mathbb{Q}$, things are more complicated, but the answer is known: the problem reduces to the same problem over the $p$-adic fields $\mathbb{Q}_p$ (see http://en.wikipedia.org/wiki/Hasse%E2%80%93Minkowski_theorem).
Over the $p$-adic fields $\mathbb{Q}_p$ there are known necessary and sufficient conditions (see, e.g., this book: http://books.google.pt/books?id=Ohj9NNk6btUC&printsec=frontcover&hl=pt-PT&source=gbs_ge_summary_r&cad=0#v=onepage&q&f=false).