Function Repository Resource:

# SignLogDet

Compute the sign and natural logarithm of the determinant of a matrix

Contributed by: Wolfram Staff
 ResourceFunction["SignLogDet"][m] gives the sign and natural logarithm of the determinant of the square matrix m.

## Details

ResourceFunction["SignLogDet"] returns a result in the form {sign,ldet}.
For a real matrix, the returned value sign is -1, 0 or 1, depending on whether the determinant is negative, zero or positive; for a complex matrix, sign is a complex number with an absolute value of 1 (i.e. it is on the unit circle) or else 0.
The returned value ldet is the natural logarithm of the absolute value of the determinant.
If the determinant is zero, then sign will be 0 and ldet will be .
The determinant can be computed as sign Exp[ldet].

## Examples

### Basic Examples (3)

Compute the sign and natural logarithm of the determinant of a matrix:

 In[1]:=
 In[2]:=
 Out[2]=

The determinant:

 In[3]:=
 Out[3]=

Or using the built-in function Det:

 In[4]:=
 Out[4]=

### Scope (6)

Compute the sign and natural logarithm of the determinant of a real-valued matrix:

 In[5]:=
 Out[5]=
 In[6]:=
 Out[6]=

Complex-valued array:

 In[7]:=
 Out[7]=

A SparseArray object:

 In[8]:=
 Out[8]=

A SymmetrizedArray object:

 In[9]:=
 Out[9]=

Use a singular matrix:

 In[10]:=
 In[11]:=
 Out[11]=

Use a large matrix:

 In[12]:=
 In[13]:=
 Out[13]=

Compute the determinant:

 In[14]:=
 Out[14]=

### Properties and Relations (4)

For real matrices, SignLogDet returns the signs as -1 or 1, depending on whether the determinant is negative or positive:

 In[15]:=
 Out[15]=

The sign is zero if the determinant is 0:

 In[16]:=
 Out[16]=
 In[17]:=
 Out[17]=

For complex matrices, the sign is a complex number with magnitude 1:

 In[18]:=
 Out[18]=
 In[19]:=
 Out[19]=

Or complex zero for singular matrices:

 In[20]:=
 Out[20]=
 In[21]:=
 Out[21]=

SignLogDet can give more accurate results than Det for small determinants:

 In[22]:=
 In[23]:=
 Out[23]=
 In[24]:=
 Out[24]=
 In[25]:=
 Out[25]=

SignLogDet may give inaccurate results with machine-precision computation:

 In[26]:=
 In[27]:=
 Out[27]=
 In[28]:=
 Out[28]=

### Possible Issues (1)

The logarithm value returned by SignLogDet may be too small to compute the determinant with machine precision:

 In[29]:=
 In[30]:=
 Out[30]=
 In[31]:=
 Out[31]=

## Version History

• 1.0.0 – 14 September 2021