How to get the symbolic determinant of a big matrix 13x13 size

14 Ansichten (letzte 30 Tage)
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 %%%%%%%%%

Akzeptierte Antwort

Sergey Kasyanov
Sergey Kasyanov am 17 Apr. 2021
Hello!
Try to use my function GaussElimination:
detM = prod(diag(GaussElimination(M, '')));
I test it. It works but I'm not sure that the result is correct.
Separately I test GaussElimination on random numerical data, it works fine.
  6 Kommentare
Murthy MVVS
Murthy MVVS am 17 Apr. 2021
Ok... Thank you very much. I will try with this one.
Murthy MVVS
Murthy MVVS am 17 Apr. 2021
I tried for a 8x8 matrix numerically and it worked. Checked the answer with det() function and found it correct. Later, I tried for symbolic matrix 13x13 which I had posted and that too worked 😃. I will cross-check it with some numbers tomorrow.
Thank you once again 🙏😊.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (1)

Walter Roberson
Walter Roberson am 17 Apr. 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
T =
65840947200
N = 13 %length of one term
N =
13
min_bytes = T * (N+1) %(+1) is to count addition operators
min_bytes =
921773260800
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 Kommentare
Murthy MVVS
Murthy MVVS am 17 Apr. 2021
Sure. It is just impossible to work with that size data, as it is just a small part of my work. To be frank, I really couldn’t understand how you got the multiplication for that ‘T’ and then finally got the size by multiplying with ‘N’. I just believe it and so now going for numerical formulation. In case if u have time (not forcing you), can u kindly explain how u got that number for ‘T’ and the rationale of multiplying with ‘N’. With regards 🙏.
Sergey Kasyanov
Sergey Kasyanov am 17 Apr. 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.

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu MATLAB finden Sie in Help Center und File Exchange

Produkte


Version

R2021a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by