How to get the symbolic determinant of a big matrix 13x13 size
13 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Murthy MVVS
le 17 Avr 2021
Commenté : Murthy MVVS
le 17 Avr 2021
I have a 13 x 13 matrix given as M. I am using Matlab 2021a.
If I use the matlab 'det' as detM = det(M)
I am getting error as,
detM =
Warning: Unable to display symbolic object because 'symengine' was reset. Repeat commands to regenerate
result.
> In sym/disp (line 44)
In sym/display>displayVariable (line 89)
In sym/display (line 51)
In det_m (line 37)
The matlab script file is,
%%%%%%%%% det_m.m %%%%%%%%%
clear all;
clc;
syms a1 a3 a7 a9 a10 a11;
syms b2 b3 b8 b12 b13;
syms c1 c3 c4 c7 c9 c10 c11;
syms d4 d6 d7 d9 d10 d11;
syms e5 e6 e8 e12 e13;
syms f4 f6 f7 f9 f10 f11;
syms g1 g3 g4 g6 g7 g9 g10 g11 g12;
syms h2 h5 h8 h9 h11 h12 h13;
syms i1 i3 i4 i6 i7 i8 i9 i10 i11 i13;
syms j1 j3 j4 j6 j7 j8 j9 j10 j11 j13;
syms k1 k3 k4 k6 k7 k8 k9 k10 k11 k13;
syms l2 l5 l7 l8 l10 l12 l13;
syms m2 m5 m8 m9 m11 m12 m13;
M = [
[ a1, 0, a3, 0, 0, 0, a7, 0, a9, a10, a11, 0, 0]
[ 0, b2, b3, 0, 0, 0, 0, b8, 0, 0, 0, b12, b13]
[ c1, 0, c3, 0, 0, 0, c7, 0, c9, c10, c11, 0, 0]
[ 0, 0, 0, d4, 0, d6, d7, 0, d9, d10, d11, 0, 0]
[ 0, 0, 0, 0, e5, e6, 0, e8, 0, 0, 0, e12, e13]
[ 0, 0, 0, f4, 0, f6, f7, 0, f9, f10, f11, 0, 0]
[ g1, 0, g3, g4, 0, g6, g7, 0, g9, g10, g11, g12, 0]
[ 0, h2, 0, 0, h5, 0, 0, h8, h9, 0, h11, h12, h13]
[ i1, 0, i3, i4, 0, i6, i7, i8, i9, i10, i11, 0, i13]
[ j1, 0, j3, j4, 0, j6, j7, j8, j9, j10, j11, 0, j13]
[ k1, 0, k3, k4, 0, k6, k7, k8, k9, k10, k11, 0, k13]
[ 0, l2, 0, 0, l5, 0, l7, l8, 0, l10, 0, l12, l13]
[ 0, m2, 0, 0, m5, 0, 0, m8, m9, 0, m11, m12, m13]
]
detM = det(M)
%%%%%%%%% End det_m.m %%%%%%%%%
0 commentaires
Réponse acceptée
Sergey Kasyanov
le 17 Avr 2021
Hello!
detM = prod(diag(GaussElimination(M, '')));
I test it. It works but I'm not sure that the result is correct.
6 commentaires
Plus de réponses (1)
Walter Roberson
le 17 Avr 2021
If my calculation is correct, that determinant has
format long g
T = 6*3*7*6*4*7*9*8*10*9*10*6*8 %number of terms
N = 13 %length of one term
min_bytes = T * (N+1) %(+1) is to count addition operators
So if MATLAB was able to code each variable as 1 byte, it would require just under a 1 terabyte. That would be theoretically possible as there are fewer than 254 different variables. However, that does not reflect how MATLAB actually stores variables, which requires at least 8 bytes per reference (pointers), so you should expect more than 8 terabytes.
You are running out of memory. And there is no realistic chance that you could fit anything even remotely close to that task.
6 commentaires
Sergey Kasyanov
le 17 Avr 2021
@Walter Roberson I have been calculated bigger symbolic matrices. I agree with you that complexity of calculation grow very very fast with matrix size but each zero in matrix reduce it greatly and It is very difficult to say what time or memory needs to solve the problem.
Voir également
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!