# Construct a matrix from its elements and solve the eigenvalue problem

I want to construct a 10 by 10 matrix whose elements are given by

$$H_{nm}=\delta_{nm}\left (n^2+v[b_1-b_0-h(2m,b_0,b_1)]\right) \\ +v(1-\delta_{nm})\left (h(n-m,b_0,b_1)-h(n+m,b_0,b_1)\right)$$

where

$$h(n,b_0,b_1)=g(n,b_1)-g(n,b_0), \quad n=1,...,10, \quad m=1,...,10,$$

and

$$g(n,b)=\frac{\sin{(n\pi b)}}{n\pi}.$$

Here, we let $$v=800, \quad b_0=0.5, \quad b_1=1$$.

My code is as below and problem seems to be that n and m are two arrays instead numbers as arguments of function h. I am new to matrix manipulation and I hope someone can give me some help! Thanks!

v = 800;
Subscript[b, 0] = 0.5;
Subscript[b, 1] = 1;
n = Range[1, 10, 1];
m = Range[1, 10, 1];

h[n, Subscript[b, 0], Subscript[b, 1]] =
Sin[n*\[Pi]*Subscript[b, 1]]/(n*\[Pi]) -
Sin[n*\[Pi]*Subscript[b, 0]]/(n*\[Pi]);

H[ [n, m] ] =
KroneckerDelta[n,
m]*(n^2 +
v*(Subscript[b, 1] - Subscript[b, 0] -
h[2 m, Subscript[b, 0], Subscript[b, 1]])) +
v*(1 - KroneckerDelta[n, m])*(h[n - m, Subscript[b, 0], Subscript[
b, 1]] - h[n + m, Subscript[b, 0], Subscript[b, 1]]);

H = Table[Subscript[H, nm], {n, 10}, {m, 10}] // MatrixForm;

Eigensystem[H]

• Don't use Subscript's! MatrixForm is only a displayoption, makes no sense in the definition of H Sep 10 at 6:48
• If you would like to see matrix, can write (H=Table[...])//MatrixForm Sep 10 at 7:54

Here a version which doesn't uses Subscript' s:

v = 800;
b[0] = 0.5;
b[1] = 1;

g[n_, b_] := b Sinc[n Pi b] ;
h[n_, b0_, b1_] := g[n, b1] - g[n, b0]

H = Table[
KroneckerDelta[n, m] (n^2 + v*(b[1] - b[0] - h[2 m, b[0], b[1]])) +
v*(1 - KroneckerDelta[n, m])*(h[n - m, b[0], b[1]] -h[n + m, b[0], b[1]])
, {n, 1, 10}, {m, 1, 10}];

Eigensystem[H]