3

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

$$\det(A(t)-B(t))$$

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?

JessicaK
  • 7,655

1 Answers1

3

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).

Joel Bosveld
  • 728
  • 5
  • 10
  • 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? – JessicaK Oct 30 '14 at 06:32
  • @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. – Joel Bosveld Oct 30 '14 at 06:37
  • @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}$. – Algebraic Pavel Oct 31 '14 at 11:31
  • @AlgebraicPavel It took me a little longer than I'd like to admit, but I see why norm is better now. – JessicaK Nov 01 '14 at 00:36