Computing matrix eigenvalues and polynomial zeros where the output is real