Skip to content

Instantly share code, notes, and snippets.

Created May 17, 2016 21:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/6f404fc15487498e07a59521b4909894 to your computer and use it in GitHub Desktop.
Save anonymous/6f404fc15487498e07a59521b4909894 to your computer and use it in GitHub Desktop.
fpts[n_, xmin_, xmax_] := Drop[Range[xmin, xmax, (xmax - xmin)/n], -1];
fmat[n_, xmin_, xmax_, j_] :=
Block[{d, ker, x},
d = D[Cot[x/2] Sin[(n x)/2]/n /. (x ->
2 \[Pi] (x - xmin)/(xmax - xmin)), {x, j}];
ker = Join[{Limit[d, x -> xmin]},
Function[x, d // Evaluate] /@ Drop[fpts[n, xmin, xmax], 1]];
Table[RotateRight[ker, i], {i, 0, n - 1}] // Transpose];
Block[{xmin = -50, xmax = 50, n = 210, H},
H = ArrayFlatten[{{0,
DiagonalMatrix[Tanh[fpts[n, xmin, xmax]]] -
fmat[n, xmin, xmax, 1]}, {DiagonalMatrix[
Tanh[fpts[n, xmin, xmax]]] + fmat[n, xmin, xmax, 1], 0}}];
{#[[1]],
ListLinePlot[Transpose[{fpts[n, xmin, xmax], #[[2]][[1 ;; n]]}],
Axes -> False, Frame -> True, ImageSize -> Small,
PlotRange -> {-0.1, 0.1}],
ListLinePlot[Transpose[{fpts[n, xmin, xmax], #[[2]][[-n ;; -1]]}],
Axes -> False, Frame -> True, ImageSize -> Small,
PlotRange -> {-0.1, 0.1}]} & /@
Take[Transpose[Eigensystem[N[H]]], -10]]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment