What is the range of this function Let $\lambda_{1}(X)$
be the larger eigenvalue of the $2$ eigenvalues of a symmetric matrix X. For fixed real numbers $a,b,c,d$,
what is the range of $\lambda_{1}\left(diag\left(a,b\right)-U\cdot diag\left(c,d\right)\cdot U^{T}\right)$
as a function of $U$, where $U$ is in the set of $2$ by $2$ orthogonal
matrices?
 A: In general, if $D$ and $\Lambda$ are $n\times n$ real diagonal matrices, we have
$$\max_{U\in O(n;\mathbb{R})}\lambda_\max(D-U\Lambda U^T)=\max_i d_i - \min_i \lambda_i.$$
Finding $\min_{U\in O(n;\mathbb{R})}\lambda_\max(D-U\Lambda U^T)$ requires more careful analysis in general, but it can be solved easily in the $2\times2$ case. Since the mapping $U\mapsto U\operatorname{diag}(1,-1)$ is a bijection between the two disconnected components of the orthogonal group and $\operatorname{diag}(1,-1)\,\operatorname{diag}(c,d)\,\operatorname{diag}(1,-1)=\operatorname{diag}(c,d)$, you may assume that $U\in SO(2)$. So, we consider an expression of the form
$$A=\pmatrix{a\\ &b}-\pmatrix{C&-S\\ S&C}\pmatrix{c\\ &d}\pmatrix{C&S\\ -S&C},$$
where $C=\cos\theta$ and $S=\sin\theta$. Straightforward calculations show that
\begin{align*}
\operatorname{trace}(A) &=a+b-c-d,\\
\det(A) &= (a-c)(b-d) - S^2(a-b)(c-d),\\
\lambda_\max(A) &= \frac12\left(\operatorname{trace}(A)+\sqrt{\operatorname{trace}(A)^2-4\det(A)}\right).
\end{align*}
Hence $\lambda_1(A)$ is maximised (resp. minimised) when $\det(A)$ is minimised (resp. maximised). Since $\det(A)$ is a continuous function in $s$ and its extrema occurs at $S^2=\sin^2\theta=0$ or $1$, i.e. at $U=I$ or $\pm\pmatrix{0&-1\\ 1&0}$, the range of $\lambda_1(A)$ is the closed interval with endpoints $\max(a-c,\ b-d)$ and $\max(a-d,\ b-c)$.
