# How to write the equation into matrix form [closed]

$$[(a+k_i)^2+(b+k_j)^2]X_{i,j}-\sum_{m,n}V_{m,n}X_{i-m,j-n}=\mu X_{i,j}$$. where $$-N\le i,j\le N$$ Here we can set $$N=10,a =1, b=1$$ and $$V_{m,n}$$ is the matrix element of $$V$$. Once I write the coefficient matrix of $$X$$, I can solve the eigenvalue $$\mu$$.

• A matrix is a list of lists. For example if $A=\begin{pmatrix} 1 & 2 \\ 3 & 4 \end{pmatrix}$, we would write this in Mathematica as A={{1,2},{3,4}}. Is this what you are asking? – mjw Mar 25 '19 at 6:15
• What are the bounds of the summation \sum_{m,n}? – Henrik Schumacher Mar 25 '19 at 7:19

$$X$$ is a $$N\times N$$ matrix, which I'll Flatten into a vector of length $$N^2$$. The coefficient array is a $$N\times N\times N\times N$$ tensor, which I'll ArrayFlatten into a $$N^2\times N^2$$ matrix.

I'll use M=$$N$$ because the symbol N is already in use in Mathematica. The coefficient array is W. Here I'll use M=3 for brevity.

M = 3;
X = Flatten[Array[Subscript[x, ##] &, {M, M}]];
W = ArrayFlatten[SparseArray[{i_,i_,j_,j_} ->
(a+Subscript[k,i])^2 + (b+Subscript[k,j])^2, {M,M,M,M}] -
SparseArray[{i1_,i2_,j1_,j2_} ->
Subscript[V,i1-i2,j1-j2], {M,M,M,M}]];


Note that the second component of W is not sparse, and can be written as

Array[Subscript[V, #1-#2, #3-#4] &, {M, M, M, M}]


which may be more efficient, but harder on the eye.

Check that this gives the desired eigenvalue equations:

Thread[W.X == μ X]


$$\{((a+k_1){}^2+(b+k_1){}^2-V_{0,0}) x_{1,1}-V_{0,-1} x_{1,2}-V_{0,-2} x_{1,3}-V_{-1,0} x_{2,1}-V_{-1,-1} x_{2,2}-V_{-1,-2} x_{2,3}-V_{-2,0} x_{3,1}-V_{-2,-1} x_{3,2}-V_{-2,-2} x_{3,3}=\mu x_{1,1},\\ -V_{0,1} x_{1,1}+((a+k_1){}^2+(b+k_2){}^2-V_{0,0}) x_{1,2}-V_{0,-1}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-V_{2,0} x_{1,2}-V_{2,-1} x_{1,3}-V_{1,1} x_{2,1}-V_{1,0} x_{2,2}-V_{1,-1} x_{2,3}-V_{0,1} x_{3,1}+((b+k_2){}^2+(a+k_3){}^2-V_{0,0}) x_{3,2}-V_{0,-1} x_{3,3}=\mu x_{3,2},\\ -V_{2,2} x_{1,1}-V_{2,1} x_{1,2}-V_{2,0} x_{1,3}-V_{1,2} x_{2,1}-V_{1,1} x_{2,2}-V_{1,0} x_{2,3}-V_{0,2} x_{3,1}-V_{0,1} x_{3,2}+((a+k_3){}^2+(b+k_3){}^2-V_{0,0}) x_{3,3}=\mu x_{3,3}\}$$

Find the eigenvalues:

Eigenvalues[W]


You'll probably have to insert numerical values into W before calculating the eigenvalues, otherwise the code will be too slow.

• It is a little perverse to use SparseArray[] to generate what is actually a dense matrix. In any event: ArrayFlatten[Table[If[i1 == i2 && j1 == j2, ((a + Subscript[k, i1])^2 + (b + Subscript[k, j1])^2), 0] - Subscript[V, i1 - i2, j1 - j2], {i1, M}, {i2, M}, {j1, M}, {j2, M}]] – J. M.'s technical difficulties Mar 25 '19 at 9:14
• Yes I just commented on that. I tend to prefer SparseArray because it's easy to debug, and once it works I try to find more efficient forms. – Roman Mar 25 '19 at 9:16
• thank， I will understand it now – yun shi Mar 26 '19 at 2:39
• This code looks perfect, but it may be a little abstract. Maybe I can't understand and imagine the mathematical form. Because for one subscript, I can write the matrix by hand and to observe the form. But for two subscript, the matrix is very large even for $N=3$, the matrix is $9\times 9$. My question is : Can you give me some detailed examples which involved the later case. Thanks a lot! – yun shi Mar 26 '19 at 4:35
• I don't know what you mean by "detailed examples", other than the 9 equations I already gave explicitly for the case M=3. Can you please formulate your question more concretely? – Roman Mar 26 '19 at 6:56