I am currently trying to compare two matrices with elements which are too complicated for me to algebraically show that they are equal element wise and I decided to try the following approach:

Suppose I have two matrix functions $A(t)$ and $B(t)$ whose entries are somewhat complicated, but "nice" differentiable functions.

If I use a computer algebra system such as MATLAB and evaluate


at a thousand points between $t = [0,10]$. If the maximum of the determinant over that interval is $4*10^{-31}$, is that enough for me to be reasonably sure $A(t) = B(t)$ on $[0,10]$? I tried searching and I couldn't find examples of using the determinant as a measurement for error.

Edit: I should point out that these matrices are never upper, or lower triangular such as this:

$$A(t)= \begin{bmatrix} 0&t\\ 0&0 \end{bmatrix}, B(t) = \begin{bmatrix} 0&2t\\ 0&0 \end{bmatrix}$$ but even if they were, is there any reasonable way to fix this method without simply comparing the matrices element wise?


If $\det(M)=0$, then we can only say that $M$ is singular, but $M$ itself could be very much non-zero.

However, if the norm of the matrix $M=A-B$ is zero, then $M=0$. So perhaps look at $\mathrm{tr}(M^\top M)$, assuming that $M$ is real (otherwise use conjugate transpose).

In terms of numerical error, if you have good reason to suppose they are equal and no reason to suppose that there may be a conspiracy going on, it would be rather suggestive (assuming that you saw the same values with the norm).

  • $\begingroup$ I am not quite sure why the trace as you described would be any better. Wouldn't this be equivalent to checking if all the eigenvalues are small? $\endgroup$
    – JessicaK
    Oct 30 '14 at 6:32
  • $\begingroup$ @JessicaK, it should be looking at the sum of the square magnitude of the eigenvalues. This is zero only if all of the eigenvalues are zero. In contrast, the determinant is zero if any of the eigenvalues are zero. $\endgroup$ Oct 30 '14 at 6:37
  • $\begingroup$ @JessicaK The point is that $\mathrm{tr}(M^TM)$ is the square of a norm, in particular the Frobenius norm of $A-B$. Any suitable norm can be used to measure the distance between $A$ and $B$, see help norm in MATLAB. Determinants don't tell you anything here: consider $A=\begin{bmatrix}1 & 0 \\ 0 & 1\end{bmatrix}$ and $B=\begin{bmatrix}1 & \text{something huge} \\ 0 & 1\end{bmatrix}$. $\endgroup$ Oct 31 '14 at 11:31
  • $\begingroup$ @AlgebraicPavel It took me a little longer than I'd like to admit, but I see why norm is better now. $\endgroup$
    – JessicaK
    Nov 1 '14 at 0:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.