0
$\begingroup$

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]
$\endgroup$
2
  • 2
    $\begingroup$ Don't use Subscript's! MatrixForm is only a displayoption, makes no sense in the definition of H $\endgroup$ Commented Sep 10, 2021 at 6:48
  • 1
    $\begingroup$ If you would like to see matrix, can write (H=Table[...])//MatrixForm $\endgroup$
    – yarchik
    Commented Sep 10, 2021 at 7:54

1 Answer 1

5
$\begingroup$

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] 
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.