det(x)
9 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
milad
il 18 Ago 2015
Commentato: David Goodmanson
il 4 Gen 2022
hello dear friends I have a problem with "det(x)". I have tried to descritize an equation with one symbolic variable(A=descritized equation in matrix form contains a symbolic variable and the size of the matrix is 32*32). after descritizing the equation during a process in matlab program , I want to use "det(A)" but the answer is too long and infinity and its not true. but when I bring the matrix "A" to a new separately m-file and I use "det(A)", the answer is true. that is because of the difference value of "det(A)" in the two approaches. since I want to find a lot of answers for different variables, the automatic process is needed absolutely. what is the problem? what should I do to solve the problem? thank you
0 Commenti
Risposta accettata
Star Strider
il 19 Ago 2015
I’m guessing here, but it seems that you may be doing a Cramer’s rule solution to a linear system (or less likely, a linear regression). MATLAB makes this relatively straightforward, so there is no need for you to specifically calculate the determinant.
0 Commenti
Più risposte (2)
John D'Errico
il 19 Ago 2015
Sorry, but how often do I need to say this? DON'T USE DET! It is poorly conditioned in terms of numerics. It is terribly slowly computed when done symbolically. It is virtually useless for anything but basic homework assignments, where students are taught to use an obscenely bad tool for no good reason. Of course, then some of those students go on to write books, teach courses, advise their own students, etc. And of course, they give the wrong advice.
So let me say it three times more. If I say it thrice, it must be true. DON'T USE DET! DON'T USE DET! DON'T USE DET!
Now, you don't say why it is that you THINK you need to use det here. Only that you need it. But the fact is, too often, posters here only THINK they need something. And when somebody tells a story as you have, it is clear that you don't know a lot about numerical analysis, so this makes it very likely that in fact, there are other, far better ways to solve your problem. But we cannot help you, since you have given no useful information in this matter.
6 Commenti
Minati Mishra
il 29 Dic 2021
any function other than det() to find the determinant of matrix ? det() is not always giving the correct result!
David Goodmanson
il 4 Gen 2022
Hi Minati,
there is always prod(eig(A)), but if det(A) is bad, the chance that the eig expression is good is not good.
Minati Mishra
il 29 Dic 2021
det([1,2;3 6]) should be 0 but it is giving non-zero value. and this is happening with many more such matrices!
2 Commenti
Christine Tobler
il 3 Gen 2022
det doesn't have a special branch for 2-by-2 or 3-by-3 matrices, it always uses the same algorithm no matter the matrix size, which has round-off on the level of machine epsilon. To get a computation with zero round-off error, you can use the symbolic toolbox (det(sym([1 2; 3 6]))). When using numeric computation as MATLAB does outside of the symbolic toolbox, using the determinant is discouraged for the reasons John d'Errico explains in the above post: The output of det can only be used as a true/false of "is it exactly zero", and in numeric computations it's nearly always impossible to reliably get an exact zero.
In numeric computations, it's advisable to instead use the condition number, or to directly compute eigenvalues / solve linear systems, which all have reliable numeric algorithms behind them.
Vedere anche
Categorie
Scopri di più su Linear Algebra in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!