Consider a $n\times n$ matrix $A$ whose elements are some polynomials in the indeterminates $x_1, x_2,\ldots,x_m$. To calculate the determinant of such a matrix, one of the usual ways is to treat the determinant as a polynomial in $x_1,\ldots,x_m$ and identify its factors. The usual idea being if $x = y$ makes the determinant vanish then $x -y$ is one of the factors. What I however do not understand is how to identify its order, that is to identify the exact $k$ such that $(x - y)^k$ is the factor.
For example, consider the matrix
$ \left( \begin{array}{ccc} (x + a_1)^2 & (x + a_1)*(y + a_1) & (y + a_1) \\ (x + a_2)^2 & (x + a_2)*(y + a_2) & (y + a_2) \\ (x + a_3)^2 & (x + a_1)*(y + a_3) & (y + a_3) \\ \end{array} \right) $. The determinant of this matrix is given by $(x - y)^2 * (a_1 - a_2) * (a_1 - a_3) * (a_2 - a_3). $ I want to know how to guess the order $2$ of $x-y$.