(* Content-type: application/vnd.wolfram.mathematica *) (*** Wolfram Notebook File ***) (* http://www.wolfram.com/nb *) (* CreatedBy='Mathematica 9.0' *) (*CacheID: 234*) (* Internal cache information: NotebookFileLineBreakTest NotebookFileLineBreakTest NotebookDataPosition[ 157, 7] NotebookDataLength[ 99783, 2280] NotebookOptionsPosition[ 97147, 2205] NotebookOutlinePosition[ 97490, 2220] CellTagsIndexPosition[ 97447, 2217] WindowFrame->Normal*) (* Beginning of Notebook Content *) Notebook[{ Cell["Helper Functions", "Text", CellChangeTimes->{{3.6854385458543634`*^9, 3.685438549192769*^9}}], Cell[BoxData[{ RowBox[{ RowBox[{"CreatePlot", "[", RowBox[{"H_", ",", RowBox[{"start_:", "1"}]}], "]"}], ":=", RowBox[{"(", "\[IndentingNewLine]", RowBox[{ RowBox[{"size", "=", RowBox[{ RowBox[{"Dimensions", "[", "H", "]"}], "[", RowBox[{"[", "1", "]"}], "]"}]}], ";", "\[IndentingNewLine]", RowBox[{"init", "=", RowBox[{"SparseArray", "[", RowBox[{ RowBox[{"{", RowBox[{"start", "->", "1"}], "}"}], ",", RowBox[{"{", "size", "}"}]}], "]"}]}], ";", "\[IndentingNewLine]", RowBox[{"DensityPlot", "[", RowBox[{ RowBox[{"If", "[", RowBox[{ RowBox[{ RowBox[{"Abs", "[", RowBox[{"x", "-", RowBox[{"Round", "[", "x", "]"}]}], "]"}], "<", "0.2"}], ",", RowBox[{ RowBox[{"Abs", "[", RowBox[{ RowBox[{"MatrixExp", "[", RowBox[{ RowBox[{ RowBox[{"-", "\[ImaginaryI]"}], " ", "H", " ", "y"}], ",", "init"}], "]"}], "[", RowBox[{"[", RowBox[{"Round", "[", "x", "]"}], "]"}], "]"}], "]"}], "^", "2"}], ",", "0"}], "]"}], ",", RowBox[{"{", RowBox[{"x", ",", "0.5", ",", RowBox[{"size", "+", "0.5"}]}], "}"}], ",", RowBox[{"{", RowBox[{"y", ",", "0", ",", RowBox[{ RowBox[{"-", "\[Pi]"}], "/", "2"}]}], "}"}], ",", RowBox[{"ColorFunction", "\[Rule]", "\"\\""}], ",", RowBox[{"PlotPoints", "\[Rule]", "200"}], ",", RowBox[{"PlotLegends", "\[Rule]", RowBox[{"BarLegend", "[", RowBox[{ RowBox[{"{", RowBox[{"\"\\"", ",", RowBox[{"{", RowBox[{"0", ",", "0.15"}], "}"}]}], "}"}], ",", RowBox[{"LegendLabel", "\[Rule]", "\"\\""}], ",", RowBox[{"LabelStyle", "->", RowBox[{"Directive", "[", RowBox[{ RowBox[{"FontSize", "\[Rule]", "20"}], ",", RowBox[{"FontFamily", "\[Rule]", "\"\\""}]}], "]"}]}], ",", RowBox[{"LegendMarkerSize", "\[Rule]", "300"}]}], "]"}]}], ",", RowBox[{"FrameLabel", "\[Rule]", RowBox[{"{", RowBox[{"\"\\"", ",", "\"\\""}], "}"}]}], ",", RowBox[{"LabelStyle", "\[Rule]", RowBox[{"Directive", "[", RowBox[{ RowBox[{"FontSize", "\[Rule]", "28"}], ",", RowBox[{"FontFamily", "\[Rule]", "\"\\""}]}], "]"}]}], ",", RowBox[{"ImageSize", "\[Rule]", "Large"}], ",", RowBox[{"FrameTicks", "\[Rule]", RowBox[{"{", RowBox[{ RowBox[{"{", RowBox[{ RowBox[{"{", RowBox[{ RowBox[{"{", RowBox[{"0.0", ",", "\"\<0\>\""}], "}"}], ",", RowBox[{"{", RowBox[{ RowBox[{ RowBox[{"-", "\[Pi]"}], "/", "4"}], ",", "\"\<\[Pi]/4\>\""}], "}"}], ",", RowBox[{"{", RowBox[{ RowBox[{ RowBox[{"-", "\[Pi]"}], "/", "2"}], ",", "\"\<\[Pi]/2\>\""}], "}"}]}], "}"}], ",", "None"}], "}"}], ",", RowBox[{"{", RowBox[{ RowBox[{"{", RowBox[{"1", ",", RowBox[{ RowBox[{"(", RowBox[{"size", "+", "1"}], ")"}], "/", "2"}], ",", "size"}], "}"}], ",", "None"}], "}"}]}], "}"}]}], ",", RowBox[{"PlotRange", "\[Rule]", RowBox[{"{", RowBox[{"0", ",", "0.15"}], "}"}]}]}], "]"}]}], "\[IndentingNewLine]", ")"}]}], "\[IndentingNewLine]", RowBox[{ RowBox[{"CreateTriDiagonal", "[", RowBox[{"{", RowBox[{"OffDiag_", ",", "Diag_"}], "}"}], "]"}], ":=", RowBox[{"(", " ", "\n", RowBox[{ RowBox[{"DiagonalMatrix", "[", RowBox[{"OffDiag", ",", "1"}], "]"}], "+", RowBox[{"DiagonalMatrix", "[", RowBox[{"OffDiag", ",", RowBox[{"-", "1"}]}], "]"}], "+", RowBox[{"DiagonalMatrix", "[", "Diag", "]"}]}], "\n", ")"}]}], "\[IndentingNewLine]", RowBox[{ RowBox[{"PST", "[", "size_", "]"}], ":=", RowBox[{"{", RowBox[{ RowBox[{"Table", "[", RowBox[{ RowBox[{"Sqrt", "[", RowBox[{"n", RowBox[{"(", RowBox[{"size", "-", "n"}], ")"}]}], "]"}], ",", RowBox[{"{", RowBox[{"n", ",", RowBox[{"size", "-", "1"}]}], "}"}]}], "]"}], ",", RowBox[{"Table", "[", RowBox[{"0", ",", RowBox[{"{", "size", "}"}]}], "]"}]}], "}"}]}], "\[IndentingNewLine]", RowBox[{ RowBox[{"Hahn", "[", RowBox[{"size_", ",", "\[Alpha]_"}], "]"}], ":=", RowBox[{"{", RowBox[{ RowBox[{"Table", "[", RowBox[{ RowBox[{"Sqrt", "[", RowBox[{"n", RowBox[{"(", RowBox[{"n", "+", "\[Alpha]"}], ")"}], RowBox[{"(", RowBox[{"size", "-", "n"}], ")"}], RowBox[{"(", RowBox[{"size", "+", "\[Alpha]", "-", "n"}], ")"}]}], "]"}], ",", RowBox[{"{", RowBox[{"n", ",", "1", ",", RowBox[{"size", "-", "1"}]}], "}"}]}], "]"}], ",", RowBox[{"Table", "[", RowBox[{ RowBox[{ RowBox[{ RowBox[{ RowBox[{"(", RowBox[{"size", "-", "1"}], ")"}], "^", "2"}], "/", "2"}], "+", RowBox[{ RowBox[{"(", RowBox[{"\[Alpha]", "+", "1"}], ")"}], RowBox[{"(", RowBox[{"size", "-", "1"}], ")"}]}], "-", RowBox[{"2", RowBox[{ RowBox[{"(", RowBox[{"n", "-", "1", "-", RowBox[{ RowBox[{"(", RowBox[{"size", "-", "1"}], ")"}], "/", "2"}]}], ")"}], "^", "2"}]}]}], ",", RowBox[{"{", RowBox[{"n", ",", "1", ",", "size"}], "}"}]}], "]"}]}], "}"}]}], "\[IndentingNewLine]", RowBox[{ RowBox[{"GiveEvolution", "[", RowBox[{"Ham_", ",", "time_", ",", RowBox[{"start_:", "1"}]}], "]"}], ":=", RowBox[{"MatrixExp", "[", RowBox[{ RowBox[{ RowBox[{"-", "I"}], " ", "time", " ", "Ham"}], ",", RowBox[{"SparseArray", "[", RowBox[{ RowBox[{"{", RowBox[{"start", "->", "1"}], "}"}], ",", RowBox[{"{", RowBox[{ RowBox[{"Dimensions", "[", "Ham", "]"}], "[", RowBox[{"[", "1", "]"}], "]"}], "}"}]}], "]"}]}], "]"}]}], "\[IndentingNewLine]", RowBox[{ RowBox[{"SolveIEP", "[", RowBox[{"spectrum_", ",", "coefficients_"}], "]"}], ":=", RowBox[{"(", " ", "\n", RowBox[{ RowBox[{"size00", "=", RowBox[{"Length", "[", "spectrum", "]"}]}], ";", "\n", RowBox[{"evectors00", "=", RowBox[{"Table", "[", RowBox[{"0", ",", RowBox[{"{", "size00", "}"}], ",", RowBox[{"{", "size00", "}"}]}], "]"}]}], ";", "\n", RowBox[{"couplings00", "=", RowBox[{"Table", "[", RowBox[{"0", ",", RowBox[{"{", RowBox[{"size00", "-", "1"}], "}"}]}], "]"}]}], ";", "\n", RowBox[{"fields00", "=", RowBox[{"Table", "[", RowBox[{"0", ",", RowBox[{"{", "size00", "}"}]}], "]"}]}], ";", "\n", RowBox[{ RowBox[{"evectors00", "[", RowBox[{"[", "1", "]"}], "]"}], "=", RowBox[{"Sqrt", "[", "coefficients", "]"}]}], ";", "\n", RowBox[{"For", "[", RowBox[{ RowBox[{"idx00", "=", "1"}], ",", RowBox[{"idx00", "<", "size00"}], ",", RowBox[{"idx00", "++"}], ",", "\n", RowBox[{ RowBox[{ RowBox[{"fields00", "[", RowBox[{"[", "idx00", "]"}], "]"}], "=", RowBox[{"Simplify", "[", RowBox[{"spectrum", ".", RowBox[{"(", RowBox[{ RowBox[{"evectors00", "[", RowBox[{"[", "idx00", "]"}], "]"}], "^", "2"}], ")"}]}], "]"}]}], ";", "\n", RowBox[{ RowBox[{"couplings00", "[", RowBox[{"[", "idx00", "]"}], "]"}], "=", RowBox[{"Simplify", "[", RowBox[{"Sqrt", "[", RowBox[{ RowBox[{ RowBox[{"(", RowBox[{"spectrum", "^", "2"}], ")"}], ".", RowBox[{"(", RowBox[{ RowBox[{"evectors00", "[", RowBox[{"[", "idx00", "]"}], "]"}], "^", "2"}], ")"}]}], "-", RowBox[{ RowBox[{"fields00", "[", RowBox[{"[", "idx00", "]"}], "]"}], "^", "2"}], "-", RowBox[{"If", "[", RowBox[{ RowBox[{"idx00", ">", "1"}], ",", RowBox[{ RowBox[{"couplings00", "[", RowBox[{"[", RowBox[{"idx00", "-", "1"}], "]"}], "]"}], "^", "2"}], ",", "0"}], "]"}]}], "]"}], "]"}]}], ";", "\n", RowBox[{ RowBox[{"evectors00", "[", RowBox[{"[", RowBox[{"idx00", "+", "1"}], "]"}], "]"}], "=", RowBox[{"Simplify", "[", RowBox[{ RowBox[{"(", RowBox[{ RowBox[{"spectrum", "*", RowBox[{"evectors00", "[", RowBox[{"[", "idx00", "]"}], "]"}]}], "-", RowBox[{ RowBox[{"fields00", "[", RowBox[{"[", "idx00", "]"}], "]"}], RowBox[{"evectors00", "[", RowBox[{"[", "idx00", "]"}], "]"}]}], "-", RowBox[{"If", "[", RowBox[{ RowBox[{"idx00", ">", "1"}], ",", RowBox[{ RowBox[{"evectors00", "[", RowBox[{"[", RowBox[{"idx00", "-", "1"}], "]"}], "]"}], RowBox[{"couplings00", "[", RowBox[{"[", RowBox[{"idx00", "-", "1"}], "]"}], "]"}]}], ",", "0"}], "]"}]}], ")"}], "/", RowBox[{"couplings00", "[", RowBox[{"[", "idx00", "]"}], "]"}]}], "]"}]}], ";"}]}], "\n", "]"}], ";", "\n", RowBox[{ RowBox[{"fields00", "[", RowBox[{"[", "size00", "]"}], "]"}], "=", RowBox[{"Simplify", "[", RowBox[{"spectrum", ".", RowBox[{"(", RowBox[{ RowBox[{"evectors00", "[", RowBox[{"[", "size00", "]"}], "]"}], "^", "2"}], ")"}]}], "]"}]}], ";", "\n", RowBox[{"{", RowBox[{"couplings00", ",", "fields00"}], "}"}]}], "\n", ")"}]}]}], "Input", InitializationCell->True, CellChangeTimes->{{3.6854389554471145`*^9, 3.685438955632125*^9}, { 3.685439022062925*^9, 3.685439022367942*^9}, {3.6854391286740227`*^9, 3.6854391360894465`*^9}, {3.685439211960786*^9, 3.685439288920188*^9}, { 3.6854395707273064`*^9, 3.68543957306244*^9}, {3.6854396836707664`*^9, 3.6854396837977734`*^9}, {3.6854401879986124`*^9, 3.685440188184623*^9}, { 3.685444044852867*^9, 3.685444045149268*^9}}], Cell[CellGroupData[{ Cell["Analytic Solutions", "Section", CellChangeTimes->{{3.6854440881585436`*^9, 3.685444090841748*^9}}], Cell[CellGroupData[{ Cell["\<\ Here we create a (2N+1)x(2N+1) matrix that has a 0 eigenvalue, and all other \ eigenvalues half-integers with a uniform spacing, symmetric about 0. \ Parameter \[Alpha] specifies size of gap between 0 eigenvalue and uniformly \ spaced block, and is the only control over the 0-vector available.\ \>", "Text", CellGroupingRules->{GroupTogetherGrouping, 10000.}, CellChangeTimes->{{3.6683146667619667`*^9, 3.668314762982936*^9}, 3.685444058081691*^9}], Cell[BoxData[ RowBox[{ RowBox[{"MakeGoodExample", "[", RowBox[{"size_", ",", "\[Alpha]_"}], "]"}], ":=", RowBox[{"(", "\[IndentingNewLine]", RowBox[{"(*", RowBox[{ RowBox[{ "make", " ", "something", " ", "of", " ", "size", " ", "2", "size"}], "+", "1"}], " ", "*)"}], "\[IndentingNewLine]", RowBox[{ RowBox[{ RowBox[{"{", RowBox[{"a", ",", "b"}], "}"}], "=", RowBox[{"Hahn", "[", RowBox[{"size", ",", "\[Alpha]"}], "]"}]}], ";", "\[IndentingNewLine]", RowBox[{"b", "=", RowBox[{"b", "+", RowBox[{ RowBox[{ RowBox[{"(", RowBox[{ RowBox[{"2", "\[Alpha]"}], "+", "1"}], ")"}], "^", "2"}], "/", "4"}]}]}], ";", "\[IndentingNewLine]", RowBox[{"couplings", "=", RowBox[{"Table", "[", RowBox[{"0", ",", RowBox[{"{", "size", "}"}]}], "]"}]}], ";", "\[IndentingNewLine]", RowBox[{ RowBox[{"couplings", "[", RowBox[{"[", "1", "]"}], "]"}], "=", RowBox[{"If", "[", RowBox[{ RowBox[{"EvenQ", "[", "size", "]"}], ",", SqrtBox[ RowBox[{"a", "[", RowBox[{"[", RowBox[{"size", "/", "2"}], "]"}], "]"}]], ",", SqrtBox[ RowBox[{ RowBox[{"b", "[", RowBox[{"[", RowBox[{ RowBox[{"(", RowBox[{"size", "+", "1"}], ")"}], "/", "2"}], "]"}], "]"}], "/", "2"}]]}], "]"}]}], ";", "\[IndentingNewLine]", RowBox[{"For", "[", RowBox[{ RowBox[{"idx", "=", "2"}], ",", RowBox[{"idx", "\[LessEqual]", "size"}], ",", RowBox[{"idx", "++"}], ",", "\[IndentingNewLine]", RowBox[{ RowBox[{"m", "=", RowBox[{"size", "+", "1", "-", "idx"}]}], ";", "\[IndentingNewLine]", RowBox[{ RowBox[{"couplings", "[", RowBox[{"[", "idx", "]"}], "]"}], "=", RowBox[{"If", "[", RowBox[{ RowBox[{"OddQ", "[", "m", "]"}], ",", SqrtBox[ RowBox[{ RowBox[{"b", "[", RowBox[{"[", RowBox[{ RowBox[{"(", RowBox[{"m", "+", "1"}], ")"}], "/", "2"}], "]"}], "]"}], "-", RowBox[{ RowBox[{"couplings", "[", RowBox[{"[", RowBox[{"idx", "-", "1"}], "]"}], "]"}], "^", "2"}]}]], ",", RowBox[{ RowBox[{"a", "[", RowBox[{"[", RowBox[{"m", "/", "2"}], "]"}], "]"}], "/", RowBox[{"couplings", "[", RowBox[{"[", RowBox[{"idx", "-", "1"}], "]"}], "]"}]}]}], "]"}]}], ";"}]}], "\[IndentingNewLine]", "]"}], ";", "\[IndentingNewLine]", RowBox[{"Join", "[", RowBox[{ RowBox[{"Reverse", "[", "couplings", "]"}], ",", "couplings"}], "]"}]}], "\[IndentingNewLine]", ")"}]}]], "Input", CellGroupingRules->{GroupTogetherGrouping, 10000.}, CellChangeTimes->{{3.6653990665094647`*^9, 3.665399209860664*^9}, 3.6653992477168293`*^9, {3.6653992798926697`*^9, 3.665399282711831*^9}, { 3.665399481867222*^9, 3.665399528883911*^9}, {3.6653995710983257`*^9, 3.6653995929305744`*^9}, {3.6653997876727133`*^9, 3.665399803118596*^9}, { 3.665400882178315*^9, 3.6654009659921093`*^9}, {3.6654011695827537`*^9, 3.665401169710761*^9}, {3.665401574678924*^9, 3.665401575251957*^9}, 3.6654019913537564`*^9, {3.665402226817224*^9, 3.6654022287833366`*^9}, { 3.6654023245118117`*^9, 3.665402342782857*^9}, {3.665403143642664*^9, 3.665403167329018*^9}, {3.665403222976201*^9, 3.6654032405682073`*^9}, 3.685444058081691*^9}], Cell[BoxData[{ RowBox[{ RowBox[{"size", "=", "5"}], ";"}], "\[IndentingNewLine]", RowBox[{ RowBox[{"H", "=", RowBox[{"CreateTriDiagonal", "[", RowBox[{"{", RowBox[{ RowBox[{"MakeGoodExample", "[", RowBox[{"size", ",", "1"}], "]"}], ",", RowBox[{"Table", "[", RowBox[{"0", ",", RowBox[{"{", RowBox[{ RowBox[{"2", "size"}], "+", "1"}], "}"}]}], "]"}]}], "}"}], "]"}]}], ";", " ", RowBox[{"(*", RowBox[{ "change", " ", "second", " ", "parameter", " ", "of", " ", "MakeGoodExamples", " ", "to", " ", "different", " ", "integers", " ", "for", " ", "different", " ", "solutions"}], "*)"}], "\[IndentingNewLine]", RowBox[{"MatrixForm", "[", "H", "]"}]}], "\[IndentingNewLine]", RowBox[{ RowBox[{"Eigenvectors", "[", RowBox[{"H", ",", RowBox[{"-", "1"}]}], "]"}], "[", RowBox[{"[", "1", "]"}], "]"}], "\[IndentingNewLine]", RowBox[{"GiveEvolution", "[", RowBox[{"H", ",", RowBox[{"2", "\[Pi]"}]}], "]"}]}], "Input", CellGroupingRules->{GroupTogetherGrouping, 10000.}, CellChangeTimes->{{3.666501828290083*^9, 3.666501859552538*^9}, { 3.6665019712487345`*^9, 3.666502038063652*^9}, {3.6665020703245087`*^9, 3.666502073631714*^9}, {3.6665028392362595`*^9, 3.6665029355196285`*^9}, { 3.6665030438930187`*^9, 3.6665030506010303`*^9}, 3.685444058081691*^9, { 3.6854441588578677`*^9, 3.6854441615254726`*^9}, {3.6866282949935985`*^9, 3.686628314602833*^9}}], Cell[BoxData[ TagBox[ RowBox[{"(", "\[NoBreak]", GridBox[{ {"0", FractionBox["231", RowBox[{"2", " ", SqrtBox["2441"]}]], "0", "0", "0", "0", "0", "0", "0", "0", "0"}, { FractionBox["231", RowBox[{"2", " ", SqrtBox["2441"]}]], "0", RowBox[{"4", " ", SqrtBox[ FractionBox["730", "2441"]]}], "0", "0", "0", "0", "0", "0", "0", "0"}, {"0", RowBox[{"4", " ", SqrtBox[ FractionBox["730", "2441"]]}], "0", FractionBox[ SqrtBox[ FractionBox["2441", "73"]], "2"], "0", "0", "0", "0", "0", "0", "0"}, {"0", "0", FractionBox[ SqrtBox[ FractionBox["2441", "73"]], "2"], "0", FractionBox["24", SqrtBox["73"]], "0", "0", "0", "0", "0", "0"}, {"0", "0", "0", FractionBox["24", SqrtBox["73"]], "0", FractionBox[ SqrtBox[ FractionBox["73", "2"]], "2"], "0", "0", "0", "0", "0"}, {"0", "0", "0", "0", FractionBox[ SqrtBox[ FractionBox["73", "2"]], "2"], "0", FractionBox[ SqrtBox[ FractionBox["73", "2"]], "2"], "0", "0", "0", "0"}, {"0", "0", "0", "0", "0", FractionBox[ SqrtBox[ FractionBox["73", "2"]], "2"], "0", FractionBox["24", SqrtBox["73"]], "0", "0", "0"}, {"0", "0", "0", "0", "0", "0", FractionBox["24", SqrtBox["73"]], "0", FractionBox[ SqrtBox[ FractionBox["2441", "73"]], "2"], "0", "0"}, {"0", "0", "0", "0", "0", "0", "0", FractionBox[ SqrtBox[ FractionBox["2441", "73"]], "2"], "0", RowBox[{"4", " ", SqrtBox[ FractionBox["730", "2441"]]}], "0"}, {"0", "0", "0", "0", "0", "0", "0", "0", RowBox[{"4", " ", SqrtBox[ FractionBox["730", "2441"]]}], "0", FractionBox["231", RowBox[{"2", " ", SqrtBox["2441"]}]]}, {"0", "0", "0", "0", "0", "0", "0", "0", "0", FractionBox["231", RowBox[{"2", " ", SqrtBox["2441"]}]], "0"} }, GridBoxAlignment->{ "Columns" -> {{Center}}, "ColumnsIndexed" -> {}, "Rows" -> {{Baseline}}, "RowsIndexed" -> {}}, GridBoxSpacings->{"Columns" -> { Offset[0.27999999999999997`], { Offset[0.7]}, Offset[0.27999999999999997`]}, "ColumnsIndexed" -> {}, "Rows" -> { Offset[0.2], { Offset[0.4]}, Offset[0.2]}, "RowsIndexed" -> {}}], "\[NoBreak]", ")"}], Function[BoxForm`e$, MatrixForm[BoxForm`e$]]]], "Output", CellGroupingRules->{GroupTogetherGrouping, 10000.}, CellChangeTimes->{{3.6665019740255394`*^9, 3.6665020480008693`*^9}, 3.6665020835065317`*^9, {3.6665028712163153`*^9, 3.666502940620837*^9}, 3.6665030513342314`*^9, 3.685444058081691*^9, 3.6866282653067465`*^9}], Cell[BoxData[ RowBox[{"{", RowBox[{ RowBox[{"-", "1"}], ",", "0", ",", FractionBox["231", RowBox[{"8", " ", SqrtBox["730"]}]], ",", "0", ",", RowBox[{"-", FractionBox[ RowBox[{"77", " ", SqrtBox[ FractionBox["2441", "730"]]}], "128"]}], ",", "0", ",", FractionBox[ RowBox[{"77", " ", SqrtBox[ FractionBox["2441", "730"]]}], "128"], ",", "0", ",", RowBox[{"-", FractionBox["231", RowBox[{"8", " ", SqrtBox["730"]}]]}], ",", "0", ",", "1"}], "}"}]], "Output", CellGroupingRules->{GroupTogetherGrouping, 10000.}, CellChangeTimes->{{3.6665019740255394`*^9, 3.6665020480008693`*^9}, 3.6665020835065317`*^9, {3.6665028712163153`*^9, 3.666502940620837*^9}, 3.6665030513342314`*^9, 3.685444058081691*^9, 3.686628265478347*^9}], Cell[BoxData[ RowBox[{"{", RowBox[{ RowBox[{"-", FractionBox["77077", "109845"]}], ",", "0", ",", RowBox[{"-", FractionBox[ RowBox[{"157696", " ", SqrtBox[ FractionBox["2", "365"]]}], "36615"]}], ",", "0", ",", FractionBox[ RowBox[{"9856", " ", SqrtBox[ FractionBox["2", "890965"]]}], "45"], ",", "0", ",", RowBox[{"-", FractionBox[ RowBox[{"9856", " ", SqrtBox[ FractionBox["2", "890965"]]}], "45"]}], ",", "0", ",", FractionBox[ RowBox[{"157696", " ", SqrtBox[ FractionBox["2", "365"]]}], "36615"], ",", "0", ",", RowBox[{"-", FractionBox["32768", "109845"]}]}], "}"}]], "Output", CellGroupingRules->{GroupTogetherGrouping, 10000.}, CellChangeTimes->{{3.6665019740255394`*^9, 3.6665020480008693`*^9}, 3.6665020835065317`*^9, {3.6665028712163153`*^9, 3.666502940620837*^9}, 3.6665030513342314`*^9, 3.685444058081691*^9, 3.6866282718275576`*^9}] }, Open ]], Cell["\<\ These are a good starting point for approximate solutions, e.g. trying to \ make the W state\ \>", "Text", CellChangeTimes->{{3.6854442711460657`*^9, 3.6854442889924965`*^9}}], Cell[CellGroupData[{ Cell[BoxData[{ RowBox[{ RowBox[{"size", "=", "35"}], ";"}], "\[IndentingNewLine]", RowBox[{ RowBox[{ RowBox[{"inputsite", "=", "1"}], ";"}], "\[IndentingNewLine]", RowBox[{"(*", RowBox[{ RowBox[{ "Target", " ", "state", " ", "must", " ", "be", " ", "a", " ", "real"}], ",", " ", RowBox[{"vector", " ", "of", " ", "length", " ", RowBox[{"N", ".", " ", "Cannot"}], " ", "have", " ", "2", " ", "consecutive", " ", "0", " ", RowBox[{"amplitudes", ".", " ", "First"}], " ", "and", " ", "last", " ", "elements", " ", "must", " ", "not", " ", "be", " ", "0.", " ", RowBox[{"(", RowBox[{"strictly", ",", " ", RowBox[{ "this", " ", "applies", " ", "to", " ", "target2", " ", "not", " ", "targetstate"}]}], ")"}]}]}], " ", "*)"}]}], "\[IndentingNewLine]", RowBox[{ RowBox[{"targetstate", "=", RowBox[{"Table", "[", RowBox[{"1", ",", RowBox[{"{", "size", "}"}]}], "]"}]}], ";", RowBox[{"(*", RowBox[{"W", " ", "state", " ", "is", " ", "a", " ", "good", " ", RowBox[{"example", "."}]}], " ", "*)"}], "\[IndentingNewLine]", RowBox[{"(*", RowBox[{ RowBox[{"targetstate", "=", RowBox[{"Join", "[", RowBox[{ RowBox[{"Table", "[", RowBox[{"1", ",", RowBox[{"{", RowBox[{ RowBox[{"(", RowBox[{"mid", "-", "1"}], ")"}], "/", "2"}], "}"}]}], "]"}], ",", RowBox[{"{", "3", "}"}], ",", RowBox[{"Table", "[", RowBox[{"2", ",", RowBox[{"{", RowBox[{ RowBox[{"(", RowBox[{"mid", "-", "1"}], ")"}], "/", "2"}], "}"}]}], "]"}]}], "]"}]}], ";"}], "*)"}], " ", RowBox[{"(*", RowBox[{"asymmetric", " ", "example"}], "*)"}], "\[IndentingNewLine]", RowBox[{"(*", RowBox[{ RowBox[{"targetstate", "=", RowBox[{"RandomReal", "[", RowBox[{ RowBox[{"{", RowBox[{"0.5", ",", "1"}], "}"}], ",", "mid"}], "]"}]}], ";"}], "*)"}], RowBox[{"(*", RowBox[{ RowBox[{"random", " ", "example"}], ",", " ", RowBox[{"fully", " ", "asymmetric"}]}], "*)"}], "\[IndentingNewLine]", RowBox[{"targetstate", "=", RowBox[{"targetstate", "/", SqrtBox[ RowBox[{"targetstate", ".", "targetstate"}]]}]}], ";"}], "\[IndentingNewLine]", RowBox[{ RowBox[{"If", "[", RowBox[{ RowBox[{ RowBox[{"Length", "[", "targetstate", "]"}], "\[NotEqual]", "size"}], ",", RowBox[{ RowBox[{"Print", "[", "\"\\"", "]"}], ";", " ", RowBox[{"Abort", "[", "]"}]}]}], "]"}], ";"}], "\[IndentingNewLine]", RowBox[{ RowBox[{"initstate", "=", RowBox[{"Table", "[", RowBox[{ RowBox[{"KroneckerDelta", "[", RowBox[{"n", ",", "inputsite"}], "]"}], ",", RowBox[{"{", RowBox[{"n", ",", "1", ",", "size"}], "}"}]}], "]"}]}], ";"}], "\[IndentingNewLine]", RowBox[{ RowBox[{ RowBox[{"target2", "=", RowBox[{ RowBox[{"(", RowBox[{"initstate", "-", "targetstate"}], ")"}], "/", SqrtBox[ RowBox[{"2", RowBox[{"(", RowBox[{"1", "-", RowBox[{"initstate", ".", "targetstate"}]}], ")"}]}]]}]}], ";"}], " ", RowBox[{"(*", RowBox[{ RowBox[{"this", " ", "is", " ", "the", " ", "0"}], "-", RowBox[{"eigenvector", " ", "that", " ", "we", " ", "target"}]}], "*)"}]}], "\[IndentingNewLine]", RowBox[{ RowBox[{"target2", "=", RowBox[{"target2", "*", RowBox[{"Sign", "[", RowBox[{"target2", "[", RowBox[{"[", "size", "]"}], "]"}], "]"}]}]}], ";"}], "\[IndentingNewLine]", RowBox[{ RowBox[{"targetEV", "=", RowBox[{"Sort", "[", RowBox[{"Append", "[", RowBox[{ RowBox[{"Table", "[", RowBox[{ RowBox[{ RowBox[{"-", "size"}], "+", RowBox[{"2", "n"}]}], ",", RowBox[{"{", RowBox[{"n", ",", "1", ",", RowBox[{"size", "-", "1"}]}], "}"}]}], "]"}], ",", "0"}], "]"}], "]"}]}], ";"}], "\[IndentingNewLine]", RowBox[{ RowBox[{"couplings", "=", RowBox[{"N", "[", RowBox[{"MakeGoodExample", "[", RowBox[{ RowBox[{ RowBox[{"(", RowBox[{"size", "-", "1"}], ")"}], "/", "2"}], ",", "1"}], "]"}], "]"}]}], ";"}], "\[IndentingNewLine]", RowBox[{ RowBox[{"For", "[", RowBox[{ RowBox[{"k", "=", "2"}], ",", RowBox[{"k", "\[LessEqual]", RowBox[{"size", "-", "1"}]}], ",", RowBox[{"k", "++"}], ",", "\[IndentingNewLine]", RowBox[{ RowBox[{ RowBox[{"couplings", "[", RowBox[{"[", "k", "]"}], "]"}], "=", RowBox[{ RowBox[{"-", RowBox[{"couplings", "[", RowBox[{"[", "k", "]"}], "]"}]}], " ", RowBox[{"Sign", "[", RowBox[{ RowBox[{"target2", "[", RowBox[{"[", RowBox[{"k", "-", "1"}], "]"}], "]"}], " ", RowBox[{ RowBox[{"couplings", "[", RowBox[{"[", RowBox[{"k", "-", "1"}], "]"}], "]"}], "/", RowBox[{"target2", "[", RowBox[{"[", RowBox[{"k", "+", "1"}], "]"}], "]"}]}]}], "]"}]}]}], ";"}]}], "\[IndentingNewLine]", "]"}], ";"}], "\[IndentingNewLine]", RowBox[{ RowBox[{"fields", "=", RowBox[{"Table", "[", RowBox[{"0", ",", RowBox[{"{", "size", "}"}]}], "]"}]}], ";"}], "\[IndentingNewLine]", RowBox[{ RowBox[{"H0", "=", RowBox[{"CreateTriDiagonal", "[", RowBox[{"{", RowBox[{"couplings", ",", "fields"}], "}"}], "]"}]}], ";"}], "\[IndentingNewLine]", RowBox[{ RowBox[{"runningbest", "=", RowBox[{ RowBox[{ RowBox[{"Eigenvectors", "[", RowBox[{"H0", ",", RowBox[{"-", "1"}]}], "]"}], "[", RowBox[{"[", "1", "]"}], "]"}], ".", "target2"}]}], ";"}], "\[IndentingNewLine]", RowBox[{ RowBox[{"Print", "[", "runningbest", "]"}], ";"}], "\[IndentingNewLine]", RowBox[{ RowBox[{"\[Epsilon]", "=", "0.04"}], ";"}], "\[IndentingNewLine]", RowBox[{ RowBox[{"For", "[", RowBox[{ RowBox[{"runner", "=", "1"}], ",", RowBox[{"runner", "\[LessEqual]", "20000"}], ",", RowBox[{"runner", "++"}], ",", "\[IndentingNewLine]", RowBox[{ RowBox[{"evecs0", "=", RowBox[{"Chop", "[", RowBox[{"Eigenvectors", "[", "H0", "]"}], "]"}]}], ";", "\[IndentingNewLine]", RowBox[{"shift", "=", RowBox[{ RowBox[{ RowBox[{"-", RowBox[{"(", RowBox[{ RowBox[{"Append", "[", RowBox[{ RowBox[{ RowBox[{"Rest", "[", "target2", "]"}], "*", "couplings"}], ",", "0"}], "]"}], "+", RowBox[{"Prepend", "[", RowBox[{ RowBox[{ RowBox[{"Most", "[", "target2", "]"}], "*", "couplings"}], ",", "0"}], "]"}]}], ")"}]}], "/", "target2"}], "-", "fields"}]}], ";", "\[IndentingNewLine]", RowBox[{"pert", "=", RowBox[{"Max", "[", RowBox[{"Abs", "[", "shift", "]"}], "]"}]}], ";", "\[IndentingNewLine]", RowBox[{"shift", "=", RowBox[{"shift", "*", RowBox[{"If", "[", RowBox[{ RowBox[{"pert", "<", "\[Epsilon]"}], ",", "1", ",", RowBox[{"\[Epsilon]", "/", "pert"}]}], "]"}]}]}], ";", "\[IndentingNewLine]", RowBox[{"H", "=", RowBox[{"CreateTriDiagonal", "[", RowBox[{"{", RowBox[{"couplings", ",", RowBox[{"fields", "+", "shift"}]}], "}"}], "]"}]}], ";", "\[IndentingNewLine]", RowBox[{ RowBox[{"{", RowBox[{"evals", ",", "evecs"}], "}"}], "=", RowBox[{"Eigensystem", "[", "H", "]"}]}], ";", "\[IndentingNewLine]", RowBox[{"order", "=", RowBox[{"Ordering", "[", "evals", "]"}]}], ";", "\[IndentingNewLine]", RowBox[{"weights", "=", RowBox[{ RowBox[{"evecs", "[", RowBox[{"[", RowBox[{"order", ",", "1"}], "]"}], "]"}], "^", "2"}]}], ";", "\[IndentingNewLine]", RowBox[{ RowBox[{"{", RowBox[{"couplings", ",", "fields"}], "}"}], "=", RowBox[{"SolveIEP", "[", RowBox[{"targetEV", ",", "weights"}], "]"}]}], ";", "\[IndentingNewLine]", RowBox[{"For", "[", RowBox[{ RowBox[{"k", "=", "2"}], ",", RowBox[{"k", "\[LessEqual]", RowBox[{"size", "-", "1"}]}], ",", RowBox[{"k", "++"}], ",", "\[IndentingNewLine]", RowBox[{ RowBox[{ RowBox[{"couplings", "[", RowBox[{"[", "k", "]"}], "]"}], "=", RowBox[{ RowBox[{"-", RowBox[{"couplings", "[", RowBox[{"[", "k", "]"}], "]"}]}], " ", RowBox[{"Sign", "[", RowBox[{ RowBox[{"target2", "[", RowBox[{"[", RowBox[{"k", "-", "1"}], "]"}], "]"}], " ", RowBox[{ RowBox[{"couplings", "[", RowBox[{"[", RowBox[{"k", "-", "1"}], "]"}], "]"}], "/", RowBox[{"target2", "[", RowBox[{"[", RowBox[{"k", "+", "1"}], "]"}], "]"}]}]}], "]"}]}]}], ";"}]}], "\[IndentingNewLine]", "]"}], ";", "\[IndentingNewLine]", RowBox[{"H0", "=", RowBox[{"CreateTriDiagonal", "[", RowBox[{"{", RowBox[{"couplings", ",", "fields"}], "}"}], "]"}]}], ";", "\[IndentingNewLine]", RowBox[{"temp", "=", RowBox[{ RowBox[{ RowBox[{"Eigenvectors", "[", RowBox[{"H0", ",", RowBox[{"-", "1"}]}], "]"}], "[", RowBox[{"[", "1", "]"}], "]"}], ".", "target2"}]}], ";", "\[IndentingNewLine]", RowBox[{"If", "[", RowBox[{ RowBox[{"temp", ">", "runningbest"}], ",", "\[IndentingNewLine]", RowBox[{ RowBox[{"If", "[", RowBox[{ RowBox[{ RowBox[{"(", RowBox[{ RowBox[{"Floor", "[", RowBox[{"temp", ",", "0.1"}], "]"}], "\[NotEqual]", RowBox[{"Floor", "[", RowBox[{"runningbest", ",", "0.1"}], "]"}]}], ")"}], "||", RowBox[{"(", RowBox[{ RowBox[{"Floor", "[", RowBox[{"Log", "[", RowBox[{"10", ",", RowBox[{"1", "-", "temp"}]}], "]"}], "]"}], "\[NotEqual]", RowBox[{"Floor", "[", RowBox[{"Log", "[", RowBox[{"10", ",", RowBox[{"1", "-", "runningbest"}]}], "]"}], "]"}]}], ")"}]}], ",", RowBox[{"Print", "[", "temp", "]"}]}], "]"}], ";", "\[IndentingNewLine]", RowBox[{"runningbest", "=", "temp"}], ";", "\[IndentingNewLine]", RowBox[{"bestH", "=", "H0"}], ";"}]}], "\[IndentingNewLine]", "]"}], ";"}]}], "\[IndentingNewLine]", "]"}], ";"}], "\[IndentingNewLine]", RowBox[{ RowBox[{"Print", "[", RowBox[{ "\"\\"", ",", "runningbest", ",", " ", "\"\< with target state.\>\""}], "]"}], ";"}], "\[IndentingNewLine]", RowBox[{"MatrixForm", "[", "bestH", "]"}]}], "Input", CellChangeTimes->{{3.6866283414660797`*^9, 3.6866283427140827`*^9}, { 3.686628389342564*^9, 3.686628390309766*^9}, {3.6866284514150734`*^9, 3.6866284799943237`*^9}, 3.686628817663348*^9}], Cell[CellGroupData[{ Cell[BoxData["0.666182786620208`"], "Print", CellChangeTimes->{3.686628420480219*^9, 3.6866284818819265`*^9}], Cell[BoxData["0.7026545322413364`"], "Print", CellChangeTimes->{3.686628420480219*^9, 3.6866284961559515`*^9}], Cell[BoxData["0.8061681230894175`"], "Print", CellChangeTimes->{3.686628420480219*^9, 3.6866284965147524`*^9}], Cell[BoxData["0.9834771269810468`"], "Print", CellChangeTimes->{3.686628420480219*^9, 3.6866284985583563`*^9}], Cell[BoxData["0.9931649775750204`"], "Print", CellChangeTimes->{3.686628420480219*^9, 3.6866285312716136`*^9}], Cell[BoxData["0.9994141855495412`"], "Print", CellChangeTimes->{3.686628420480219*^9, 3.686628550256847*^9}], Cell[BoxData["0.9999851890119669`"], "Print", CellChangeTimes->{3.686628420480219*^9, 3.6866285798500986`*^9}], Cell[BoxData["0.9999984137988598`"], "Print", CellChangeTimes->{3.686628420480219*^9, 3.6866285927669215`*^9}], Cell[BoxData["0.9999990958459751`"], "Print", CellChangeTimes->{3.686628420480219*^9, 3.6866285962613277`*^9}], Cell[BoxData["0.99999996862749`"], "Print", CellChangeTimes->{3.686628420480219*^9, 3.6866286157301617`*^9}], Cell[BoxData["0.9999999995566989`"], "Print", CellChangeTimes->{3.686628420480219*^9, 3.6866286184445667`*^9}], Cell[BoxData["0.9999999999954247`"], "Print", CellChangeTimes->{3.686628420480219*^9, 3.6866286212993717`*^9}], Cell[BoxData["0.9999999999998687`"], "Print", CellChangeTimes->{3.686628420480219*^9, 3.686628623186975*^9}], Cell[BoxData["1.0000000000000002`"], "Print", CellChangeTimes->{3.686628420480219*^9, 3.6866286272595825`*^9}], Cell[BoxData[ InterpretationBox[ RowBox[{"\<\"Solution achieves fidelity: \"\>", "\[InvisibleSpace]", "1.0000000000000002`", "\[InvisibleSpace]", "\<\"with target state.\"\>"}], SequenceForm[ "Solution achieves fidelity: ", 1.0000000000000002`, "with target state."], Editable->False]], "Print", CellChangeTimes->{3.686628420480219*^9, 3.686628711237261*^9}] }, Open ]], Cell[BoxData[ TagBox[ RowBox[{"(", "\[NoBreak]", GridBox[{ {"1.6312981368318635`", "8.019591805646368`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`"}, {"8.019591805646368`", "25.094001198922236`", "14.330951954908478`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`"}, {"0.`", "14.330951954908478`", RowBox[{"-", "4.987335372212645`"}], RowBox[{"-", "9.343616640957991`"}], "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`"}, {"0.`", "0.`", RowBox[{"-", "9.343616640957991`"}], RowBox[{"-", "4.884073218371204`"}], "14.227690015863205`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`"}, {"0.`", "0.`", "0.`", "14.227690015863205`", RowBox[{"-", "0.734069083357223`"}], RowBox[{"-", "13.493621089556632`"}], "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`"}, {"0.`", "0.`", "0.`", "0.`", RowBox[{"-", "13.493621089556632`"}], RowBox[{"-", "3.287633396502487`"}], "16.78125447079286`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`"}, {"0.`", "0.`", "0.`", "0.`", "0.`", "16.78125447079286`", RowBox[{"-", "0.5393993386480834`"}], RowBox[{"-", "16.241855191832858`"}], "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`"}, {"0.`", "0.`", "0.`", "0.`", "0.`", "0.`", RowBox[{"-", "16.241855191832858`"}], RowBox[{"-", "1.4233018740720105`"}], "17.66515711224179`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`"}, {"0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "17.66515711224179`", RowBox[{"-", "0.7954566729590594`"}], RowBox[{"-", "16.869700575104233`"}], "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`"}, {"0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", RowBox[{"-", "16.869700575104233`"}], "0.0288884293182781`", "16.84081167752875`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`"}, {"0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "16.84081167752875`", RowBox[{"-", "2.095948796695811`"}], RowBox[{"-", "14.744862722090923`"}], "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`"}, {"0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", RowBox[{"-", "14.744862722090923`"}], RowBox[{"-", "0.5786944319587031`"}], "15.323556895942339`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`"}, {"0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "15.323556895942339`", "0.4313499792485939`", RowBox[{"-", "15.754907016447355`"}], "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`"}, {"0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", RowBox[{"-", "15.754907016447355`"}], RowBox[{"-", "1.5451493511966348`"}], "17.300056219008027`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`"}, {"0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "17.300056219008027`", RowBox[{"-", "2.3393205696107278`"}], RowBox[{"-", "14.96073564589819`"}], "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`"}, {"0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", RowBox[{"-", "14.96073564589819`"}], "0.0015356770806844403`", "14.959200286747743`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`"}, {"0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "14.959200286747743`", "0.08813051415552223`", RowBox[{"-", "15.047330758587773`"}], "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`"}, {"0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", RowBox[{"-", "15.047330758587773`"}], RowBox[{"-", "0.5783000311705035`"}], "15.625630803954046`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`"}, {"0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "15.625630803954046`", RowBox[{"-", "1.4653624895872648`"}], RowBox[{"-", "14.160268165839609`"}], "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`"}, {"0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", RowBox[{"-", "14.160268165839609`"}], RowBox[{"-", "1.9083671331863439`"}], "16.068634915590252`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`"}, {"0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "16.068634915590252`", RowBox[{"-", "1.9148891366747463`"}], RowBox[{"-", "14.153745476093793`"}], "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`"}, {"0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", RowBox[{"-", "14.153745476093793`"}], "1.4761144322060862`", "12.677631028920747`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`"}, {"0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "12.677631028920747`", "1.2873029041942545`", RowBox[{"-", "13.964934358800758`"}], "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`"}, {"0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", RowBox[{"-", "13.964934358800758`"}], RowBox[{"-", "0.32707725941036536`"}], "14.292011319512541`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`"}, {"0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "14.292011319512541`", RowBox[{"-", "2.187610739166915`"}], RowBox[{"-", "12.10440008486738`"}], "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`"}, {"0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", RowBox[{"-", "12.10440008486738`"}], "0.16949919802418772`", "11.934901036972782`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`"}, {"0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "11.934901036972782`", RowBox[{"-", "0.918249588753197`"}], RowBox[{"-", "11.01665084448019`"}], "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`"}, {"0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", RowBox[{"-", "11.01665084448019`"}], "0.2816669688060775`", "10.734984241606178`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`"}, {"0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "10.734984241606178`", RowBox[{"-", "0.39811607398006604`"}], RowBox[{"-", "10.336868481060025`"}], "0.`", "0.`", "0.`", "0.`", "0.`"}, {"0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", RowBox[{"-", "10.336868481060025`"}], "1.2131445966584953`", "9.123723925694328`", "0.`", "0.`", "0.`", "0.`"}, {"0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "9.123723925694328`", RowBox[{"-", "1.0493320235093586`"}], RowBox[{"-", "8.074391233356536`"}], "0.`", "0.`", "0.`"}, {"0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", RowBox[{"-", "8.074391233356536`"}], "0.7617902934184428`", "7.312600310812852`", "0.`", "0.`"}, {"0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "7.312600310812852`", RowBox[{"-", "2.007976165512395`"}], RowBox[{"-", "5.304624209899443`"}], "0.`"}, {"0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", RowBox[{"-", "5.304624209899443`"}], "4.4027824294454305`", "0.9018419561789777`"}, {"0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.`", "0.9018419561789777`", RowBox[{"-", "0.9018420117593442`"}]} }, GridBoxAlignment->{ "Columns" -> {{Center}}, "ColumnsIndexed" -> {}, "Rows" -> {{Baseline}}, "RowsIndexed" -> {}}, GridBoxSpacings->{"Columns" -> { Offset[0.27999999999999997`], { Offset[0.7]}, Offset[0.27999999999999997`]}, "ColumnsIndexed" -> {}, "Rows" -> { Offset[0.2], { Offset[0.4]}, Offset[0.2]}, "RowsIndexed" -> {}}], "\[NoBreak]", ")"}], Function[BoxForm`e$, MatrixForm[BoxForm`e$]]]], "Output", CellChangeTimes->{3.686628465595498*^9, 3.6866287112672625`*^9}] }, Open ]] }, Open ]], Cell[CellGroupData[{ Cell["\<\ Hamiltonian Close to Uniform Coupling, Makes W State\ \>", "Section", CellChangeTimes->{{3.68544444483677*^9, 3.6854444454295716`*^9}, { 3.6854444847728405`*^9, 3.6854444960360603`*^9}}], Cell[CellGroupData[{ Cell["\<\ Consider a chain of arbitrary length. We can create any state that we want to \ arbitrary accuracy in the single excitation subspace provided the amplitudes \ are real and do not contain consecutive zeros. The more accurate you want the evolution, the longer you have to wait (in \ general). However, there is a maximum value of \[Epsilon] that should be \ considered: \[Epsilon] should be less than the smallest eigenvalue gap in the \ chain to be perturbed (otherwise the effect of \[Epsilon] is not a \ perturbation, and the ordering of eigenvalues will be messed up).\ \>", "Text", CellGroupingRules->{GroupTogetherGrouping, 10000.}, CellChangeTimes->{{3.6482778575437317`*^9, 3.648278104367197*^9}, { 3.6482781843639975`*^9, 3.648278186672797*^9}, {3.6482782324431973`*^9, 3.648278347837912*^9}, {3.648278730001915*^9, 3.648278757707692*^9}, { 3.6482940231707335`*^9, 3.6482940297071447`*^9}, {3.6483053360191145`*^9, 3.6483053788411894`*^9}, 3.685444421265129*^9, 3.6866284992915573`*^9}], Cell[BoxData[{ RowBox[{ RowBox[{"size", "=", "51"}], ";"}], "\[IndentingNewLine]", RowBox[{ RowBox[{"inputsite", "=", "1"}], ";"}], "\[IndentingNewLine]", RowBox[{ RowBox[{ RowBox[{"initstate", "=", RowBox[{"Table", "[", RowBox[{ RowBox[{"KroneckerDelta", "[", RowBox[{"n", ",", "inputsite"}], "]"}], ",", RowBox[{"{", RowBox[{"n", ",", "1", ",", "size"}], "}"}]}], "]"}]}], ";"}], "\[IndentingNewLine]", RowBox[{"(*", RowBox[{ RowBox[{ "Target", " ", "state", " ", "must", " ", "be", " ", "a", " ", "real"}], ",", " ", RowBox[{"vector", " ", "of", " ", "length", " ", RowBox[{"N", ".", " ", "Cannot"}], " ", "have", " ", "2", " ", "consecutive", " ", "0", " ", RowBox[{"amplitudes", ".", " ", "First"}], " ", "and", " ", "last", " ", "elements", " ", "must", " ", "not", " ", "be", " ", "0.", " ", RowBox[{"(", RowBox[{"strictly", ",", " ", RowBox[{ "this", " ", "appiles", " ", "to", " ", "target2", " ", "not", " ", "targetstate"}]}], ")"}]}]}], " ", "*)"}]}], "\[IndentingNewLine]", RowBox[{ RowBox[{"targetstate", "=", RowBox[{"Table", "[", RowBox[{"1", ",", RowBox[{"{", "size", "}"}]}], "]"}]}], ";", RowBox[{"(*", RowBox[{"W", " ", "state", " ", "is", " ", "a", " ", "good", " ", RowBox[{"example", "."}]}], " ", "*)"}], "\[IndentingNewLine]", RowBox[{"(*", RowBox[{ RowBox[{"targetstate", "=", RowBox[{"Join", "[", RowBox[{ RowBox[{"Table", "[", RowBox[{"1", ",", RowBox[{"{", RowBox[{ RowBox[{"(", RowBox[{"mid", "-", "1"}], ")"}], "/", "2"}], "}"}]}], "]"}], ",", RowBox[{"{", "3", "}"}], ",", RowBox[{"Table", "[", RowBox[{"2", ",", RowBox[{"{", RowBox[{ RowBox[{"(", RowBox[{"mid", "-", "1"}], ")"}], "/", "2"}], "}"}]}], "]"}]}], "]"}]}], ";"}], "*)"}], " ", RowBox[{"(*", RowBox[{"asymmetric", " ", "example"}], "*)"}], "\[IndentingNewLine]", RowBox[{"(*", RowBox[{ RowBox[{"targetstate", "=", RowBox[{"RandomReal", "[", RowBox[{ RowBox[{"{", RowBox[{"0.5", ",", "1"}], "}"}], ",", "mid"}], "]"}]}], ";"}], "*)"}], RowBox[{"(*", RowBox[{ RowBox[{"random", " ", "example"}], ",", " ", RowBox[{"fully", " ", "asymmetric"}]}], "*)"}], "\[IndentingNewLine]", RowBox[{"targetstate", "=", RowBox[{"targetstate", "/", SqrtBox[ RowBox[{"targetstate", ".", "targetstate"}]]}]}], ";"}], "\[IndentingNewLine]", RowBox[{ RowBox[{"If", "[", RowBox[{ RowBox[{ RowBox[{"Length", "[", "targetstate", "]"}], "\[NotEqual]", "size"}], ",", RowBox[{ RowBox[{"Print", "[", "\"\\"", "]"}], ";", " ", RowBox[{"Abort", "[", "]"}]}]}], "]"}], ";"}], "\[IndentingNewLine]", RowBox[{ RowBox[{ RowBox[{"target2", "=", RowBox[{ RowBox[{"(", RowBox[{"initstate", "-", "targetstate"}], ")"}], "/", SqrtBox[ RowBox[{"2", RowBox[{"(", RowBox[{"1", "-", RowBox[{"targetstate", "[", RowBox[{"[", "1", "]"}], "]"}]}], ")"}]}]]}]}], ";"}], "\[IndentingNewLine]", RowBox[{"(*", RowBox[{ RowBox[{"fix", " ", "all", " ", "coupling", " ", "strengths", " ", RowBox[{"equal", ".", " ", "Magnetic"}], " ", "fields", " ", "determined", " ", "by", " ", "requirement", " ", "of", " ", "specific", " ", "zero", " ", "eigenvector"}], ",", " ", "target2"}], "*)"}]}], "\[IndentingNewLine]", RowBox[{ RowBox[{ RowBox[{"J", "[", "1", "]"}], "=", "1"}], ";"}], "\[IndentingNewLine]", RowBox[{ RowBox[{ RowBox[{"B", "[", "1", "]"}], "=", RowBox[{ RowBox[{"-", RowBox[{"target2", "[", RowBox[{"[", "2", "]"}], "]"}]}], "/", RowBox[{"target2", "[", RowBox[{"[", "1", "]"}], "]"}]}]}], ";"}], "\[IndentingNewLine]", RowBox[{ RowBox[{"For", "[", RowBox[{ RowBox[{"idx", "=", "2"}], ",", RowBox[{"idx", "<=", RowBox[{"size", "-", "1"}]}], ",", RowBox[{"idx", "++"}], ",", "\[IndentingNewLine]", RowBox[{ RowBox[{"If", "[", RowBox[{ RowBox[{ RowBox[{"target2", "[", RowBox[{"[", "idx", "]"}], "]"}], "\[Equal]", "0"}], ",", "\[IndentingNewLine]", RowBox[{ RowBox[{ RowBox[{"B", "[", "idx", "]"}], "=", "0"}], ";", " ", RowBox[{ RowBox[{"J", "[", "idx", "]"}], "=", RowBox[{ RowBox[{"-", RowBox[{"target2", "[", RowBox[{"[", RowBox[{"idx", "-", "1"}], "]"}], "]"}]}], RowBox[{ RowBox[{"J", "[", RowBox[{"idx", "-", "1"}], "]"}], "/", RowBox[{"target2", "[", RowBox[{"[", RowBox[{"idx", "+", "1"}], "]"}], "]"}]}]}]}]}], ",", "\[IndentingNewLine]", RowBox[{ RowBox[{ RowBox[{"J", "[", "idx", "]"}], "=", "1"}], ";", " ", RowBox[{ RowBox[{"B", "[", "idx", "]"}], "=", RowBox[{ RowBox[{"-", RowBox[{"(", RowBox[{ RowBox[{ RowBox[{"J", "[", RowBox[{"idx", "-", "1"}], "]"}], RowBox[{"target2", "[", RowBox[{"[", RowBox[{"idx", "-", "1"}], "]"}], "]"}]}], "+", RowBox[{"target2", "[", RowBox[{"[", RowBox[{"idx", "+", "1"}], "]"}], "]"}]}], ")"}]}], "/", RowBox[{"target2", "[", RowBox[{"[", "idx", "]"}], "]"}]}]}]}]}], "\[IndentingNewLine]", "]"}], ";"}]}], "\[IndentingNewLine]", "]"}], ";"}], "\[IndentingNewLine]", RowBox[{ RowBox[{ RowBox[{"B", "[", "size", "]"}], "=", RowBox[{ RowBox[{"-", RowBox[{"J", "[", RowBox[{"size", "-", "1"}], "]"}]}], RowBox[{ RowBox[{"target2", "[", RowBox[{"[", RowBox[{"size", "-", "1"}], "]"}], "]"}], "/", RowBox[{"target2", "[", RowBox[{"[", "size", "]"}], "]"}]}]}]}], ";"}], "\[IndentingNewLine]", RowBox[{ RowBox[{"couplings", "=", RowBox[{"Table", "[", RowBox[{ RowBox[{"J", "[", "n", "]"}], ",", RowBox[{"{", RowBox[{"n", ",", "1", ",", RowBox[{"size", "-", "1"}]}], "}"}]}], "]"}]}], ";"}], "\[IndentingNewLine]", RowBox[{ RowBox[{"targetham", "=", RowBox[{ RowBox[{"FullSimplify", "[", RowBox[{ RowBox[{"DiagonalMatrix", "[", RowBox[{"couplings", ",", "1"}], "]"}], "+", RowBox[{"DiagonalMatrix", "[", RowBox[{"couplings", ",", RowBox[{"-", "1"}]}], "]"}]}], "]"}], "+", RowBox[{"DiagonalMatrix", "[", RowBox[{"Table", "[", RowBox[{ RowBox[{"B", "[", "n", "]"}], ",", RowBox[{"{", RowBox[{"n", ",", "1", ",", "size"}], "}"}]}], "]"}], "]"}]}]}], ";", " ", RowBox[{"(*", RowBox[{ RowBox[{ "this", " ", "has", " ", "the", " ", "correct", " ", "0", " ", "eigenvector"}], ",", " ", RowBox[{ "but", " ", "other", " ", "eigenvalues", " ", "are", " ", "imperfect"}]}], "*)"}], "\[IndentingNewLine]", RowBox[{"targetEV", "=", RowBox[{"Chop", "[", RowBox[{"Eigenvalues", "[", RowBox[{"N", "[", RowBox[{"targetham", ",", "100"}], "]"}], "]"}], "]"}]}], ";"}], "\[IndentingNewLine]", RowBox[{ RowBox[{"evectors", "=", RowBox[{"Eigenvectors", "[", RowBox[{"N", "[", RowBox[{"targetham", ",", "100"}], "]"}], "]"}]}], ";"}], "\[IndentingNewLine]", RowBox[{ RowBox[{ RowBox[{"evectors", "=", RowBox[{"Chop", "[", RowBox[{"evectors", "/", SqrtBox[ RowBox[{"Diagonal", "[", RowBox[{"evectors", ".", RowBox[{"Transpose", "[", "evectors", "]"}]}], "]"}]]}], "]"}]}], ";"}], "\[IndentingNewLine]", RowBox[{"(*", RowBox[{ "experiment", " ", "with", " ", "new", " ", "heuristics", " ", "for", " ", "picking", " ", "best", " ", "eigenvalue", " ", "gap"}], "*)"}]}], "\[IndentingNewLine]", RowBox[{ RowBox[{ RowBox[{"gap", "=", RowBox[{"Min", "[", RowBox[{ RowBox[{"Rest", "[", RowBox[{"Sort", "[", RowBox[{"Most", "[", "targetEV", "]"}], "]"}], "]"}], "-", RowBox[{"Most", "[", RowBox[{"Sort", "[", RowBox[{"Most", "[", "targetEV", "]"}], "]"}], "]"}]}], "]"}]}], ";", " ", RowBox[{"(*", RowBox[{ "find", " ", "eigenvalue", " ", "gaps", " ", "when", " ", "0", " ", "is", " ", RowBox[{"removed", ".", " ", "Work"}], " ", "in", " ", "truncation", " ", "range", " ", "between", " ", RowBox[{"1", "/", "100"}], " ", "and", " ", RowBox[{"1", "/", "80"}]}], " ", "*)"}], "\[IndentingNewLine]", RowBox[{"\[Epsilon]", "=", RowBox[{"x", "/.", RowBox[{ RowBox[{"NMinimize", "[", RowBox[{ RowBox[{"{", RowBox[{ RowBox[{"Total", "[", RowBox[{ RowBox[{"Abs", "[", RowBox[{ RowBox[{"(", RowBox[{ RowBox[{"Round", "[", RowBox[{ RowBox[{"Most", "[", "targetEV", "]"}], ",", "x"}], "]"}], "+", RowBox[{ RowBox[{"(", RowBox[{"x", "/", "2"}], ")"}], " ", RowBox[{"Sign", "[", RowBox[{"Most", "[", "targetEV", "]"}], "]"}]}], "-", RowBox[{"Most", "[", "targetEV", "]"}]}], ")"}], "/", RowBox[{"(", RowBox[{ RowBox[{"Most", "[", "targetEV", "]"}], "x"}], ")"}]}], "]"}], "^", "2"}], "]"}], ",", RowBox[{ RowBox[{"gap", "/", "100"}], "\[LessEqual]", "x", "\[LessEqual]", RowBox[{"gap", "/", "80"}]}]}], "}"}], ",", "x", ",", RowBox[{"WorkingPrecision", "\[Rule]", "100"}], ",", RowBox[{"MaxIterations", "\[Rule]", "500"}]}], "]"}], "[", RowBox[{"[", RowBox[{"2", ",", "1"}], "]"}], "]"}]}]}], ";"}], "\[IndentingNewLine]", RowBox[{"(*", RowBox[{"accuracy", " ", "parameter"}], "*)"}]}], "\[IndentingNewLine]", RowBox[{ RowBox[{"Print", "[", RowBox[{"\"\\"", ",", RowBox[{"N", "[", RowBox[{"\[Epsilon]", ",", "10"}], "]"}]}], "]"}], ";"}], "\[IndentingNewLine]", RowBox[{ RowBox[{ RowBox[{"oddEV", "=", RowBox[{ RowBox[{"Round", "[", RowBox[{ RowBox[{"Most", "[", "targetEV", "]"}], ",", "\[Epsilon]"}], "]"}], "+", RowBox[{ RowBox[{"(", RowBox[{"\[Epsilon]", "/", "2"}], ")"}], " ", RowBox[{"Sign", "[", RowBox[{"Most", "[", "targetEV", "]"}], "]"}]}]}]}], ";", " ", RowBox[{"(*", RowBox[{ "nudge", " ", "the", " ", "negative", " ", "symmetric", " ", "eigenvalues"}], "*)"}], "\[IndentingNewLine]", RowBox[{"targetEV", "=", RowBox[{"Append", "[", RowBox[{"oddEV", ",", "0"}], "]"}]}], ";"}], "\[IndentingNewLine]"}], "\[IndentingNewLine]", RowBox[{ RowBox[{"S", "=", RowBox[{"Table", "[", RowBox[{ RowBox[{"KroneckerDelta", "[", RowBox[{"n", ",", RowBox[{"size", "+", "1", "-", "m"}]}], "]"}], ",", RowBox[{"{", RowBox[{"n", ",", "1", ",", "size"}], "}"}], ",", RowBox[{"{", RowBox[{"m", ",", "1", ",", "size"}], "}"}]}], "]"}]}], ";"}], "\[IndentingNewLine]", RowBox[{ RowBox[{ RowBox[{"If", "[", RowBox[{ RowBox[{ RowBox[{"S", ".", "target2"}], "\[Equal]", "target2"}], ",", "\[IndentingNewLine]", RowBox[{"(*", RowBox[{"symetric", " ", "case"}], "*)"}], "\[IndentingNewLine]", RowBox[{ RowBox[{ RowBox[{"f", "[", "x_", "]"}], ":=", RowBox[{"Times", "@@", RowBox[{"(", RowBox[{"x", "-", "targetEV"}], ")"}]}]}], ";", "\[IndentingNewLine]", RowBox[{"vec", "=", RowBox[{"Table", "[", RowBox[{ RowBox[{"1", "/", RowBox[{"Sqrt", "[", RowBox[{ RowBox[{"f", "'"}], "[", "q", "]"}], "]"}]}], ",", RowBox[{"{", RowBox[{"q", ",", "targetEV"}], "}"}]}], "]"}]}], ";", "\[IndentingNewLine]", RowBox[{"newEvectors", "=", RowBox[{"{", RowBox[{"vec", "/", SqrtBox[ RowBox[{"vec", ".", "vec"}]]}], "}"}]}], ";"}], "\[IndentingNewLine]", ",", "\[IndentingNewLine]", RowBox[{ RowBox[{"newEvectors", "=", RowBox[{"{", RowBox[{"evectors", "[", RowBox[{"[", RowBox[{"All", ",", "1"}], "]"}], "]"}], "}"}]}], ";"}]}], "\[IndentingNewLine]", "]"}], ";"}], "\[IndentingNewLine]", RowBox[{"(*", RowBox[{ "start", " ", "the", " ", "inverse", " ", "eigenvalue", " ", "algorithm"}], "*)"}]}], "\[IndentingNewLine]", RowBox[{ RowBox[{"newEvectors", "=", RowBox[{"{", RowBox[{"evectors", "[", RowBox[{"[", RowBox[{"All", ",", "1"}], "]"}], "]"}], "}"}]}], ";"}], "\[IndentingNewLine]", RowBox[{ RowBox[{ RowBox[{"{", RowBox[{"couplings", ",", "fields"}], "}"}], "=", RowBox[{"SolveIEP", "[", RowBox[{"targetEV", ",", RowBox[{ RowBox[{"newEvectors", "[", RowBox[{"[", "1", "]"}], "]"}], "^", "2"}]}], "]"}]}], ";"}], "\[IndentingNewLine]", RowBox[{ RowBox[{"Print", "[", RowBox[{"\"\\"", ",", RowBox[{"N", "[", RowBox[{ RowBox[{"Min", "[", "couplings", "]"}], ",", "6"}], "]"}], ",", "\"\< to \>\"", ",", RowBox[{"N", "[", RowBox[{ RowBox[{"Max", "[", "couplings", "]"}], ",", "6"}], "]"}]}], "]"}], ";"}], "\[IndentingNewLine]", RowBox[{ RowBox[{"finalham", "=", RowBox[{ RowBox[{"CreateTriDiagonal", "[", RowBox[{"{", RowBox[{"couplings", ",", "fields"}], "}"}], "]"}], "+", RowBox[{ RowBox[{"IdentityMatrix", "[", "size", "]"}], RowBox[{"\[Epsilon]", "/", "2"}]}]}]}], ";"}], "\[IndentingNewLine]", RowBox[{ RowBox[{ "Print", "[", "\"\