# Re: 'inv' command works and 'det' returns inf for the same matrix

• From: "Arvind Iyer" <aiyer@xxxxxxxxxxx>
• Date: Thu, 16 Oct 2008 16:54:01 +0000 (UTC)

In my current application, the matrix is a covariance matrix appearing in the log likelihood function of a Gaussian process regression(GPR) model (the objective function of an optimization problem).
The expression requires me to have values of both the determinant and the inverse of the covariance matrix.

With my matrix, I can get the inverse but not the determinant (which is returned as inf)...and hence am not able to evaluate my objective function.

What is the way out to get a value of the determinant for such an application? Will some svd-based formulation help?

"Steven Lord" <slord@xxxxxxxxxxxxx> wrote in message <gd7qti\$ocs\$1@xxxxxxxxxxxxxxxxxx>...

"Arvind Iyer" <aiyer@xxxxxxxxxxx> wrote in message
news:gd7pk1\$72a\$1@xxxxxxxxxxxxxxxxxxxxx
For a 274x274 matrix, I get an inverse with finite elements when I use the
'inv' command.
However when I use the 'det' command with the same matrix, MATLAB returns
a value of inf.

What does such an output mean?

Nothing, really.

A = 2*eye(1025);
det(A)
cond(A)

A is very well conditioned, but the determinant is Inf.

n = 1e6; A = [n n;n n+1e-6];
det(A)
cond(A)

The determinant of A is a little over 1, but the matrix is very poorly
conditioned.

Is 'det' the best way to calculate matrix determinants in MATLAB? What are
other fool-proof ways using linear-algebra tricks?

What's your application? Why are you trying to compute the determinant?
There may be a way to accomplish your goal without actually computing the
determinant or using INV to compute the inverse.

--
Steve Lord
slord@xxxxxxxxxxxxx

.

## Relevant Pages

• Re: minimization problem
... that is determinant is positive, ... objective function to be minimized is. ... eigenvalues of M, if M is pos. ...
(sci.math)
• Re: minimization problem
... that is determinant is positive, ... objective function to be minimized is. ... So please confirm that minimizing ...
(sci.math)
• Re: minimization problem
... that is determinant is positive, ... actually my precise problem is ... objective function to be minimized is. ... So please confirm that minimizing ...
(sci.math)
• Mahalanobis distance & covariance matrices
... difficult to invert. ... If I calculate a covariance matrix for a raw data matrix with columns ... the determinant, I get numbers very similar to the limit of resolution ... calculating a covariance matrix when calculating Mahalanobis distance? ...
(sci.stat.math)
• Re: matrix determinant obtained as infinity
... I am getting the determinant of a covariance matrix as infinity. ... The best material model of a cat is another, or preferably the same, cat. ...
(comp.soft-sys.matlab)