基本上我試圖找到矩陣的特徵值,大約需要12個小時。當它結束時,它說它找不到所有的特徵向量(實際上幾乎沒有),我對它找到的那些特徵向量持懷疑態度。我所能做的只是發佈我的代碼,我希望有人能夠向我提出一些建議。我對mathematica並不是很有經驗,也許運行時間很慢,不好的結果與我有關,而不是mathematica的能力。感謝任何回覆的人,我真的很感激。使用mathematica計算特徵值的問題
cutoff = 500; (* set a cutoff for the infinite series *)
numStates = cutoff + 1; (* set the number of excited states to be printed *)
If[numStates > 10, numStates = 10];
$RecursionLimit = cutoff + 256; (* Increase the recursion limit to allow for the specified cutoff *)
(* set the mass of the constituent quarks *)
m1 := mS; (* just supposed to be a constant *)
m2 := 0;
(* construct the hamiltonian *)
h0[n_,m_] := 4 Min[n,m] * ((-1)^(n+m) * m1^2 + m2^2);
v[0,m_] := 0;
v[n_,0] := 0;
v[n_,1] := (8/n) * ((1 + (-1)^(n + 1))/2);
v[n_,m_] := v[n - 1, m - 1] * (m/(m - 1)) + (8 m/(n + m - 1))*((1 + (-1)^(n + m))/2);
h[n_,m_] := h0[n,m] + v[n,m];
(* construct the matrix from the hamiltonian *)
mat = Table[h[n,m], {n, 0, cutoff}, {m, 0, cutoff}] // FullSimplify;
(* find the eigenvalues and eigenvectors, then reverse the order *)
PrintTemporary["Finding the eigenvalues"];
{vals, vecs} = Eigensystem[N[mat]] // FullSimplify;
$RecursionLimit = 256; (* Put the recursion limit back to the default *)
還有一點我的代碼,但這是真正放緩的點。我應該提到的一件事是,如果我將m1和m2設置爲零,我沒有任何問題,但將m1設置爲常數會使所有事情都陷入困境。
它可能是值得指出的是時間的顯著塊都花在構建矩陣了(即使有記憶化作爲蒂莫建議)。'RSolve'爲'v'的遞歸定義提供了一個明確的形式,雖然修改未確定的函數(通過初始條件)可能會因分支切割等原因而變得複雜。在任何情況下,如果您進一步擴展它,這可能是看着。 – acl