Eigen value of 100*100 Symbolic Matrix

5 visualizaciones (últimos 30 días)
SHUBHAM PATEL
SHUBHAM PATEL el 5 de Dic. de 2019
Comentada: Steven Lord el 23 de Sept. de 2020
I am constructing a symbolic matrix and want to get eigen values and eigen vectors. Using following code I got error.
syms E t
Na = 100;
Nb = 100;
H =zeros(Na,Nb);
H =sym(H);
% E=1;t=1;
for i = 1:Na
for j = 1:Nb
if (i==j)
H(i,j)= E;
elseif (i-j==1|| i-j==2||i-j==3 )
H(i,j)= -t;
elseif (i-j ==-1|| i-j==-2||i-j==-3 )
H(i,j)=(-t);
end
end
end
If i would have used
[V,D]=eig(H)
it was taking too long. I don't know when it's gonna stop. Why is that? Then I tried to calculate only Eigenvalue, but an error occured:
"Error using symengine
Column index out of range."
How to sort it out?

Respuesta aceptada

Shashank Gupta
Shashank Gupta el 11 de Dic. de 2019
Hi Patel,
Matrix computations which involvs many symbolic variables can be slow. In your case we have 100x100 symbolic matrix which makes the speed slower. To increase the computational speed, you can reduce the number of symbolic variables by substituting the given values for some variables. Also the “symengine error” is arising because of the similar reason, it is taking more time to evaluate the eigenvalue, you can check this by reducing the matrix size and see weather the same error arise.
I hope this helps you.
  4 comentarios
Allan Walstad
Allan Walstad el 23 de Sept. de 2020
Thanks! I feel like the sorcerer’a apprentice with the sorcerer out of town. Just trying to solve a physics problem to get energy levels. In principle I need an infinite matrix, but hoping to get by with 400x400. I thought I was just identifying all my variables with syms at the start, but apparently it’s more involved than that. So I eliminated the syms statement and 100x100 worked, then 121x121 took 23 minutes. Going up in steps, maybe 400x400 is attainable before they send me to the nursing home.
Steven Lord
Steven Lord el 23 de Sept. de 2020
I recommend that you profile the 100-by-100 case (or an even smaller case, if that takes too long in the Profiler) to identify the bottlenecks and focus on those sections that take the most time. If you're not sure how or if you can improve the performance of those sections, post them (with information about classes and sizes of the variables used in the sections) as a separate question and ask for suggestions. Generally people on Answers are more than willing to help investigate interesting problems where the poster provides enough information for them to sink their teeth into.

Iniciar sesión para comentar.

Más respuestas (0)

Community Treasure Hunt

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

Start Hunting!

Translated by