(************** Content-type: application/mathematica ************** CreatedBy='Mathematica 5.0' Mathematica-Compatible Notebook This notebook can be used with any Mathematica-compatible application, such as Mathematica, MathReader or Publicon. The data for the notebook starts with the line containing stars above. To get the notebook into a Mathematica-compatible application, do one of the following: * Save the data starting with the line of stars above into a file with a name ending in .nb, then open the file inside the application; * Copy the data starting with the line of stars above to the clipboard, then use the Paste menu command inside the application. Data for notebooks contains only printable 7-bit ASCII and can be sent directly in email or through ftp in text mode. Newlines can be CR, LF or CRLF (Unix, Macintosh or MS-DOS style). NOTE: If you modify the data for this notebook not in a Mathematica- compatible application, you must delete the line below containing the word CacheID, otherwise Mathematica-compatible applications may try to use invalid cache data. For more information on notebooks and Mathematica-compatible applications, contact Wolfram Research: web: http://www.wolfram.com email: info@wolfram.com phone: +1-217-398-0700 (U.S.) Notebook reader applications are available free of charge from Wolfram Research. *******************************************************************) (*CacheID: 232*) (*NotebookFileLineBreakTest NotebookFileLineBreakTest*) (*NotebookOptionsPosition[ 10227, 256]*) (*NotebookOutlinePosition[ 10873, 278]*) (* CellTagsIndexPosition[ 10829, 274]*) (*WindowFrame->Normal*) Notebook[{ Cell[CellGroupData[{ Cell["45-degree square gas experiment", "Subsection"], Cell["\<\ Consider a single 45-degree rotated square in an N by M octagon. I want to \ count for each lattice site the number of ways that the rotated square might \ end up in this cell. I will paths that would end at this site for the \ 45-degree rhombus strings and multiply.\ \>", "Text"], Cell[BoxData[{ \(\(Width\ = \ 5;\)\), "\[IndentingNewLine]", \(\(Height\ = \ 4;\)\)}], "Input"], Cell["\<\ The Gessel-Viennot algorithm is actually unnecessary here. I use simple \ combinations.\ \>", "Text"], Cell[BoxData[ \(\(\(CountAll[j_, \ i_]\ := \ Binomial[\((\ i - 1)\)\ + \((\ j - 1)\), \((\ j - 1)\)]\ Binomial[\((Height\ - j)\) + \((i\ - \ 1)\), \ \((i\ - \ 1)\)]\ Binomial[\((\ Width\ - \ i)\)\ + \((\ j - 1)\), \((\ j - 1)\)]\ \ Binomial[\((\ Width\ - \ i)\)\ + \((Height\ - \ j)\), \((Height\ - \ j)\)]\ ;\)\(\[IndentingNewLine]\) \)\)], "Input"], Cell[CellGroupData[{ Cell[BoxData[ \(MatrixForm[Array[CountAll, {Height, \ Width}]]\)], "Input"], Cell[BoxData[ TagBox[ RowBox[{"(", "\[NoBreak]", GridBox[{ {"35", "80", "100", "80", "35"}, {"75", "240", "324", "240", "75"}, {"75", "240", "324", "240", "75"}, {"35", "80", "100", "80", "35"} }], "\[NoBreak]", ")"}], Function[ BoxForm`e$, MatrixForm[ BoxForm`e$]]]], "Output"] }, Open ]], Cell["\<\ This represents the number of distinct choices of the four 45-degree rhombus \ strings that can leave the single 45-degree rotated square at this site, \ indicating the degree of repulsion from nearby hard walls.\ \>", "Text"] }, Open ]], Cell[CellGroupData[{ Cell["Implementation of Destinville's formula for Octagon tilings", \ "Subsection"], Cell["\<\ This is a very, very brute force algorithm. The key to doing it properly \ lies in the enumeration of the squares.\ \>", "Text"], Cell[BoxData[{ \(BinomialConvention[a_, \ b_]\ := \ If[Or[a\ < \ 0, \ b\ < \ 0, \ b\ > \ a], \ 0, \ Binomial[a, \ b]]\), "\[IndentingNewLine]", \(\(GetConventionX[x_, i_, \ j_, a_, b_, c_, d_]\ := \ If[Or[j \[Equal] 0, \ i\ \[Equal] \ 0], \ 0, If[Or[i \[Equal] b + 1, j \[Equal] d + 1], \ a, \(x[\([i]\)]\)[\([j]\)]]];\)\), "\[IndentingNewLine]", \(\(GetConventionY[y_, i_, \ j_, a_, b_, c_, d_]\ := \ If[Or[j \[Equal] 0, \ i\ \[Equal] \ b + 1], \ 0, If[Or[i \[Equal] 0, j \[Equal] d + 1], \ c, \(y[\([i]\)]\)[\([j]\)]]];\)\), "\[IndentingNewLine]", \(M[u_, \ x_, \ y_, a_, b_, c_, d_, \ i_, \ j_]\ := \ BinomialConvention[\ GetConventionX[x, j, u, a, b, c, d]\ - \ GetConventionX[x, i, u - 1, a, b, c, d]\ \ + \ GetConventionY[y, j, u, a, b, c, d]\ - \ GetConventionY[y, i, u - 1, a, b, c, d], \ GetConventionX[x, j, u, a, b, c, d]\ - GetConventionX[x, i, u - 1, a, b, c, d]\ \ + \ j\ - \ i]; P[v_, \ x_, \ y_, a_, b_, c_, d_, \ i_, \ j_]\ := \ BinomialConvention[ GetConventionX[x, v, j, a, b, c, d]\ - \ GetConventionX[x, v - 1, i, a, b, c, d]\ + GetConventionY[y, v - 1, i, a, b, c, d] - \ GetConventionY[y, v, j, a, b, c, d], \ GetConventionX[x, v, j, a, b, c, d]\ - \ GetConventionX[x, v - 1, i, a, b, c, d]\ + \ j\ - \ i];\), "\[IndentingNewLine]", \(\(DeterminantM[u_, \ x_, \ y_, a_, b_, c_, d_]\ := Det[\(\(\(\(\(\(\(Array[ M, \ {1, \ 1, \ 1, 1, 1, 1, 1, b, b}, \ {u, \ x, y, a, b, c, d, \ 1, \ 1}]\)[\([1]\)]\)[\([1]\)]\)[\([1]\)]\)[\([1]\)]\)[\ \([1]\)]\)[\([1]\)]\)[\([1]\)]]\ ;\)\), "\[IndentingNewLine]", \(\(DeterminantP[v_, \ x_, \ y_, a_, b_, c_, d_]\ := \ Det[\(\(\(\(\(\(\(Array[ P, \ {1, \ 1, \ 1, 1, 1, 1, 1, d, d}, \ {v, \ x, y, a, b, c, d, \ 1, \ 1}]\)[\([1]\)]\)[\([1]\)]\)[\([1]\)]\)[\([1]\)]\)[\ \([1]\)]\)[\([1]\)]\)[\([1]\)]]\ ;\)\), "\[IndentingNewLine]", \(\(PathProduct[x_, \ y_, a_, b_, c_, d_] := \((\[Product]\+\(u = 1\)\%\(d + 1\)DeterminantM[u, \ x, \ y, a, b, c, d]\ )\) \((\[Product]\+\(v = 1\)\%\(b + 1\)DeterminantP[v, \ x, \ y, a, b, c, d]\ )\);\)\)}], "Input"], Cell[TextData[{ "\nThis should define the necessary prerequisites to get the path product: \ now I must sum over all chocies of x and y arrays. The items in x run from 0 \ to a, and the items in y run from 0 to c. They also must satisfy the \ conditions from Destainville's paper. This is then an inherently brutal \ algorithm that I will deal with in a brutal way. \n\nFirst, I need to know \ if my selected X and Y are actually in the appropriate cross-product space. \ \n\nThere is a faster algorithm to check this: I could hypothetically check \ in N time, but it's harder to program in ", StyleBox["Mathematica", FontSlant->"Italic"], " than C++ since in ", StyleBox["Mathematica", FontSlant->"Italic"], " I must nest everything in parameters." }], "Text"], Cell[BoxData[{ \(\(ValidX[inMatrix_, \ b_, d_]\ := For[i = 1, i \[LessEqual] b, \ \(i++\), For[j = 1, j \[LessEqual] d, \(j++\), \ For[k = i, k \[LessEqual] b, \(k++\), \ For[l = j, l \[LessEqual] d, \(l++\), \ If[\(inMatrix[\([i]\)]\)[\([j]\)]\ > \ \ \(inMatrix[\([k]\)]\)[\([l]\)], \ Return[False]]]]]; \ If[i \[Equal] b, Return[True]]];\)\), "\[IndentingNewLine]", \(\(ValidY[inMatrix_, \ b_, d_]\ := For[i = 1, i \[LessEqual] b, \ \(i++\), For[j = 1, j \[LessEqual] d, \(j++\), \ For[k = i, k > 0, \(k--\), \ For[l = j, l \[LessEqual] d, \(l++\), \ If[\(inMatrix[\([i]\)]\)[\([j]\)]\ > \ \ \(inMatrix[\([k]\)]\)[\([l]\)], \ Return[False]]]]]; \ If[i \[Equal] b, Return[True]]];\)\)}], "Input"], Cell["\<\ Now I need to actually construct all possible matrices (b by d), x having \ values 0 through a, y having values 0 through c.\ \>", "Text"], Cell[BoxData[{ \(\(Zero[i_, \ j_]\ := \ 0;\)\), "\[IndentingNewLine]", \(\(ForAllMatricesX[px_, \ py_, inMatrix_, \ a_, b_, c_, d_]\ := \ If[And[px \[Equal] b, \ py \[Equal] d + 1], If[ValidX[inMatrix\ , b, d], \ Return[\ ForAllMatricesY[1, \ 1, \ inMatrix, \ Array[Zero, \ {b, \ d}], \ a, \ b, \ c, \ d]], \ \ Return[ 0]], \ If[And[px\ < \ b, \ py\ \[Equal] \ d\ + \ 1]\ , \ Return[ForAllMatricesX[px\ + \ 1, \ 1, \ inMatrix\ , \ \ a, \ b, \ c, \ d]], \[Sum]\+\(n = 0\)\%a ForAllMatricesX[px, \ py\ + \ 1, \ inMatrix + \ SparseArray[{{px, \ py}}\ \[Rule] \ {n}, \ {b, d}], \ \ a, \ b, \ c, \ d]\ ]];\)\), "\[IndentingNewLine]", \(\(ForAllMatricesY[px_, \ py_, inMatrixX_, \ inMatrix_, \ a_, b_, c_, d_]\ := \ If[And[px \[Equal] b, \ py \[Equal] d + 1], If[ValidY[inMatrix\ , b, d], \ Return[\ PathProduct[inMatrixX, \ inMatrix, a, b, c, d]], \ \ Return[0]], \ If[And[px\ < \ b, \ py\ \[Equal] \ d\ + \ 1]\ , \ Return[ForAllMatricesY[px\ + \ 1, \ 1, \ inMatrixX, \ inMatrix\ , \ \ a, \ b, \ c, \ d]], \[Sum]\+\(n = 0\)\%c ForAllMatricesY[px, \ py\ + \ 1, inMatrixX, \ \ inMatrix + \ SparseArray[{{px, \ py}}\ \[Rule] \ {n}, \ {b, d}], \ \ a, \ b, \ c, \ d]\ ]];\)\)}], "Input"], Cell[BoxData[ \(\(\(\[IndentingNewLine]\)\(T[a_, \ b_, c_, d_]\ := ForAllMatricesX[1, \ 1, Array[Zero, \ {b, \ d}], \ a, b, c, d];\)\)\)], "Input"], Cell[CellGroupData[{ Cell[BoxData[ \(\(\(\[IndentingNewLine]\)\(T[1, 1, 1, 1]\[IndentingNewLine] T[2, 2, 2, 2]\[IndentingNewLine] T[2, 2, 2, 1]\)\)\)], "Input"], Cell[BoxData[ \(8\)], "Output"], Cell[BoxData[ \(5383\)], "Output"], Cell[BoxData[ \(480\)], "Output"] }, Open ]] }, Open ]] }, FrontEndVersion->"5.0 for Microsoft Windows", ScreenRectangle->{{0, 1280}, {0, 955}}, WindowSize->{804, 740}, WindowMargins->{{Automatic, 126}, {73, Automatic}} ] (******************************************************************* Cached data follows. If you edit this Notebook file directly, not using Mathematica, you must remove the line containing CacheID at the top of the file. The cache data will then be recreated when you save this file from within Mathematica. *******************************************************************) (*CellTagsOutline CellTagsIndex->{} *) (*CellTagsIndex CellTagsIndex->{} *) (*NotebookFileOutline Notebook[{ Cell[CellGroupData[{ Cell[1776, 53, 53, 0, 38, "Subsection"], Cell[1832, 55, 293, 5, 52, "Text"], Cell[2128, 62, 106, 2, 50, "Input"], Cell[2237, 66, 111, 3, 33, "Text"], Cell[2351, 71, 478, 9, 70, "Input"], Cell[CellGroupData[{ Cell[2854, 84, 79, 1, 30, "Input"], Cell[2936, 87, 363, 9, 73, "Output"] }, Open ]], Cell[3314, 99, 237, 5, 71, "Text"] }, Open ]], Cell[CellGroupData[{ Cell[3588, 109, 83, 1, 38, "Subsection"], Cell[3674, 112, 140, 4, 52, "Text"], Cell[3817, 118, 2543, 45, 493, "Input"], Cell[6363, 165, 785, 15, 185, "Text"], Cell[7151, 182, 862, 16, 210, "Input"], Cell[8016, 200, 148, 3, 33, "Text"], Cell[8167, 205, 1562, 26, 362, "Input"], Cell[9732, 233, 172, 3, 50, "Input"], Cell[CellGroupData[{ Cell[9929, 240, 151, 3, 90, "Input"], Cell[10083, 245, 35, 1, 29, "Output"], Cell[10121, 248, 38, 1, 29, "Output"], Cell[10162, 251, 37, 1, 29, "Output"] }, Open ]] }, Open ]] } ] *) (******************************************************************* End of Mathematica Notebook file. *******************************************************************)