I have a set {A1, A2 .. Ak}$\{A_1, A_2, .. A_k\}$ of n$n$ by n$n$ real matrices and I know that they are 'perturbated versions' of a set of commuting matrices : {P1,..,Pk}$\{P_1,..,P_k\}$, by perturbated versions I mean that I have a bound on sum_i(norm(Ai-Pi)) leq epsilon$\sum_i\|A_i-P_i\|\leq \epsilon$. My problem is that I want to find an epsilon perturbation of {A1..Ak}$\{A_1,...,A_k\}$ so that they commute. It is clear that at least one such perturbation exists since they are perturbed versions of a commuting set. But my question is if there is any algorithm to find a permutation that makes the matrices in A$A$ commute.