How to determine the eigenvalues ​​of a matrix in a matrix when all matrix elements are variables?

I have a matrix with a number of unknown constants, such as:

a*b -c -d 0 -ce -a -bd -d -ad -e 0 -bd -ea 

As you can understand, it is diagonal symmetrical, and therefore the diagonal values ​​are all positive. All constants are greater than 0.

I would like to solve this for eigenvalues ​​in Matlab. How can I do it? I do not know the values ​​of a, b, c, d and e. I would like to do something like this:

 d = eig(@getMatrix) 

but the eig function does not accept function descriptors.

+4
source share
1 answer

No problem in MATLAB.

 >> syms abcde >> M = [a*b -c -d 0 -ce -a -bd -d -ad -e 0 -bd -ea]; >> eig(M) ans = a/4 + d/4 + e/4 + (a*b)/4 - ((51*a*d^3)/16 - (117*a^4*b)/16 + (27*a^3*d)/16 + (27*a*e^3)/16 + (57*b*d^3)/2 + (27*a^3*e)/16 + (27*d*e^3)/16 + (51*d^3*e)/16 + 6*((4*(2*b*d - (a*e)/4 - (a*d)/4 - (d*e)/4 - (a^2*b)/4 + (11*a^2)/8 + b^2 + c^2 + (19*d^2)/8 + (11*e^2)/8 + (3*a^2*b^2)/8 - (a*b*d)/4 - (a*b*e)/4)*((17*a*d^3)/64 - (39*a^4*b)/64 + (9*a^3*d)/64 + (9*a*e^3)/64 + (19*b*d^3)/8 + (9*a^3*e)/64 + (9*d*e^3)/64 + (17*d^3*e)/64 + (45*a^4)/256 + (285*d^4)/256 + (45*e^4)/256 - (a^2*b^2)/16 + (a^2*b^3)/8 + (3*a^2*b^4)/16 + (31*a^4*b^2)/128 + (a^4*b^3)/64 - (3*a^4*b^4)/256 + (3*a^2*c^2)/16 + (15*a^2*d^2)/128 - (9*a^2*e^2)/128 + (19*b^2*d^2)/16 - (b^2*e^2)/16 + (3*c^2*d^2)/16 + (15*c^2*e^2)/16 + ... (a*b*c^2*e)/8 + (3*a*b*d*e^2)/64 + (11*a*b*d^2*e)/64 + (a*b^2*d*e)/4 - (33*a^2*b*d*e)/32 - (5*a^2*b^2*d*e)/64 + (a*b*d*e)/4 + (a*c*d*e)/2 - 2*b*c*d*e) - 256*((17*a*d^3)/64 - (39*a^4*b)/64 + (9*a^3*d)/64 + (9*a*e^3)/64 + (19*b*d^3)/8 + (9*a^3*e)/64 + (9*d*e^3)/64 + (17*d^3*e)/64 + (45*a^4)/256 + (285*d^4)/256 + (45*e^4)/256 - (a^2*b^2)/16 + (a^2*b^3)/8 + (3*a^2*b^4)/16 + (31*a^4*b^2)/128 + (a^4*b^3)/64 - (3*a^4*b^4)/256 + (3*a^2*c^2)/16 + (15*a^2*d^2)/128 - (9*a^2*e^2)/128 + (19*b^2*d^2)/16 - (b^2*e^2)/16 + (3*c^2*d^2)/16 + (15*c^2*e^2)/16 + (15*d^2*e^2)/1... Output truncated. Text exceeds maximum line length of 25,000 characters for Command Window display. 

I deleted a lot there. Admittedly, this is pretty messy and lengthy, but can you really expect better?

Edit: I have to comment that such a long extended formula can be dangerous in terms of computational accuracy. I have seen people blindly use such a mess of expression, evaluating it in Fortran or MATLAB. They think that since it is "symbolic," it is also accurate. This is a complete mistake when performing numerical calculations.

In these terms, there can be a huge subtractive cancellation, while huge positive and negative expressions almost cancel each other out, leaving a tiny result that is essentially useless due to the limited dynamic range of floating point calculations. BEWARE. At the very least, compare single and double precision calculations performed with the same expression. If they differ in a significant amount, try the version with enhanced accuracy to check if there is a problem for doubles. If you have not tested such an expression and did not test it extensively, do not trust it.

+3
source

All Articles