The following is the code for Kronig-Penney model from the book A Physicist's Guide to Mathematica by Patrick T. Tam. I would be grateful if someone could explain the code to me, especially line with FindRoot
.
What is the role of [[1, 2]]
there?
kmPlot[l_?Positive, nb_Integer?Positive, mp_Integer /; mp > 10] :=
Module[{K, Q, d, r},
K[n_, 1] := n*Pi;
Q[n_, m_] := n*Pi - (m - 1)*Pi/(mp - 1);
K[n_, m_] :=
K[n, m] =
FindRoot[Cos[Q[n, m]] == Cos[x] + (l/2)*(Sin[x]/x), {x,K[n, m - 1]}][[1, 2]];
d[n_, m_] := K[n, m]^2;
r[n_] := r[n] = Table[{Q[n, m], d[n, m]}, {m, 1, mp}];
Graphics[
Flatten[Table[{Line[r[n]], Line[{-#[[1]], #[[2]]} & /@ r[n]]}, {n,1, nb}]],
Ticks -> {Table[{I*Pi, I "p"}, {I, -nb, nb}], Automatic},
Axes -> True, AxesLabel -> {"q(1/a)", "E"},
AspectRatio -> 1/GoldenRatio]];