Examples for the use of RTNI discussed in the paper

SetDirectory[NotebookDirectory[]];
<<RTNI`

Example: Creation of Figure 3 in main paper

e1={{"U",1,"out",1},{"U",2,"out",1}}
e2={{"U",1,"in",1},{"A",1,"out",1}}
e3={{"U",2,"in",1},{"A",1,"out",2}}
g={e1,e2,e3};
visualizeTN[g]
Export["visualizeTNnoedgelabels.pdf",%]
visualizeTN[g,{EdgeLabeling->True}]
Export["visualizeTNedgelabels.pdf",%]

Example 6.1: Twirling a matrix

e1={{"U",1,"out",1},{"X",1,"in",1}};
e2={{"Y",1,"out",1},{"U",1,"in",1}};
e3={{"U*",1,"out",1},{"Y",1,"in",1}};
e4={{"X",1,"out",1},{"U*",1,"in",1}};
g={e1,e2,e3,e4}
visualizeTN[g]
(* alternative: visualizeTN[{{g,1}},{EdgeLabeling->True}]*)
Export["TrXUYUstar.pdf",%]
Eg=integrateHaarUnitary[g,"U",{d},{d},d];
visualizeTN[Eg]
Export["ETrXUYUstar.pdf",%]

e1={{"U",1,"out",1},{"X",1,"in",1}};
e2={{"Y",1,"out",1},{"U",1,"in",1}};
e3={{"U*",1,"out",1},{"Y",1,"in",1}};
g={e1,e2,e3}
Eg=integrateHaarUnitary[g,"U",{d},{d},d]
visualizeTN[g]
Export["XUYUstar.pdf",%]
visualizeTN[Eg]
Export["EXUYUstar.pdf",%]

Example 6.2: Several tensor factors

e1={{"A",1,"out",1},{"U",1,"in",1}};
e2={{"A",1,"out",2},{"U",1,"in",2}};
e3={{"U*",1,"out",1},{"A",1,"in",1}};
e4={{"U*",1,"out",2},{"A",1,"in",2}};
e5={{"U",1,"out",2}, {"U*",1,"in",2}};
g={e1,e2,e3,e4,e5}
Eg=integrateHaarUnitary[g,"U",{n,k},{n,k},n k]
visualizeTN[g]
Export["id-Tr-UU-A-UstarUstar.pdf",%]
visualizeTN[Eg]
Export["E-id-Tr-UU-A-UstarUstar.pdf",%]

Example 6.3: Bi-partite twirling

e1={{"X",1,"out",1},{"U",1,"in",1}};
e2={{"U*",1,"out",1},{"X",1,"in",1}};
e3={{"X",1,"out",2},{"U",2,"in",1}};
e4={{"U*",2,"out",1},{"X",1,"in",2}};
g={e1,e2,e3,e4}
visualizeTN[g]
Export["twirl.pdf",%]
integrateHaarUnitary[g,"U",{d},{d},d]
visualizeTN[%,EdgeLabeling->True]
Export["E-twirl.pdf",%]

Example 6.4: Bell state as input in conjugate random quantum channels

e1={{"U*",2,"out",1},{"U",1,"in",1}};
e2={{"U*",1,"out",1},{"U",2,"in",1}};
e3={{"U",1,"out",1},{"U*",1,"in",1}};
e4={{"U",2,"out",1},{"U*",2,"in",1}};
e5={{"U",1,"out",2},{"U*",2,"in",2}};
e6={{"U",2,"out",2},{"U*",1,"in",2}};
g={e1,e2,e3,e4,e5,e6};
listg={{g,1/(d k)}};
Eg=integrateHaarUnitary[listg,"U",{d},{n,k},n k]
overlap=Eg[[1,2]];
overlapt=overlap/.{d->t n k};
Assuming[t>0&&k>1,Limit[overlapt,n->Infinity]]//Simplify

Example 6.5: Random tensor networks for holographic duality

(* see separate file examples_holographictensornetworks*)

Example 6.6: Computation of expectation values of matrix products

MultinomialexpectationvalueHaar[d,{1,2},{X,Y},True]

MultinomialexpectationvalueHaar[d,{1,3},{X,Y},False]

MultinomialexpectationvalueHaar[d,{2,3},{X,Y},False]

MultinomialexpectationvalueHaar[d,{1,4},{X,Y},True]

MultinomialexpectationvalueHaar[d,{1,2,3,4},{V,W,X,Y},False]

(* for additional examples for the use of MultinomialexpectationvalueHaar, see file examples_momentcalculator.nb*)