wolfram-mathematica - 使用 mathematica 计算特征值的问题

标签 wolfram-mathematica eigenvector eigenvalue

基本上我试图找到矩阵的特征值,大约需要 12 个小时。当它完成时,它说它找不到所有的特征向量(实际上几乎没有),我对它确实找到的特征向量持怀疑态度。我真正能做的就是发布我的代码,我希望有人能给我一些建议。我对 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 设置为常量会使一切变得糟糕。

最佳答案

你的问题是常数 mS仍然是象征性的。这意味着 Mathematica 正在尝试对特征值进行解析求解,而不是数值求解。如果您的问题允许您为 mS 选择一个数值你应该这样做。

您遇到的另一个不相关的问题是您正在使用递归公式,并且您想使用,例如,在下一行中的内存

v[n_, m_] := v[n, m] = v[n - 1, m - 1]*(m/(m - 1)) 
                     + (8 m/(n + m - 1))*((1 + (-1)^(n + m))/2);

额外的 v[n, m] =存储给定 n 的值和 m所以你不必一直递归到 v[0,0]每次h[n, m]Table[] 中被调用.

处理好这两件事后,我的旧核心 2 二人组只需不到一分钟的时间来计算特征值。

关于wolfram-mathematica - 使用 mathematica 计算特征值的问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6510946/

相关文章:

python - 使用 sklearn 和大亲和性矩阵进行谱聚类

python - 需要在pyspark中通过类似于scipy.linalg.eig的特征值分解来找到非对称方阵的特征向量

r - 矩阵计算 R 与 Stata 的精度

numpy - 计算 scipy LinearOperator : "gmres did not converge" 的特征值时出错

algorithm - 一种计算 n*n 矩阵 : 行列式的数学算法

wolfram-mathematica - 如何 DumpSave 函数?

wolfram-mathematica - 阅读已定义函数的代码(尤其是从 System` 上下文中)的最佳方法是什么?

wolfram-mathematica - 为什么 Extract 会在结果中添加额外的 {} 以及删除它们的最佳方法

computer-vision - 特征脸是从什么生成的?

python - SymPy 无法计算此矩阵的特征值