Suppose I have a symmetric $2$ by $2$ matrix $M$ whose $(i,j)$-th entry $F\_{i,j}(\mathbf{x})$ belongs to $\mathbb{R}[x\_1, \ldots, x\_n]$ for each $i,j$. I know that for each $\mathbf{x} \in \mathbb{R}^n$, we can find an orthogonal matrix which diagonalises $M$. I was wondering if it is possible to find the orthogonal matrix and the diagonal matrix in terms of the polynomials (or fractions of polynomials), so that we can find some matrices $P(\mathbf{x})$ and $D(\mathbf{x})$ such that at each $\mathbf{x}$, $P$ is orthogonal and diagonalises $M$ to be $D$. I was guessing this is possible but I wasn't sure how to prove this statement. Any comments/suggestions or references are appreciated. Thank you. 



Diagonalising a symmetric matrix with polynomial entries
This cannot work. If a polynomial from $\mathbb R[\mathbf{x}]$ vanishes on $\mathbb R^n$, then it is $0$ itself. So if $P(\mathbf{v})^tP(\mathbf{v})=I\_2$ for each $\mathbf{v}\in\mathbb R^n$, then $P(\mathbf{x})^tP(\mathbf{x})=I\_2$. Similarly, we get $P(\mathbf{x})^tM(\mathbf{x})P(\mathbf{x})=D(\mathbf{x})$, so $M(\mathbf{x})$ has eigenvalues in $\mathbb R[\mathbf{x}]$. However, a matrix like $\begin{pmatrix}1&x\_1\\x\_1&0\end{pmatrix}$ doesn't have eigenvalues in $\mathbb R[\mathbf{x}]$ (for instance because the discriminant of its characteristic polynomial is $1+4x\_1^2$).


