# How do the eigenvalues of $A$ relate to $DAD$ where $A$ is symmetric and $D$ is diagonal?

How do the eigenvalues of $A$ relate to $DAD$ where $A$ is symmetric and $D$ is diagonal? Specifically, I'm interested in the case where most of the eigenvalues of $A$ and $D$ are the same. For example consider the following piece of MATLAB/Octave code. In creates a matrix $A$ with three different eigenvalues where the last has multiplicity $m-2$. It does the same for $D$:

% Set the size
m=20;

% Create a random symmetric matrix
A=randn(m);
A=(A+A')/2;
[V D]=eig(A);
A = V*diag([2;2;3*ones(m-2,1)])*V';
D = diag([5;-7;-11*ones(m-2,1)]);

% Check the eigenvalues
eig(D*A*D)


with the result

ans =

73.153
123.923
245.802
289.760
363.000
363.000
363.000
363.000
363.000
363.000
363.000
363.000
363.000
363.000
363.000
363.000
363.000
363.000
363.000
363.000


Notably, 363 = 11 * 3 * 11, which are a product of the eigenvalues $A$ and $D$ with multiplicity $m-2$. I'm aware of Sylvester's Law of Inertia as well as Ostrowski's Theorem from Horn and Johnson's book Matrix Analysis: That said, I feel like there's a stronger result here because most of the eigenvalues of $A$ and $D$ are repeated. If possible, I'd like to know the eigenvectors as well.

There is a special relationship between the eigenvalues for $DAD$ and the eigenvalues for $A$ and $D$ when many of the eigenvalues are repeated for both $A$ and $D$, but it's not because there's something deep going on. The eigenspace $U_1$ associated with the repeated eigenvalue $\lambda_1$ for $A$ may overlap with the eigenspace $U_{2}$ associated with the repeated eigenvalue $\lambda_2$ for $D$. If so, $\lambda_1\lambda_2^2$ is an eigenvalue for $DAD$ with eigenspace $U_{3} = U_1\cap U_2$.
In your example, we have $$\dim(U_1 \cap U_2) = \dim(U_1) + \dim(U_2) - \dim(U_1 + U_2) = (m-2) + (m-2) - m = m- 4,$$which is what you computed. Note that $\dim(U_1 + U_{2}) = m$ with probability 1 because the eigenvectors for $A$ were randomly generated.