---
title: "Determinant and Other Properties"
canonical: "https://docs.magma-maths.org/v2.30-1/MatricesLinearAlgebra/Matrices/properties.html"
source: "https://docs.magma-maths.org/v2.30-1/MatricesLinearAlgebra/Matrices/properties.md"
part: "Matrices and Linear Algebra"
chapter: "Matrices"
breadcrumbs:
  - {"title": "Magma Handbook", "source": "https://docs.magma-maths.org/v2.30-1/index.md"}
  - {"title": "Matrices and Linear Algebra", "source": "https://docs.magma-maths.org/v2.30-1/MatricesLinearAlgebra/index-matrices-linear-algebra.md"}
  - {"title": "Matrices", "source": "https://docs.magma-maths.org/v2.30-1/MatricesLinearAlgebra/Matrices/index-matrices.md"}
prev: {"title": "Predicates", "source": "https://docs.magma-maths.org/v2.30-1/MatricesLinearAlgebra/Matrices/predicates.md"}
next: {"title": "Minimal and Characteristic Polynomials and Eigenvalues", "source": "https://docs.magma-maths.org/v2.30-1/MatricesLinearAlgebra/Matrices/properties-2.md"}
intrinsics:
  - {"name": "Determinant", "signature": "Determinant(A: parameters): Mtrx -> RngElt"}
  - {"name": "Trace", "signature": "Trace(A): Mtrx -> RngElt"}
  - {"name": "TraceOfProduct", "signature": "TraceOfProduct(A, B): Mtrx, Mtrx -> RngElt"}
  - {"name": "Rank", "signature": "Rank(A): Mtrx -> RngIntElt"}
  - {"name": "Minor", "signature": "Minor(M, i, j): Mtrx, RngIntElt, RngIntElt -> RngElt"}
  - {"name": "Minor", "signature": "Minor(M, I, J): Mtrx, [RngIntElt], [RngIntElt] -> RngElt"}
  - {"name": "Minors", "signature": "Minors(M, r): Mtrx, RngIntElt -> SeqEnum"}
  - {"name": "Cofactor", "signature": "Cofactor(M, i, j): Mtrx, RngIntElt, RngIntElt -> RngElt"}
  - {"name": "Cofactors", "signature": "Cofactors(M): Mtrx -> SeqEnum"}
  - {"name": "Cofactors", "signature": "Cofactors(M, r): Mtrx, RngIntElt -> SeqEnum"}
  - {"name": "Pfaffian", "signature": "Pfaffian(M): Mtrx -> RngElt"}
  - {"name": "Pfaffian", "signature": "Pfaffian(M, I, J): Mtrx, [RngIntElt], [RngIntElt] -> RngElt"}
  - {"name": "Pfaffians", "signature": "Pfaffians(M, r): Mtrx, RngIntElt -> SeqEnum"}
---

# Determinant and Other Properties

<a id="function-determinant-mtrx"></a>
## `Determinant(A: parameters): Mtrx -> RngElt`

```magma
MonteCarloLevel: RngIntElt                    Default: 0
Proof          : BoolElt                      Default: true
pAdic          : BoolElt                      Default: true
Divisor        : RngIntElt                    Default: 0
```

Given a square matrix $A$ over the ring $R$, return the determinant of $A$ as an element of $R$. $R$ may be any commutative ring. The determinant of the $0 \times 0$ matrix over $R$ is defined to be `R!1`. If the coefficient ring is the integer ring ${\mathbb{Z}}$ or the rational field ${\mathbb{Q}}$ then a modular algorithm based on that of Abbott et al. [[ABM99](https://docs.magma-maths.org/v2.30-1/references.md#cite-abm-det)] is used, which first computes a divisor $d$ of the determinant $D$ using a fast $p$-adic nullspace computation, and then computes the quotient $D/d$ by computing the determinant $D$ modulo enough small primes to cover the Hadamard bound divided by $d$. This always yields a correct answer. If the parameter `MonteCarloLevel` is set to a small positive integer $s$, then a probabilistic Monte-Carlo modular technique is used. Rather than using sufficient primes to cover the Hadamard bound divided by the divisor $d$, this version of the algorithm terminates when the constructed residue remains constant for $s$ steps. The probability of this being wrong is non-zero but extremely small, even if $s$ is only 1 or 2. If the level is set to 0, then the normal deterministic algorithm is used. Setting the parameter `Proof` to `false` is equivalent to setting `MonteCarloLevel` to 2. If the coefficient ring is ${\mathbb{Z}}$ and the parameter `Divisor` is set to an integer $d$, then $d$ must be a known exact divisor of the determinant (the sign does not matter), and the algorithm may be sped up because of this knowledge.

<a id="function-trace-mtrx"></a>
## `Trace(A): Mtrx -> RngElt`

Given a square matrix $A$ over the ring $R$, return the trace of $A$ as an element of $R$, which is simply the sum of the diagonal elements of $A$.

<a id="function-traceofproduct-mtrx-mtrx"></a>
## `TraceOfProduct(A, B): Mtrx, Mtrx -> RngElt`

Given square matrices $A$ and $B$ over the ring $R$, with the same size, return the trace of $A\cdot B$ as an element of $R$. This is in general much faster than the call `Trace(A*B)`.

<a id="function-rank-mtrx"></a>
## `Rank(A): Mtrx -> RngIntElt`

Given an $m \times n$ matrix $A$ over a ring $R$, return the rank of $A$. This is defined to be the largest $r$ such that there exists a non-zero $r \times r$ subdeterminant of $A$, so $r\leq m$ and $r \leq n$. The rank may have to be obtained by computing the Smith form or echelon form of $A$, and this computation may be quite expensive over some rings.

<a id="function-minor-mtrx-rngintelt-rngintelt"></a>
## `Minor(M, i, j): Mtrx, RngIntElt, RngIntElt -> RngElt`

The determinant of the submatrix of $M$ (which must be square) formed by removing the $i$-th row and $j$-th column.

<a id="function-minor-mtrx-rngintelt-rngintelt-2"></a>
## `Minor(M, I, J): Mtrx, [RngIntElt], [RngIntElt] -> RngElt`

The determinant of the submatrix of $M$ given by the row indices in $I$ and the column indices in $J$.

<a id="function-minors-mtrx-rngintelt"></a>
## `Minors(M, r): Mtrx, RngIntElt -> SeqEnum`

Returns a sequence of all the $r$ by $r$ minors of the matrix $M$.

<a id="function-cofactor-mtrx-rngintelt-rngintelt"></a>
## `Cofactor(M, i, j): Mtrx, RngIntElt, RngIntElt -> RngElt`

The appropriate cofactor of $M$, equal to $(-1)^{i+j}$ times the corresponding minor.

<a id="function-cofactors-mtrx"></a>
## `Cofactors(M): Mtrx -> SeqEnum`

Returns a sequence of all the cofactors of the matrix $M$.

<a id="function-cofactors-mtrx-rngintelt"></a>
## `Cofactors(M, r): Mtrx, RngIntElt -> SeqEnum`

Returns a sequence of all the $r$ by $r$ cofactors of the matrix $M$.

<a id="function-pfaffian-mtrx"></a>
## `Pfaffian(M): Mtrx -> RngElt`

<a id="function-pfaffian-mtrx-rngintelt-rngintelt"></a>
## `Pfaffian(M, I, J): Mtrx, [RngIntElt], [RngIntElt] -> RngElt`

<a id="function-pfaffians-mtrx-rngintelt"></a>
## `Pfaffians(M, r): Mtrx, RngIntElt -> SeqEnum`

Let $M$ be an anti-symmetric square matrix. Then its determinant is always a square and a particular square-root of this, which can be described by a universal polynomial in its entries, is called the Pfaffian of $M$. The first function returns this. The second function returns the Pfaffian of the submatrix of $M$ described by the indices in $I$ and $J$. The third function returns the sequence of Pfaffians of the ${n \choose r}$ principal $r$ by $r$ submatrices of $M$ ($n=$ the number of rows of $M$).

These are primarily convenience functions and are computed naively by Pfaffian row-expansion.
