Matrix determinant - MATLAB det (2024)

Matrix determinant

collapse all in page

Syntax

d = det(A)

Description

example

d = det(A) returns the determinant of square matrix A.

Examples

collapse all

Calculate Determinant of Matrix

Open Live Script

Create a 3-by-3 square matrix, A.

A = [1 -2 4; -5 2 0; 1 0 3]
A = 3×3 1 -2 4 -5 2 0 1 0 3

Calculate the determinant of A.

d = -32

Determine if Matrix Is Singular

Open Live Script

Examine why the determinant is not an accurate measure of singularity.

Create a 10-by-10 matrix by multiplying an identity matrix, eye(10), by a small number.

A = eye(10)*0.0001;

The matrix A has very small entries along the main diagonal. However, A is not singular, because it is a multiple of the identity matrix.

Calculate the determinant of A.

d = det(A)
d = 1.0000e-40

The determinant is extremely small. A tolerance test of the form abs(det(A)) < tol is likely to flag this matrix as singular. Although the determinant of the matrix is close to zero, A is actually not ill conditioned. Therefore, A is not close to being singular. The determinant of a matrix can be arbitrarily close to zero without conveying information about singularity.

To investigate if A is singular, use either the cond or rcond functions.

Calculate the condition number of A.

c = cond(A)
c = 1

The result confirms that A is not ill conditioned.

Find Determinant of Singular Matrix

Open Live Script

Examine a matrix that is exactly singular, but which has a large nonzero determinant. In theory, the determinant of any singular matrix is zero, but because of the nature of floating-point computation, this ideal is not always achievable.

Create a 17-by-17 diagonally dominant singular matrix A and view the pattern of nonzero elements.

A = diag([36 54 24 46 64 78 88 94 96 94 88 78 64 46 24 54 36]);S = diag([-27 -12 -13 -24 -33 -40 -45 -48 -49 -48 -45 -40 -33 -12 -27 -36],1);A = A + S + rot90(S,2);spy(A)

Matrix determinant - MATLAB det (1)

A is singular because the rows are linearly dependent. For instance, sum(A) produces a vector of zeros.

Calculate the determinant of A.

d = det(A)
d = 2.6698e+10

The determinant of A is quite large despite the fact that A is singular. In fact, the determinant of A should be exactly zero! The inaccuracy of d is due to an aggregation of round-off errors in the MATLAB® implementation of the LU decomposition, which det uses to calculate the determinant. This result demonstrates a few important aspects of calculating numeric determinants. See the Limitations section for more details.

Input Arguments

collapse all

AInput matrix
square numeric matrix

Input matrix, specified as a square numeric matrix.

Data Types: single | double
Complex Number Support: Yes

Limitations

Avoid using det to examine if a matrix issingular because of the following limitations. Use cond or rcond instead.

LimitationResult

The magnitude of the determinant is typically unrelatedto the condition number of a matrix.

The determinant of a matrix can be arbitrarily largeor small without changing the condition number.

det uses the LU decomposition to calculatethe determinant, which is susceptible to floating-point round-offerrors.

The determinant calculation is sometimes numericallyunstable. For example, det can produce a large-magnitudedeterminant for a singular matrix, even though it should have a magnitudeof 0.

Algorithms

det computes the determinant from the triangularfactors obtained by Gaussian elimination with the lu function.

[L,U] = lu(X)s = det(L) % This is always +1 or -1 det(X) = s*prod(diag(U))

Extended Capabilities

This function fully supports GPU arrays. For more information, see Run MATLAB Functions on a GPU (Parallel Computing Toolbox).

Version History

Introduced before R2006a

See Also

cond | rcond | condest | inv | lu | rref | mldivide

MATLAB Command

You clicked a link that corresponds to this MATLAB command:

 

Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.

Matrix determinant - MATLAB det (2)

Select a Web Site

Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .

You can also select a web site from the following list:

Americas

  • América Latina (Español)
  • Canada (English)
  • United States (English)

Europe

  • Belgium (English)
  • Denmark (English)
  • Deutschland (Deutsch)
  • España (Español)
  • Finland (English)
  • France (Français)
  • Ireland (English)
  • Italia (Italiano)
  • Luxembourg (English)
  • Netherlands (English)
  • Norway (English)
  • Österreich (Deutsch)
  • Portugal (English)
  • Sweden (English)
  • Switzerland
    • Deutsch
    • English
    • Français
  • United Kingdom (English)

Asia Pacific

Contact your local office

Matrix determinant - MATLAB det (2024)

FAQs

How to determine the determinant of a matrix in Matlab? ›

B = det( A ) returns the determinant of the square matrix of symbolic numbers, scalar variables, or functions A . B = det( A ,'Algorithm','minor-expansion') uses the minor expansion algorithm to evaluate the determinant of A .

What is the answer to the determinant of a matrix? ›

To find this determinant, first get the minors of each element in the second column. Now find the cofactor of each of these minors. The determinant is found by multiplying each cofactor by its corresponding element in the matrix and finding the sum of these products.

What does the determinant of a matrix tell you about solutions? ›

The determinant tells whether a linear system of equations has solutions or not. Remember the three cases; unique solution, infinitely many solutions or no solutions. If the determinant is zero, the system has "infinitely many solutions" or "no solutions".

How to use det function in MATLAB? ›

Go to function:

d = det(X) returns the determinant of the square matrix X . If X contains only integer entries, the result d is also an integer.

How do I evaluate the determinant of a matrix? ›

To evaluate the determinant of a 3 × 3 matrix we choose any row or column of the matrix - this will contain three elements. We then find three products by multiplying each element in the row or column we have chosen by its cofactor. Finally, we sum these three products to find the value of the determinant.

How do you find the determinant of a matrix quickly? ›

Finding the determinant of a matrix in row echelon form is really easy; you just find the product of the diagonal. Solving the determinant of the original matrix A then just boils down to calculating α as you find the row echelon form R.

Can the determinant of a 3x3 matrix be 0? ›

When the determinant of a 3 × 3 matrix is zero: The rows and columns are linearly dependent vectors. The matrix is not invertible. The system of linear equations is linearly dependent.

How do you interpret a matrix determinant? ›

The determinant of a 2X2 matrix tells us what the area of the image of a unit square would be under the matrix transformation. This, in turn, allows us to tell what the area of the image of any figure would be under the transformation.

Why is it important to know the determinant of a matrix? ›

Determinants basically help to describe the nature of solutions of linear equations. The determinant of a real matrix is just some real number, telling you about the invertibility of the matrix and hence telling you things about linear equations wrapped up in the matrix.

What if the determinant is 0? ›

A determinant equal to zero means that a matrix is a singular matrix. A matrix is singular if it does not have an inverse, which means it cannot be used to solve systems of linear equations.

What is the formula for the determinant of a matrix? ›

The determinant is: |A| = a (ei − fh) − b (di − fg) + c (dh − eg). The determinant of A equals 'a times e x i minus f x h minus b times d x i minus f x g plus c times d x h minus e x g'. It may look complicated, but if you carefully observe the pattern its really easy!

How do I find the determinant of a 2x2 matrix? ›

The determinant of a 2x2 matrix A = ⎡⎢⎣abcd⎤⎥⎦ [ a b c d ] is |A| = ad - bc. It is simply obtained by cross multiplying the elements starting from top left and then subtracting the products.

How do you find the identity of a matrix in MATLAB? ›

I = eye( n ) returns an n -by- n identity matrix with ones on the main diagonal and zeros elsewhere. I = eye( n , m ) returns an n -by- m matrix with ones on the main diagonal and zeros elsewhere.

Top Articles
Latest Posts
Article information

Author: Edmund Hettinger DC

Last Updated:

Views: 6066

Rating: 4.8 / 5 (58 voted)

Reviews: 89% of readers found this page helpful

Author information

Name: Edmund Hettinger DC

Birthday: 1994-08-17

Address: 2033 Gerhold Pine, Port Jocelyn, VA 12101-5654

Phone: +8524399971620

Job: Central Manufacturing Supervisor

Hobby: Jogging, Metalworking, Tai chi, Shopping, Puzzles, Rock climbing, Crocheting

Introduction: My name is Edmund Hettinger DC, I am a adventurous, colorful, gifted, determined, precious, open, colorful person who loves writing and wants to share my knowledge and understanding with you.