(* Content-type: application/vnd.wolfram.mathematica *) (*** Wolfram Notebook File ***) (* http://www.wolfram.com/nb *) (* CreatedBy='Mathematica 11.0' *) (*CacheID: 234*) (* Internal cache information: NotebookFileLineBreakTest NotebookFileLineBreakTest NotebookDataPosition[ 158, 7] NotebookDataLength[ 41021, 1014] NotebookOptionsPosition[ 39965, 977] NotebookOutlinePosition[ 40308, 992] CellTagsIndexPosition[ 40265, 989] WindowFrame->Normal*) (* Beginning of Notebook Content *) Notebook[{ Cell["\<\ The following is an incomplete set of functions to export Mathematica \ formulas to Python functions. While you could conceivably use simpy, I find \ that this is somewhat easier and does not require third-party libraries. It \ is also a useful example of how to manipulate Mathematica expressions with \ pattern matching.\ \>", "Text", CellChangeTimes->{{3.71480577394792*^9, 3.714805840251181*^9}}], Cell["\<\ The core routine is simply a loop that converts an expression to Python, \ preceding it with variable definitions that have been created along the \ process.\ \>", "Text", CellChangeTimes->{{3.7148058465391145`*^9, 3.7148058811393056`*^9}}], Cell[BoxData[{ RowBox[{ RowBox[{"Clear", "[", "ToPython", "]"}], ";"}], "\[IndentingNewLine]", RowBox[{ RowBox[{ RowBox[{"ToPython", "[", RowBox[{"expression_", ",", RowBox[{"extravars_:", RowBox[{"{", "}"}]}], ",", RowBox[{"outputvar_:", "\"\\""}], ",", RowBox[{"indent_:", "\"\<\>\""}]}], "]"}], ":=", "\[IndentingNewLine]", RowBox[{"Block", "[", RowBox[{ RowBox[{"{", "\[IndentingNewLine]", RowBox[{"(*", " ", RowBox[{ "Python", " ", "code", " ", "that", " ", "precedes", " ", "our", " ", RowBox[{"expression", ".", "\[IndentingNewLine]", " ", "Includes"}], " ", "auxiliary", " ", "vars", " ", "and", " ", "functions"}], " ", "*)"}], "\[IndentingNewLine]", RowBox[{ RowBox[{"PythonBuffer", "=", "\"\<\>\""}], ",", "\[IndentingNewLine]", RowBox[{"(*", " ", RowBox[{ "Last", " ", "number", " ", "of", " ", "defined", " ", "variable"}], " ", "*)"}], "\[IndentingNewLine]", RowBox[{"PythonVar", "=", "0"}], ",", "\[IndentingNewLine]", RowBox[{"(*", " ", RowBox[{ "Spaces", " ", "to", " ", "indent", " ", "each", " ", "line", " ", "of", " ", "Python", " ", "code"}], " ", "*)"}], "\[IndentingNewLine]", RowBox[{"PythonIndent", "=", "indent"}], ",", "\[IndentingNewLine]", RowBox[{"(*", " ", RowBox[{"Was", " ", RowBox[{"Sqrt", "[", "]"}], " ", RowBox[{"used", "?", " ", "Then"}], " ", "we", " ", "have", " ", "to", " ", "define", " ", "it"}], " ", "*)"}], "\[IndentingNewLine]", RowBox[{"PythonSqrt", "=", "False"}], ",", "\[IndentingNewLine]", RowBox[{"(*", " ", RowBox[{"Was", " ", "Pi", " ", RowBox[{"used", "?", " ", "We"}], " ", "define", " ", "\[Pi]", " ", "variable", " ", "in", " ", "Python"}], " ", "*)"}], "\[IndentingNewLine]", RowBox[{"PythonPi", "=", "False"}]}], "}"}], ",", "\[IndentingNewLine]", RowBox[{"(*", " ", RowBox[{ RowBox[{"We", " ", "begin", " ", "by", " ", RowBox[{"parsing", " ", "'"}], RowBox[{"extravars", "'"}], " ", "which", " ", "is", " ", "a", " ", "list", "\[IndentingNewLine]", RowBox[{"{", RowBox[{ RowBox[{"{", RowBox[{"var1", ",", " ", "exp1"}], "}"}], ",", RowBox[{"{", RowBox[{"var2", ",", "exp2"}], "}"}], ",", "..."}], "}"}], "\[IndentingNewLine]", "of", " ", "variables", " ", "that", " ", "are", " ", "used", " ", "in", " ", "our", " ", RowBox[{"formula", ".", " ", "This"}], " ", "is", " ", "used", " ", "for", "\[IndentingNewLine]", "simplifying", " ", "expressions"}], ",", " ", RowBox[{"as", " ", "shown", " ", "later", " ", RowBox[{"on", "."}]}]}], " ", "*)"}], "\[IndentingNewLine]", RowBox[{ RowBox[{"Do", "[", "\[IndentingNewLine]", RowBox[{ RowBox[{"Module", "[", RowBox[{ RowBox[{"{", RowBox[{ RowBox[{"var", "=", RowBox[{"def", "[", RowBox[{"[", "1", "]"}], "]"}]}], ",", RowBox[{"value", "=", RowBox[{"def", "[", RowBox[{"[", "2", "]"}], "]"}]}]}], "}"}], ",", "\[IndentingNewLine]", RowBox[{"PythonBuffer", "=", RowBox[{"PythonBuffer", "<>", "PythonIndent", "<>", RowBox[{"ToString", "[", "var", "]"}], "<>", "\"\<=\>\"", "<>", RowBox[{"ToPython2", "[", "value", "]"}], "<>", "\"\<;\\n\>\""}]}]}], "]"}], ",", "\[IndentingNewLine]", RowBox[{"{", RowBox[{"def", ",", "extravars"}], "}"}]}], "]"}], ";", "\[IndentingNewLine]", RowBox[{"(*", "\[IndentingNewLine]", " ", RowBox[{ RowBox[{ "The", " ", "actual", " ", "conversion", " ", "takes", " ", "place", " ", "here"}], ",", " ", RowBox[{ "recursively", "\[IndentingNewLine]", " ", "calling", " ", "the", " ", "function", " ", "ToPython2"}], ",", " ", RowBox[{"which", " ", "does", " ", "the", " ", RowBox[{"work", "."}]}]}], "\[IndentingNewLine]", " ", "*)"}], "\[IndentingNewLine]", RowBox[{"Module", "[", RowBox[{ RowBox[{"{", RowBox[{"aux", "=", RowBox[{"ToPython2", "[", "expression", "]"}]}], "}"}], ",", "\[IndentingNewLine]", RowBox[{"(*", " ", RowBox[{ RowBox[{"If", " ", RowBox[{"Sqrt", "[", "]"}], " ", "was", " ", "used"}], ",", " ", RowBox[{ "we", " ", "introduce", " ", "a", " ", "function", " ", "that", " ", "works", " ", "with", "\[IndentingNewLine]", " ", "complex", " ", "numbers"}], ",", " ", RowBox[{"since", " ", RowBox[{"np", ".", "sqrt"}], " ", "does", " ", "not"}]}], " ", "*)"}], "\[IndentingNewLine]", RowBox[{ RowBox[{"If", "[", RowBox[{"PythonSqrt", ",", "\[IndentingNewLine]", RowBox[{"PythonBuffer", "=", RowBox[{ "PythonIndent", "<>", "\"\\"", "<>", "PythonBuffer"}]}]}], "]"}], ";", "\[IndentingNewLine]", RowBox[{"(*", " ", RowBox[{ "Define", " ", "\[Pi]", " ", "as", " ", "a", " ", "Python", " ", "variable"}], " ", "*)"}], "\[IndentingNewLine]", RowBox[{"If", "[", RowBox[{"PythonPi", ",", "\[IndentingNewLine]", RowBox[{"PythonBuffer", "=", RowBox[{ "PythonIndent", "<>", "\"\<\[Pi]=math.pi;\\n\\n\>\"", "<>", "PythonBuffer"}]}]}], "]"}], ";", "\[IndentingNewLine]", RowBox[{"(*", " ", RowBox[{ "Output", " ", "Python", " ", "code", " ", "preceded", " ", "by", " ", "all", " ", "variable", " ", RowBox[{"definitions", "."}]}], " ", "*)"}], "\[IndentingNewLine]", RowBox[{ "PythonBuffer", "<>", "PythonIndent", "<>", "outputvar", "<>", "\"\<=\>\"", "<>", "aux", "<>", "\"\<;\\n\>\""}]}]}], "]"}]}]}], "]"}]}], ";"}]}], "Input", CellChangeTimes->{{3.714805863995676*^9, 3.714806071798952*^9}}], Cell["\<\ The following is a key piece of code. Essentially, PythonWrap converts an \ expression into Python. If that expression is too long, it is stored in an \ auxiliary variable. We do this to make the code more readable. It also takes \ care (in a very imperfect way) of parenthesis.\ \>", "Text", CellChangeTimes->{{3.714806076363162*^9, 3.714806131251169*^9}}], Cell[BoxData[{ RowBox[{ RowBox[{"Clear", "[", "ToPythonVar", "]"}], ";"}], "\[IndentingNewLine]", RowBox[{ RowBox[{ RowBox[{ RowBox[{"ToPythonVar", "[", "a_", "]"}], ":=", "\[IndentingNewLine]", RowBox[{"Module", "[", RowBox[{ RowBox[{"{", RowBox[{"name", "=", RowBox[{"\"\\"", "<>", RowBox[{"ToString", "[", "PythonVar", "]"}]}]}], "}"}], ",", "\[IndentingNewLine]", RowBox[{ RowBox[{"PythonBuffer", "=", RowBox[{ "PythonBuffer", "<>", "PythonIndent", "<>", "name", "<>", "\"\<=\>\"", "<>", "a", "<>", "\"\<;\\n\>\""}]}], ";", "\[IndentingNewLine]", RowBox[{"PythonVar", "=", RowBox[{"PythonVar", "+", "1"}]}], ";", "\[IndentingNewLine]", "name"}]}], "]"}]}], ";"}], "\[IndentingNewLine]"}], "\[IndentingNewLine]", RowBox[{ RowBox[{"Clear", "[", "AlreadyWrapped", "]"}], ";"}], "\[IndentingNewLine]", RowBox[{ RowBox[{ RowBox[{ RowBox[{"AlreadyWrapped", "[", "s_", "]"}], ":=", RowBox[{ RowBox[{"(", RowBox[{ RowBox[{"StringPosition", "[", RowBox[{"s", ",", "\"\<(\>\""}], "]"}], "\[Equal]", RowBox[{"{", RowBox[{"{", RowBox[{"1", ",", "1"}], "}"}], "}"}]}], ")"}], "&&", RowBox[{"(", RowBox[{ RowBox[{"StringPosition", "[", RowBox[{"s", ",", "\"\<)\>\""}], "]"}], "\[Equal]", RowBox[{"{", RowBox[{"{", RowBox[{ RowBox[{"StringLength", "[", "s", "]"}], ",", RowBox[{"StringLength", "[", "s", "]"}]}], "}"}], "}"}]}], ")"}]}]}], ";"}], "\[IndentingNewLine]"}], "\[IndentingNewLine]", RowBox[{ RowBox[{"Clear", "[", "PythonWrap", "]"}], ";"}], "\[IndentingNewLine]", RowBox[{ RowBox[{ RowBox[{"PythonWrap", "[", RowBox[{"expa_", ",", RowBox[{"limit_:", "70"}]}], "]"}], ":=", "\[IndentingNewLine]", RowBox[{"Module", "[", RowBox[{ RowBox[{"{", RowBox[{"a", "=", RowBox[{"ToPython2", "[", "expa", "]"}]}], "}"}], ",", "\[IndentingNewLine]", RowBox[{"If", "[", RowBox[{ RowBox[{ RowBox[{"StringLength", "[", "a", "]"}], ">", "limit"}], ",", "\[IndentingNewLine]", RowBox[{"ToPythonVar", "[", "a", "]"}], ",", "\[IndentingNewLine]", RowBox[{"If", "[", RowBox[{ RowBox[{ RowBox[{"Not", "[", RowBox[{"AtomQ", "[", "expa", "]"}], "]"}], "&&", RowBox[{"!", RowBox[{"AlreadyWrapped", "[", "a", "]"}]}]}], ",", "\[IndentingNewLine]", RowBox[{"\"\<(\>\"", "<>", "a", "<>", "\"\<)\>\""}], ",", "\[IndentingNewLine]", "a"}], "]"}]}], "]"}]}], "]"}]}], ";"}]}], "Input", CellChangeTimes->{{3.7147280588921475`*^9, 3.71472847792723*^9}, { 3.7147285301011763`*^9, 3.7147285337920303`*^9}, {3.7147285734391193`*^9, 3.7147287393509483`*^9}, {3.714730740835744*^9, 3.7147307637387114`*^9}, { 3.7147308644072504`*^9, 3.71473088121015*^9}, {3.714730922668334*^9, 3.7147309759396734`*^9}, {3.7147310215055676`*^9, 3.714731035817973*^9}, { 3.7147310738257504`*^9, 3.7147310993150253`*^9}, {3.7147311385093727`*^9, 3.7147312545277743`*^9}, {3.71473130586526*^9, 3.714731311342312*^9}, { 3.714731523161806*^9, 3.7147319638739753`*^9}, {3.714731996976762*^9, 3.714732234323004*^9}, {3.7147324208167787`*^9, 3.7147324215701065`*^9}, { 3.7147324846008277`*^9, 3.714732514624278*^9}, {3.714732544880668*^9, 3.7147326560833797`*^9}, {3.7147326962001123`*^9, 3.7147327139369645`*^9}, {3.7147327556513977`*^9, 3.714732784061017*^9}, { 3.7147328200164394`*^9, 3.714732832258009*^9}, {3.7147328792940807`*^9, 3.714733058632985*^9}, {3.7147331160513325`*^9, 3.7147331580657306`*^9}, { 3.7147332046312933`*^9, 3.7147332991360803`*^9}, {3.714733330503126*^9, 3.714733375560923*^9}, {3.714733436424821*^9, 3.714733438236446*^9}, { 3.71473347514571*^9, 3.7147334784629173`*^9}, {3.7147336437826815`*^9, 3.7147336481829033`*^9}, {3.7147336872549086`*^9, 3.7147337093584805`*^9}, {3.71473374412983*^9, 3.714733752337072*^9}, { 3.7147338783672934`*^9, 3.714733936247692*^9}, {3.7147340328418875`*^9, 3.7147341736080713`*^9}, {3.714734218358507*^9, 3.714734312101856*^9}, { 3.714734352321475*^9, 3.714734366366227*^9}, {3.7147344087821355`*^9, 3.7147344797911453`*^9}, {3.714734522408616*^9, 3.71473453658136*^9}, { 3.714734578211076*^9, 3.7147347086892567`*^9}, {3.7147347436772504`*^9, 3.7147347535898995`*^9}, {3.7147347921411543`*^9, 3.7147347958871455`*^9}, {3.71473485379753*^9, 3.7147348595275497`*^9}, { 3.714734990429813*^9, 3.7147351125760574`*^9}, {3.714735603038391*^9, 3.71473560575518*^9}, {3.7147357284060974`*^9, 3.7147357807020073`*^9}, { 3.7147365033244696`*^9, 3.7147365533222103`*^9}, 3.7147366063063927`*^9, { 3.7147367337637787`*^9, 3.7147367347542233`*^9}, {3.7147370260916977`*^9, 3.7147370340306473`*^9}, {3.7147371864496264`*^9, 3.7147373716410685`*^9}, {3.7147374234520593`*^9, 3.7147375075165033`*^9}, {3.7147375416526403`*^9, 3.714737549034314*^9}, { 3.7147376239369783`*^9, 3.7147377491617785`*^9}, {3.714737812275239*^9, 3.714737843725829*^9}, {3.7147386184577885`*^9, 3.7147386254537725`*^9}, { 3.7147387687906475`*^9, 3.714738833870376*^9}, {3.7147388843509083`*^9, 3.7147389482301245`*^9}, {3.7147390016326647`*^9, 3.714739064570006*^9}, { 3.714739095734868*^9, 3.7147392186026163`*^9}, {3.714739339647521*^9, 3.714739495705353*^9}, {3.714739555218461*^9, 3.7147395571339664`*^9}, { 3.7147396746144247`*^9, 3.714739710929316*^9}, {3.7147398390895705`*^9, 3.714739855039546*^9}, {3.714739906584563*^9, 3.714739947338665*^9}, { 3.7147400476379995`*^9, 3.7147401199552126`*^9}, {3.714740194415708*^9, 3.714740225476508*^9}, {3.7147402821293263`*^9, 3.7147404667192593`*^9}, { 3.71474052985758*^9, 3.7147405349435663`*^9}, {3.7147410996956167`*^9, 3.7147410999249225`*^9}, {3.7147412301257772`*^9, 3.714741261188238*^9}, 3.7148058448030186`*^9, {3.7148061349583783`*^9, 3.7148061412843285`*^9}}], Cell["\<\ Then comes the actual conversion. We only have included some conversions that \ are needed in our code. Feel free to add more. It is easy!\ \>", "Text", CellChangeTimes->{{3.714806145866866*^9, 3.7148061649232726`*^9}}], Cell[BoxData[ RowBox[{ RowBox[{"(*", " ", RowBox[{ "Conversions", " ", "for", " ", "the", " ", "most", " ", "common", " ", "expressions"}], " ", "*)"}], "\[IndentingNewLine]", RowBox[{ RowBox[{ RowBox[{"Clear", "[", "ToPython2", "]"}], ";"}], "\[IndentingNewLine]", RowBox[{ RowBox[{ RowBox[{"ToPython2", "[", RowBox[{"Sqrt", "[", "x_", "]"}], "]"}], ":=", RowBox[{"Module", "[", RowBox[{ RowBox[{"{", "}"}], ",", "\[IndentingNewLine]", RowBox[{ RowBox[{"PythonSqrt", "=", "True"}], ";", "\[IndentingNewLine]", RowBox[{"\"\\"", "<>", RowBox[{"PythonWrap", "[", "x", "]"}], "<>", "\"\<)\>\""}]}]}], "]"}]}], ";"}], "\[IndentingNewLine]", RowBox[{ RowBox[{"ToPython2", "[", RowBox[{"Log", "[", "x_", "]"}], "]"}], ":=", RowBox[{"\"\\"", "<>", RowBox[{"PythonWrap", "[", "x", "]"}], "<>", "\"\<)\>\""}]}], "\[IndentingNewLine]", RowBox[{ RowBox[{"ToPython2", "[", RowBox[{"Exp", "[", "x_", "]"}], "]"}], ":=", RowBox[{"\"\\"", "<>", RowBox[{"PythonWrap", "[", "x", "]"}], "<>", "\"\<)\>\""}]}], "\[IndentingNewLine]", RowBox[{ RowBox[{"ToPython2", "[", RowBox[{"Sin", "[", "x_", "]"}], "]"}], ":=", RowBox[{"\"\\"", "<>", RowBox[{"PythonWrap", "[", "x", "]"}], "<>", "\"\<)\>\""}]}], "\[IndentingNewLine]", RowBox[{ RowBox[{"ToPython2", "[", RowBox[{"Cos", "[", "x_", "]"}], "]"}], ":=", RowBox[{"\"\\"", "<>", RowBox[{"PythonWrap", "[", "x", "]"}], "<>", "\"\<)\>\""}]}], "\[IndentingNewLine]", RowBox[{ RowBox[{"ToPython2", "[", SuperscriptBox["\[ExponentialE]", "x_"], "]"}], ":=", RowBox[{"\"\\"", "<>", RowBox[{"PythonWrap", "[", "x", "]"}], "<>", "\"\<)\>\""}]}], "\[IndentingNewLine]", RowBox[{ RowBox[{"ToPython2", "[", RowBox[{"E", "^", "x_"}], "]"}], ":=", RowBox[{"\"\\"", "<>", RowBox[{"PythonWrap", "[", "x", "]"}], "<>", "\"\<)\>\""}]}], "\[IndentingNewLine]", RowBox[{ RowBox[{"ToPython2", "[", RowBox[{"a_", "+", "b_"}], "]"}], ":=", RowBox[{"ToPythonOp", "[", RowBox[{"\"\<+\>\"", ",", "a", ",", "b"}], "]"}]}], "\[IndentingNewLine]", RowBox[{ RowBox[{"ToPython2", "[", RowBox[{"a_", "*", "b_"}], "]"}], ":=", RowBox[{"ToPythonOp", "[", RowBox[{"\"\<*\>\"", ",", "a", ",", "b"}], "]"}]}], "\[IndentingNewLine]", RowBox[{ RowBox[{"ToPython2", "[", RowBox[{"a_", "-", "b_"}], "]"}], ":=", RowBox[{"ToPythonOp", "[", RowBox[{"\"\<-\>\"", ",", "a", ",", "b"}], "]"}]}], "\[IndentingNewLine]", RowBox[{ RowBox[{"ToPython2", "[", RowBox[{"a_", "/", "b_"}], "]"}], ":=", RowBox[{"ToPythonOp", "[", RowBox[{"\"\\"", ",", "a", ",", "b"}], "]"}]}], "\[IndentingNewLine]", RowBox[{ RowBox[{"ToPython2", "[", RowBox[{"a_", "^", "2"}], "]"}], ":=", RowBox[{"\"\<(\>\"", "<>", RowBox[{"PythonWrap", "[", "a", "]"}], "<>", "\"\<**2)\>\""}]}], "\[IndentingNewLine]", RowBox[{ RowBox[{"ToPython2", "[", RowBox[{"a_", "^", "b_"}], "]"}], ":=", RowBox[{"PythonWrap", "[", RowBox[{"ToPythonOp", "[", RowBox[{"\"\<**\>\"", ",", "a", ",", "b"}], "]"}], "]"}]}], "\[IndentingNewLine]", RowBox[{ RowBox[{ RowBox[{"ToPython2", "[", RowBox[{"x_", "?", "NumberQ"}], "]"}], ":=", "\[IndentingNewLine]", RowBox[{"If", "[", RowBox[{ RowBox[{ RowBox[{"Head", "[", "x", "]"}], "===", "Complex"}], ",", "\[IndentingNewLine]", RowBox[{"\"\<(\>\"", "<>", RowBox[{"ToPython2", "[", RowBox[{"Re", "[", "x", "]"}], "]"}], "<>", "\"\<+\>\"", "<>", RowBox[{"ToPython2", "[", RowBox[{"Im", "[", "x", "]"}], "]"}], "<>", "\"\\""}], ",", "\[IndentingNewLine]", RowBox[{"ToString", "[", RowBox[{"N", "[", "x", "]"}], "]"}]}], "]"}]}], ";"}], "\[IndentingNewLine]", RowBox[{ RowBox[{"ToPython2", "[", RowBox[{"-", "x_"}], "]"}], ":=", RowBox[{"\"\<(-\>\"", "<>", RowBox[{"ToPython2", "[", "x", "]"}], "<>", "\"\<)\>\""}]}], "\[IndentingNewLine]", RowBox[{ RowBox[{"ToPython2", "[", "\[Pi]", "]"}], ":=", RowBox[{"Module", "[", RowBox[{ RowBox[{"{", "}"}], ",", RowBox[{ RowBox[{"PythonPi", "=", "True"}], ";", "\"\<\[Pi]\>\""}]}], "]"}]}], "\[IndentingNewLine]", RowBox[{ RowBox[{"ToPython2", "[", "\[Gamma]", "]"}], ":=", "\"\<\[Gamma]\>\""}], "\[IndentingNewLine]", RowBox[{ RowBox[{"ToPython2", "[", "\[CapitalOmega]", "]"}], ":=", "\"\<\[CapitalOmega]\>\""}], "\[IndentingNewLine]", RowBox[{ RowBox[{"ToPython2", "[", "\[CapitalDelta]", "]"}], ":=", "\"\<\[CapitalDelta]\>\""}], "\[IndentingNewLine]", RowBox[{ RowBox[{ RowBox[{"ToPython2", "[", "x_", "]"}], ":=", RowBox[{"ToString", "[", "x", "]"}]}], ";"}], "\[IndentingNewLine]", "\[IndentingNewLine]", RowBox[{"(*", " ", RowBox[{ "This", " ", "is", " ", "for", " ", "converting", " ", "inline", " ", "operations"}], " ", "*)"}], "\[IndentingNewLine]", RowBox[{ RowBox[{"Clear", "[", "ToPythonOp", "]"}], ";"}], "\[IndentingNewLine]", RowBox[{ RowBox[{ RowBox[{"ToPythonOp", "[", RowBox[{"op_", ",", "expa_", ",", "expb_"}], "]"}], ":=", "\[IndentingNewLine]", RowBox[{ RowBox[{"PythonWrap", "[", "expa", "]"}], "<>", "op", "<>", RowBox[{"PythonWrap", "[", "expb", "]"}]}]}], ";"}]}]}]], "Input", CellChangeTimes->{{3.714806168380881*^9, 3.7148061930925913`*^9}}], Cell["One example of use", "Text", CellChangeTimes->{{3.714806196619082*^9, 3.714806198794927*^9}}], Cell[CellGroupData[{ Cell[BoxData[ RowBox[{"ToPython", "[", RowBox[{"Exp", "[", RowBox[{"g", "*", RowBox[{ RowBox[{"Log", "[", RowBox[{ RowBox[{"(", RowBox[{ RowBox[{"-", "3"}], "+", RowBox[{"2", " ", SuperscriptBox["\[Pi]", "2"], " ", SuperscriptBox["\[Gamma]", "2"]}], "+", RowBox[{"2", " ", "\[Pi]", " ", "\[Gamma]", " ", SqrtBox[ RowBox[{ RowBox[{"-", "1"}], "+", RowBox[{ SuperscriptBox["\[Pi]", "2"], " ", SuperscriptBox["\[Gamma]", "2"]}]}]]}]}], ")"}], " ", SuperscriptBox["\[CapitalOmega]", "2"]}], "]"}], "/", RowBox[{"Log", "[", RowBox[{ RowBox[{"(", RowBox[{ RowBox[{"-", "1"}], "+", RowBox[{"2", " ", SuperscriptBox["\[Pi]", "2"], " ", SuperscriptBox["\[Gamma]", "2"]}], "+", RowBox[{"2", " ", "\[Pi]", " ", "\[Gamma]", " ", SqrtBox[ RowBox[{ RowBox[{"-", "1"}], "+", RowBox[{ SuperscriptBox["\[Pi]", "2"], " ", SuperscriptBox["\[Gamma]", "2"]}]}]]}]}], ")"}], " ", SuperscriptBox["\[CapitalOmega]", "2"]}], "]"}]}]}], "]"}], "]"}]], "Input", CellChangeTimes->{ 3.714733238398271*^9, {3.714734882085868*^9, 3.714734903599966*^9}, 3.714735134228116*^9}], Cell[BoxData["\<\"\[Pi]=math.pi;\\n\\ndef mysqrt(x): return \ np.sqrt((1.+0j)*x)\\n\\naux0=-3.+((2.*((\[Pi]**2)*(\[Gamma]**2)))+(2.*(\[Pi]*(\ \[Gamma]*(mysqrt((-1.+((\[Pi]**2)*(\[Gamma]**2)))))))));\\naux1=-1.+((2.*((\ \[Pi]**2)*(\[Gamma]**2)))+(2.*(\[Pi]*(\[Gamma]*(mysqrt((-1.+((\[Pi]**2)*(\ \[Gamma]**2)))))))));\\noutput=(aux0*(\[CapitalOmega]**2))**(g/(np.log((aux1*(\ \[CapitalOmega]**2)))));\\n\"\>"], "Output", CellChangeTimes->{ 3.714733101737248*^9, {3.7147331361527834`*^9, 3.714733162035652*^9}, { 3.7147332103185225`*^9, 3.7147332594965534`*^9}, 3.7147333806236677`*^9, 3.7147334599302845`*^9, 3.7147334949449296`*^9, {3.7147348950554457`*^9, 3.7147349042323856`*^9}, {3.714735124711671*^9, 3.7147351352481256`*^9}, { 3.714736598135808*^9, 3.7147366119709363`*^9}, 3.7147375219643946`*^9, 3.71473771955263*^9, 3.714737758986186*^9, 3.714737848907398*^9, { 3.7147394764077134`*^9, 3.714739498691456*^9}, 3.714740478683316*^9, 3.7147405378274813`*^9, 3.7147412683346996`*^9, 3.7148062059971113`*^9}] }, Open ]], Cell["This is a more complicated example:", "Text", CellChangeTimes->{{3.714805656341395*^9, 3.7148056601398*^9}}], Cell[BoxData[ RowBox[{ RowBox[{ RowBox[{ RowBox[{"ExpP", "[", RowBox[{ "\[CapitalOmega]_", ",", "\[CapitalDelta]_", ",", " ", "g_", ",", " ", "\[Gamma]_"}], "]"}], ":=", " ", RowBox[{"Exp", "[", RowBox[{ RowBox[{"-", RowBox[{"(", RowBox[{ RowBox[{ SuperscriptBox["g", "2"], " ", RowBox[{"(", RowBox[{ RowBox[{"2", " ", "\[Pi]", " ", SqrtBox[ FractionBox[ RowBox[{"1", "-", RowBox[{"2", " ", SuperscriptBox["\[Pi]", "2"], " ", SuperscriptBox["\[Gamma]", "2"]}], "+", RowBox[{"2", " ", "\[Pi]", " ", "\[Gamma]", " ", SqrtBox[ RowBox[{ RowBox[{"-", "1"}], "+", RowBox[{ SuperscriptBox["\[Pi]", "2"], " ", SuperscriptBox["\[Gamma]", "2"]}]}]]}]}], RowBox[{ RowBox[{"-", "1"}], "+", RowBox[{"2", " ", SuperscriptBox["\[Pi]", "2"], " ", SuperscriptBox["\[Gamma]", "2"]}], "+", RowBox[{"2", " ", "\[Pi]", " ", "\[Gamma]", " ", SqrtBox[ RowBox[{ RowBox[{"-", "1"}], "+", RowBox[{ SuperscriptBox["\[Pi]", "2"], " ", SuperscriptBox["\[Gamma]", "2"]}]}]]}]}]]], " ", SuperscriptBox["\[CapitalDelta]", "5"], " ", "\[CapitalOmega]"}], "-", RowBox[{ RowBox[{"(", RowBox[{"1", "-", RowBox[{"2", " ", SuperscriptBox["\[Pi]", "2"], " ", SuperscriptBox["\[Gamma]", "2"]}], "-", RowBox[{"2", " ", "\[Pi]", " ", "\[Gamma]", " ", SqrtBox[ RowBox[{ RowBox[{"-", "1"}], "+", RowBox[{ SuperscriptBox["\[Pi]", "2"], " ", SuperscriptBox["\[Gamma]", "2"]}]}]]}]}], ")"}], " ", SuperscriptBox["\[CapitalOmega]", "4"]}]}], ")"}], " ", RowBox[{"Log", "[", RowBox[{"-", FractionBox["1", RowBox[{ SqrtBox[ RowBox[{"1", "-", RowBox[{"2", " ", SuperscriptBox["\[Pi]", "2"], " ", SuperscriptBox["\[Gamma]", "2"]}], "+", RowBox[{"2", " ", "\[Pi]", " ", "\[Gamma]", " ", SqrtBox[ RowBox[{ RowBox[{"-", "1"}], "+", RowBox[{ SuperscriptBox["\[Pi]", "2"], " ", SuperscriptBox["\[Gamma]", "2"]}]}]]}]}]], " ", "\[CapitalOmega]"}]]}], "]"}]}], "+", RowBox[{"2", " ", SuperscriptBox["\[CapitalDelta]", "5"], " ", "\[CapitalOmega]", " ", RowBox[{"Log", "[", FractionBox["1", RowBox[{ SqrtBox[ RowBox[{"1", "-", RowBox[{"2", " ", SuperscriptBox["\[Pi]", "2"], " ", SuperscriptBox["\[Gamma]", "2"]}], "+", RowBox[{"2", " ", "\[Pi]", " ", "\[Gamma]", " ", SqrtBox[ RowBox[{ RowBox[{"-", "1"}], "+", RowBox[{ SuperscriptBox["\[Pi]", "2"], " ", SuperscriptBox["\[Gamma]", "2"]}]}]]}]}]], " ", "\[CapitalOmega]"}]], "]"}]}], "-", RowBox[{"2", " ", SuperscriptBox["\[Pi]", "2"], " ", SuperscriptBox["\[Gamma]", "2"], " ", SqrtBox[ RowBox[{"1", "-", RowBox[{"2", " ", SuperscriptBox["\[Pi]", "2"], " ", SuperscriptBox["\[Gamma]", "2"]}], "+", RowBox[{"2", " ", "\[Pi]", " ", "\[Gamma]", " ", SqrtBox[ RowBox[{ RowBox[{"-", "1"}], "+", RowBox[{ SuperscriptBox["\[Pi]", "2"], " ", SuperscriptBox["\[Gamma]", "2"]}]}]]}]}]], " ", SuperscriptBox["\[CapitalOmega]", "6"], " ", RowBox[{"Log", "[", RowBox[{ RowBox[{"(", RowBox[{ RowBox[{"-", "1"}], "+", RowBox[{"2", " ", SuperscriptBox["\[Pi]", "2"], " ", SuperscriptBox["\[Gamma]", "2"]}], "+", RowBox[{"2", " ", "\[Pi]", " ", "\[Gamma]", " ", SqrtBox[ RowBox[{ RowBox[{"-", "1"}], "+", RowBox[{ SuperscriptBox["\[Pi]", "2"], " ", SuperscriptBox["\[Gamma]", "2"]}]}]]}]}], ")"}], " ", SuperscriptBox["\[CapitalOmega]", "2"]}], "]"}]}], "+", RowBox[{"2", " ", "\[Pi]", " ", "\[Gamma]", " ", SqrtBox[ RowBox[{ RowBox[{"-", "1"}], "+", RowBox[{ SuperscriptBox["\[Pi]", "2"], " ", SuperscriptBox["\[Gamma]", "2"]}]}]], " ", SqrtBox[ RowBox[{"1", "-", RowBox[{"2", " ", SuperscriptBox["\[Pi]", "2"], " ", SuperscriptBox["\[Gamma]", "2"]}], "+", RowBox[{"2", " ", "\[Pi]", " ", "\[Gamma]", " ", SqrtBox[ RowBox[{ RowBox[{"-", "1"}], "+", RowBox[{ SuperscriptBox["\[Pi]", "2"], " ", SuperscriptBox["\[Gamma]", "2"]}]}]]}]}]], " ", SuperscriptBox["\[CapitalOmega]", "6"], " ", RowBox[{"Log", "[", RowBox[{ RowBox[{"(", RowBox[{ RowBox[{"-", "1"}], "+", RowBox[{"2", " ", SuperscriptBox["\[Pi]", "2"], " ", SuperscriptBox["\[Gamma]", "2"]}], "+", RowBox[{"2", " ", "\[Pi]", " ", "\[Gamma]", " ", SqrtBox[ RowBox[{ RowBox[{"-", "1"}], "+", RowBox[{ SuperscriptBox["\[Pi]", "2"], " ", SuperscriptBox["\[Gamma]", "2"]}]}]]}]}], ")"}], " ", SuperscriptBox["\[CapitalOmega]", "2"]}], "]"}]}]}], ")"}]}], "/", RowBox[{"(", RowBox[{"\[Pi]", " ", SqrtBox[ RowBox[{ RowBox[{"-", "1"}], "+", RowBox[{ SuperscriptBox["\[Pi]", "2"], " ", SuperscriptBox["\[Gamma]", "2"]}]}]], " ", SqrtBox[ RowBox[{"1", "-", RowBox[{"2", " ", SuperscriptBox["\[Pi]", "2"], " ", SuperscriptBox["\[Gamma]", "2"]}], "+", RowBox[{"2", " ", "\[Pi]", " ", "\[Gamma]", " ", SqrtBox[ RowBox[{ RowBox[{"-", "1"}], "+", RowBox[{ SuperscriptBox["\[Pi]", "2"], " ", SuperscriptBox["\[Gamma]", "2"]}]}]]}]}]], " ", SuperscriptBox[ RowBox[{"(", RowBox[{ SuperscriptBox["\[CapitalDelta]", "4"], "+", RowBox[{"2", " ", RowBox[{"(", RowBox[{ RowBox[{"-", "1"}], "+", RowBox[{"2", " ", SuperscriptBox["\[Pi]", "2"], " ", SuperscriptBox["\[Gamma]", "2"]}]}], ")"}], " ", SuperscriptBox["\[CapitalDelta]", "2"], " ", SuperscriptBox["\[CapitalOmega]", "2"]}], "+", SuperscriptBox["\[CapitalOmega]", "4"]}], ")"}], "2"]}], ")"}]}], "]"}]}], ";"}], "\[IndentingNewLine]"}]], "Input", CellChangeTimes->{{3.698565838364592*^9, 3.69856589189324*^9}, { 3.698566441642161*^9, 3.698566459618937*^9}, 3.698566577350696*^9, { 3.69856662866551*^9, 3.698566641770298*^9}, {3.698566742952484*^9, 3.6985667581828337`*^9}, {3.6985671284505787`*^9, 3.698567147748344*^9}, { 3.6985680732705507`*^9, 3.6985680752971992`*^9}, {3.6985681064070263`*^9, 3.698568110904233*^9}, {3.6985681811053257`*^9, 3.69856818665193*^9}, { 3.6985882824409723`*^9, 3.6985882911556253`*^9}, {3.700897972732787*^9, 3.7008980310996943`*^9}, {3.700898110246846*^9, 3.700898113778957*^9}, { 3.7008989340283737`*^9, 3.70089894342194*^9}, {3.701491854670836*^9, 3.701491866755329*^9}, {3.701491914466011*^9, 3.701491916352087*^9}, { 3.701492283185144*^9, 3.701492289675894*^9}, {3.701495527557707*^9, 3.701495544340198*^9}, 3.708860386614855*^9, 3.714730725280631*^9, { 3.7148056168716755`*^9, 3.7148056335366106`*^9}}, ExpressionUUID -> "6bbfa07f-da87-4b55-95f0-f9b02da0d983"], Cell["\<\ We export to Python after simplifying the expression a little bit, to \ reducethe number of variables.\ \>", "Text", CellChangeTimes->{{3.7147413546085854`*^9, 3.7147413682087984`*^9}}], Cell[CellGroupData[{ Cell[BoxData[ RowBox[{"Code", "=", RowBox[{"Block", "[", RowBox[{ RowBox[{"{", RowBox[{"$Assumptions", "=", RowBox[{"{", RowBox[{ RowBox[{"\[CapitalOmega]", ">", "0"}], ",", RowBox[{"\[Gamma]", ">", "0"}], ",", RowBox[{"y", ">", "0"}]}], "}"}]}], "}"}], ",", "\[IndentingNewLine]", RowBox[{"Module", "[", RowBox[{ RowBox[{"{", RowBox[{"aux", "=", RowBox[{"ExpP", "[", RowBox[{ "\[CapitalOmega]", ",", "\[CapitalDelta]", ",", " ", "g", ",", " ", "\[Gamma]"}], "]"}]}], "}"}], ",", "\[IndentingNewLine]", RowBox[{"Module", "[", RowBox[{ RowBox[{"{", "\[IndentingNewLine]", RowBox[{"vars", "=", RowBox[{"{", RowBox[{ RowBox[{"{", RowBox[{"y", ",", RowBox[{"\[Gamma]", " ", "\[Pi]"}]}], "}"}], ",", RowBox[{"{", RowBox[{"x", ",", SqrtBox[ RowBox[{ RowBox[{"-", "1"}], "+", SuperscriptBox["y", "2"]}]]}], "}"}], ",", RowBox[{"{", RowBox[{"z", ",", RowBox[{"1", "+", RowBox[{"2", " ", "x", " ", "y"}], "-", RowBox[{"2", " ", SuperscriptBox["y", "2"]}]}]}], "}"}], ",", RowBox[{"{", RowBox[{"w", ",", RowBox[{ RowBox[{"-", "1"}], "+", RowBox[{"2", " ", "x", " ", "y"}], " ", "+", RowBox[{"2", " ", SuperscriptBox["y", "2"]}]}]}], "}"}], ",", RowBox[{"{", RowBox[{"u", ",", SqrtBox[ FractionBox["z", "w"]]}], "}"}]}], "}"}]}], "\[IndentingNewLine]", "}"}], ",", "\[IndentingNewLine]", RowBox[{ RowBox[{"aux", "=", RowBox[{"Simplify", "[", RowBox[{"aux", "/.", RowBox[{"{", RowBox[{"\[Gamma]", "\[Rule]", RowBox[{"y", "/", "\[Pi]"}]}], "}"}]}], "]"}]}], ";", "\[IndentingNewLine]", RowBox[{"aux", "=", RowBox[{"Simplify", "[", RowBox[{"aux", "/.", RowBox[{"{", RowBox[{ SqrtBox[ RowBox[{ RowBox[{"-", "1"}], "+", SuperscriptBox["y", "2"]}]], "\[Rule]", "x"}], "}"}]}], "]"}]}], ";", "\[IndentingNewLine]", RowBox[{"aux", "=", RowBox[{"Simplify", "[", RowBox[{"aux", "/.", RowBox[{"{", RowBox[{ RowBox[{"1", "+", RowBox[{"2", " ", "x", " ", "y"}], "-", RowBox[{"2", " ", SuperscriptBox["y", "2"]}]}], "\[Rule]", "z"}], "}"}]}], "]"}]}], ";", "\[IndentingNewLine]", RowBox[{"aux", "=", RowBox[{"Simplify", "[", RowBox[{"aux", "/.", RowBox[{"{", RowBox[{ RowBox[{ RowBox[{"-", "1"}], "+", RowBox[{"2", " ", "x", " ", "y"}], " ", "+", RowBox[{"2", " ", SuperscriptBox["y", "2"]}]}], "\[Rule]", "w"}], "}"}]}], "]"}]}], ";", "\[IndentingNewLine]", RowBox[{"aux", "=", RowBox[{"Simplify", "[", RowBox[{"aux", "/.", RowBox[{"{", RowBox[{ SqrtBox[ FractionBox["z", "w"]], "\[Rule]", "u"}], "}"}]}], "]"}]}], ";", "\[IndentingNewLine]", RowBox[{"Print", "[", "aux", "]"}], ";", "\[IndentingNewLine]", RowBox[{"ToPython", "[", RowBox[{ "aux", ",", "vars", ",", "\"\\"", ",", "\"\< \>\""}], RowBox[{"(*", " ", "Indentation", " ", "*)"}], "]"}]}]}], "\[IndentingNewLine]", "]"}]}], "]"}]}], "]"}]}]], "Input", CellChangeTimes->CompressedData[" 1:eJxTTMoPSmViYGAQAWIQvetFaov32teOFv5TukH0nX1OM0D0jtfaa8Di/Aab QPQrwSvbQbSzn/pBEF0pf+0IiP7leuw2iP5/I/YpiJbo+/ASRO8xCXgHop98 OvcJRLu+dP4Mou2qX/wG0ULvfrL7AOneB6dlQHTJbB01EP33b5IuiE6LuwKm E9SaI0D05DNXwPTCW1ekfIH0jye/pEH03ccnjP2AtO3VEDMQvUrX3ApEn+L8 4AyiHz057AeiJ0ibp4LoODPPVhB9RvpyN4jWcS2eAKKfzTKcBKI3KrfOBNHJ yZ9mgeiKizoLQHSb0OSFIDrH/+2XXCD9SbLlD4gGAA03r0Y= "]], Cell[BoxData[ SuperscriptBox["\[ExponentialE]", RowBox[{"-", FractionBox[ RowBox[{"\[CapitalOmega]", " ", RowBox[{"(", RowBox[{ RowBox[{ SuperscriptBox["g", "2"], " ", RowBox[{"(", RowBox[{ RowBox[{"2", " ", "\[Pi]", " ", "u", " ", SuperscriptBox["\[CapitalDelta]", "5"]}], "+", RowBox[{"w", " ", SuperscriptBox["\[CapitalOmega]", "3"]}]}], ")"}], " ", RowBox[{"Log", "[", RowBox[{"-", FractionBox["1", RowBox[{ SqrtBox["z"], " ", "\[CapitalOmega]"}]]}], "]"}]}], "+", RowBox[{"2", " ", RowBox[{"(", RowBox[{ RowBox[{ SuperscriptBox["\[CapitalDelta]", "5"], " ", RowBox[{"Log", "[", FractionBox["1", RowBox[{ SqrtBox["z"], " ", "\[CapitalOmega]"}]], "]"}]}], "+", RowBox[{ RowBox[{"(", RowBox[{"x", "-", "y"}], ")"}], " ", "y", " ", SqrtBox["z"], " ", SuperscriptBox["\[CapitalOmega]", "5"], " ", RowBox[{"Log", "[", RowBox[{"w", " ", SuperscriptBox["\[CapitalOmega]", "2"]}], "]"}]}]}], ")"}]}]}], ")"}]}], RowBox[{"\[Pi]", " ", SqrtBox[ RowBox[{ RowBox[{"-", "1"}], "+", SuperscriptBox["y", "2"]}]], " ", SqrtBox["z"], " ", SuperscriptBox[ RowBox[{"(", RowBox[{ SuperscriptBox["\[CapitalDelta]", "4"], "+", RowBox[{"2", " ", RowBox[{"(", RowBox[{ RowBox[{"-", "1"}], "+", RowBox[{"2", " ", SuperscriptBox["y", "2"]}]}], ")"}], " ", SuperscriptBox["\[CapitalDelta]", "2"], " ", SuperscriptBox["\[CapitalOmega]", "2"]}], "+", SuperscriptBox["\[CapitalOmega]", "4"]}], ")"}], "2"]}]]}]]], "Print",\ CellChangeTimes->{3.71474099753652*^9, 3.7147410391108294`*^9, 3.714741318685417*^9, 3.714741358178559*^9, 3.7147414104073987`*^9, 3.7147414871597557`*^9, 3.7147415336729407`*^9, 3.714806208143749*^9}], Cell[BoxData["\<\" \[Pi]=math.pi;\\n\\n def mysqrt(x): return \ np.sqrt((1.+0j)*x)\\n\\n y=\[Pi]*\[Gamma];\\n \ x=mysqrt((-1.+(y**2)));\\n z=1.+((2.*(x*y))+(-2.*(y**2)));\\n \ w=-1.+((2.*(x*y))+(2.*(y**2)));\\n u=mysqrt((z/w));\\n aux0=((\ \[CapitalDelta]**5.)*(np.log(((z**-0.5)/\[CapitalOmega]))))+((x-y)*(y*((\ mysqrt(z))*((\[CapitalOmega]**5.)*(np.log((w*(\[CapitalOmega]**2))))))));\\n \ aux1=((g**2)*(((2.*(\[Pi]*(u*(\[CapitalDelta]**5.))))+(w*(\[CapitalOmega]**\ 3.)))*(np.log(((-z**-0.5)/\[CapitalOmega])))))+(2.*aux0);\\n aux2=(((\ \[CapitalDelta]**4.)+((2.*((-1.+(2.*(y**2)))*((\[CapitalDelta]**2)*(\ \[CapitalOmega]**2))))+(\[CapitalOmega]**4.)))**-2.)*aux1;\\n \ output=np.exp((((-((-1.+(y**2))**-0.5)*((z**-0.5)*(\[CapitalOmega]*aux2))))/\ \[Pi]));\\n\"\>"], "Output", CellChangeTimes->{3.714806208168769*^9}] }, Open ]], Cell["\<\ This code can be exported to a Python file in Unicode format (so that Greek \ characters can be used)\ \>", "Text", CellChangeTimes->{{3.714805690139448*^9, 3.71480569537115*^9}, { 3.7148057483393836`*^9, 3.714805762668*^9}}], Cell[CellGroupData[{ Cell[BoxData[ RowBox[{"Export", "[", RowBox[{ RowBox[{ RowBox[{"NotebookDirectory", "[", "]"}], "<>", "\"\\""}], ",", "Code", ",", "\"\\"", ",", RowBox[{"CharacterEncoding", "\[Rule]", "\"\\""}]}], "]"}]], "Input", CellChangeTimes->{{3.7148057418524723`*^9, 3.7148057460123253`*^9}}], Cell[BoxData["\<\"E:\\\\home\\\\JuanJose\\\\Dropbox\\\\workspace\\\\02 \ Burocracia\\\\170919 - Exportar Python\\\\foo.py\"\>"], "Output", CellChangeTimes->{3.714806208708612*^9}] }, Open ]] }, WindowSize->{808, 911}, WindowMargins->{{Automatic, 91}, {Automatic, 5}}, FrontEndVersion->"10.4 para Microsoft Windows (64-bit) (April 11, 2016)", StyleDefinitions->"Default.nb" ] (* End of Notebook Content *) (* Internal cache information *) (*CellTagsOutline CellTagsIndex->{} *) (*CellTagsIndex CellTagsIndex->{} *) (*NotebookFileOutline Notebook[{ Cell[558, 20, 411, 7, 68, "Text"], Cell[972, 29, 251, 5, 49, "Text"], Cell[1226, 36, 6404, 143, 772, "Input"], Cell[7633, 181, 368, 6, 68, "Text"], Cell[8004, 189, 6147, 122, 392, "Input"], Cell[14154, 313, 230, 4, 49, "Text"], Cell[14387, 319, 5768, 154, 652, "Input"], Cell[20158, 475, 100, 1, 30, "Text"], Cell[CellGroupData[{ Cell[20283, 480, 1390, 40, 85, "Input"], Cell[21676, 522, 1038, 14, 172, "Output"] }, Open ]], Cell[22729, 539, 115, 1, 30, "Text"], Cell[22847, 542, 8749, 210, 666, "Input"], Cell[31599, 754, 196, 4, 30, "Text"], Cell[CellGroupData[{ Cell[31820, 762, 4342, 112, 435, "Input"], Cell[36165, 876, 2132, 60, 81, "Print"], Cell[38300, 938, 856, 12, 352, "Output"] }, Open ]], Cell[39171, 953, 238, 5, 30, "Text"], Cell[CellGroupData[{ Cell[39434, 962, 332, 8, 31, "Input"], Cell[39769, 972, 180, 2, 31, "Output"] }, Open ]] } ] *)