roots: Factor expression before using roots_quadratic()

Example:

In [1]: var('a')
Out[1]: a

In [2]: M = Matrix([[a, 0], [0, 1]])

In [3]: M.eigenvals()
Out[3]: {1: 1, a: 1}

Before it gave {a/2 + sqrt((a - 1)**2)/2 + 1/2: 1,
                a/2 - sqrt((a - 1)**2)/2 + 1/2: 1}
keep quadratic processing if there is only one factor
Merge pull request #8388 from smichr/quad

factor before using roots quadratic (replaces #2520)