├── resources
├── test.sh
├── test.m
├── examples
│ └── 2nd_order_GW_pert.nb
└── GRE
│ └── GRE.m
├── .project
├── MathGR.iml
├── MathGR.m
├── README.md
├── adm.m
├── utilPrivate.m
├── frwadm.m
├── util.m
├── decomp.m
├── gr.m
├── ibp.m
├── tensor.m
├── typeset.m
└── LICENSE
/resources/test.sh:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | MathematicaScript -script test.m
3 | notify-send "$(cat test_result.txt test_message.txt)"
4 |
5 |
--------------------------------------------------------------------------------
/.project:
--------------------------------------------------------------------------------
1 |
2 |
3 | MathGR
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/MathGR.iml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/MathGR.m:
--------------------------------------------------------------------------------
1 | (* ::Package:: *)
2 |
3 | (* Mathematica package *)
4 | BeginPackage["MathGR`MathGR`", {"MathGR`tensor`", "MathGR`decomp`", "MathGR`gr`", "MathGR`ibp`", "MathGR`typeset`", "MathGR`util`"}]
5 | EndPackage[]
6 | "MathGR, by Yi Wang (2013-2022), https://github.com/tririver/MathGR. \nBugs can be reported to https://github.com/tririver/MathGR/issues\nLoaded components tensor, decomp, gr, ibp, typeset, util."
7 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | MathGR
2 | ======
3 |
4 | MathGR is a package for GR calculation, written in Mathematica.
5 |
6 | The manual of the package is available at http://arxiv.org/abs/1306.1295
7 |
8 | Note: if you download (instead of clone) the package and then unzip, the folder name will include a version number, something like `MathGR-0.1.1`. Please change it to exactly `MathGR` before usage. This is because `Mathematica` requires the folder name to be exactly the same as the package name. Otherwise the packages cannot be properly loaded.
9 |
--------------------------------------------------------------------------------
/adm.m:
--------------------------------------------------------------------------------
1 | (* ::Package:: *)
2 |
3 | (* Yi Wang, 2013, tririverwangyi@gmail.com, GPLv3 *)
4 | BeginPackage["MathGR`adm`", {"MathGR`tensor`", "MathGR`decomp`", "MathGR`gr`", "MathGR`util`", "MathGR`ibp`"}]
5 |
6 | DeclareIdx[{UP, DN}, DefaultDim, LatinIdx]
7 |
8 | SimpHook = {DefaultDim->3}
9 | LapseN = \[ScriptCapitalN]
10 | ShiftN[DN@i_] := \[ScriptCapitalN][DN@i]
11 | Sqrtg:= \[ScriptCapitalN]* Sqrth * a^3
12 | UseMetric[h]
13 |
14 | (* 4d metric is used to be decomposed and be replaced. *)
15 | DecompHook = {
16 | g[DN@i_, DN@j_]:> h[DN@i, DN@j],
17 | g[DE@0, DE@0]:> (-\[ScriptCapitalN]^2 + h[UP@#1, UP@#2]ShiftN[DN@#1]ShiftN[DN@#2] &@Uq[2]),
18 | g[DE@0, DN@i_]:> ShiftN[DN@i],
19 | g[UP@i_, UP@j_]:> (h[UP@i, UP@j] - ShiftN[DN@#1]ShiftN[DN@#2]h[UP@#1, UP@i]h[UP@#2, UP@j]/\[ScriptCapitalN]^2 &@Uq[2]),
20 | g[UE@0, UE@0]:> -1/\[ScriptCapitalN]^2,
21 | g[UE@0, UP@i_]:> (h[UP@i, UP@#]ShiftN[DN@#]/\[ScriptCapitalN]^2 &@Uq[1])}
22 |
23 |
24 | SetAttributes[DecompG2H, HoldAll]
25 | DecompG2H[f_]:= Decomp0i@WithMetric[g, {UTot, DTot}, MetricContract[f]]
26 |
27 |
28 | EndPackage[]
29 |
--------------------------------------------------------------------------------
/utilPrivate.m:
--------------------------------------------------------------------------------
1 | (* Yi Wang, 2013, tririverwangyi@gmail.com, GPLv3 *)
2 | BeginPackage["MathGR`utilPrivate`"]
3 |
4 | defQ
5 | plus2list
6 | expand2list
7 | apply2term
8 | replaceTo
9 | getSampleTerm
10 | times2prod
11 | prod2times
12 | prod
13 | add2set
14 | add2pattern
15 | take
16 |
17 | Begin["`Private`"]
18 |
19 | SetAttributes[defQ, HoldAll];
20 | defQ[x_]:= {OwnValues[x],UpValues[x],DownValues[x]} =!= {{},{},{}};
21 |
22 | plus2list = If[Head[#]===Plus||Head[#]===List, List@@#, {#}]&
23 | expand2list = plus2list[Expand@#]&
24 |
25 | times2list = If[Head[#] === Times || Head[#] === List, List @@ #, {#}] &;
26 |
27 | apply2term = Total[#1/@expand2list[#2]]&
28 | replaceTo = Thread[RuleDelayed[##]]&
29 | getSampleTerm = Function[e, If[Head@#===Plus, #[[1]], #]&[Expand@e]]
30 |
31 | SetAttributes[prod,Flat]
32 | times2prod[expr_]:= expr /. {Times->prod,Power[a_,n_/;IntegerQ[n]&&n>0]:>prod@@ConstantArray[a,n]}
33 | times2prod[expr_, t_]:= times2prod[expr] /. prod->t
34 | prod2times[expr_, t_:prod]:= expr /. t->Times
35 |
36 | SetAttributes[{add2set, add2pattern}, HoldFirst]
37 | add2set[li_, elem_]:= If[Head[li]===List, li=Union[li,Flatten@{elem}], li = Flatten@{elem}]
38 | add2pattern[pi_, elem_]:= If[ValueQ[pi], pi=pi|elem, pi=elem]
39 |
40 | take[list_, n_] := If[Length@list > n, Take[list, n], list]
41 |
42 | End[]
43 | EndPackage[]
--------------------------------------------------------------------------------
/frwadm.m:
--------------------------------------------------------------------------------
1 | (* Yi Wang, 2013, tririverwangyi@gmail.com, GPLv3 *)
2 | BeginPackage["MathGR`frwadm`", {"MathGR`tensor`", "MathGR`decomp`", "MathGR`gr`", "MathGR`util`", "MathGR`ibp`"}]
3 |
4 | DeclareIdx[{UP, DN}, DefaultDim, LatinIdx]
5 |
6 | PdT[Mp,_]:=0
7 | PdT[a|H|\[Epsilon]|\[Eta], PdVars[_DN, ___]]:=0
8 | SimpHook = {DefaultDim->3, Pd[a, DE@0]->a*H, PdT[a, PdVars[DE@0,DE@0]] -> a H^2 - a H^2 \[Epsilon],
9 | Pd[H, DE@0]->-\[Epsilon]*H*H, PdT[H, PdVars[DE@0,DE@0]] -> 2 H^3 \[Epsilon]^2 - H^3 \[Epsilon] \[Eta],
10 | PdT[H, PdVars[DE@0,DE@0,DE@0]] -> -6 H^4 \[Epsilon]^3 + 7 H^4 \[Epsilon]^2 \[Eta] - H^4 \[Epsilon] \[Eta]^2 - H^4 \[Epsilon] \[Eta] \[Eta]2,
11 | Pd[\[Epsilon], DE@0]->H*\[Epsilon]*\[Eta], Pd[\[Eta], DE@0] -> H*\[Eta]2*\[Eta], Pd[\[Eta]2, DE@0] -> H*\[Eta]3*\[Eta]2 }
12 | LapseN = 1 + Eps * \[Alpha]
13 | ShiftN[DN@i_] := Eps * Pd[\[Beta], DN@i] + Eps * b[DN@i]
14 | PdT[b[DN@i_], PdVars[DN@i_, ___]]:= 0
15 | b /: b[DN@i_] k[DN@i_]:= 0 (* Above expression in momentum space. *)
16 | Sqrtg:= LapseN*Exp[3*Eps*\[Zeta]] * a^3
17 |
18 | UseMetric[h]
19 | h[DN@i_, DN@j_]:= a * a * Exp[2*Eps*\[Zeta]] * Dta[DN@i, DN@j]
20 | h[UP@i_, UP@j_]:= Exp[-2*Eps*\[Zeta]] * Dta[DN@i, DN@j] /a /a
21 |
22 | (* 4d metric is used to be decomposed and be replaced. *)
23 | DecompHook = {
24 | g[DN@i_, DN@j_]:> h[DN@i, DN@j],
25 | g[DE@0, DE@0]:> (-LapseN^2 + h[UP@#1, UP@#2]ShiftN[DN@#1]ShiftN[DN@#2] &@Uq[2]),
26 | g[DE@0, DN@i_]:> ShiftN[DN@i],
27 | g[UP@i_, UP@j_]:> (h[UP@i, UP@j] - ShiftN[DN@#1]ShiftN[DN@#2]h[UP@#1, UP@i]h[UP@#2, UP@j]/LapseN^2 &@Uq[2]),
28 | g[UE@0, UE@0]:> -1/LapseN^2,
29 | g[UE@0, UP@i_]:> (h[UP@i, UP@#]ShiftN[DN@#]/LapseN^2 &@Uq[1])}
30 |
31 |
32 | SetAttributes[DecompG2H, HoldAll]
33 | DecompG2H[f_]:= Decomp0i@WithMetric[g, {UTot, DTot}, MetricContract[f]]
34 |
35 | PdT[k|Eps, _]:=0
36 | fourier2RuleList = Dispatch@{PdT[f_, PdVars[DN@i_, DN@i_, j___]] :> -k^2 PdT[f, PdVars[j]],
37 | PdT[f_, PdVars[DN@i_, a___]] PdT[g_, PdVars[DN@i_, b___]] :> k^2 PdT[f, PdVars[a]] PdT[g, PdVars[b]],
38 | PdT[f_, PdVars[DN@i_, j___]]^2 :> k^2 PdT[f, PdVars[j]]^2,
39 | PdT[f_, PdVars[DN@i_, j___]] b_[DN@i_] :> -I k[DN@i] PdT[f, PdVars[j]] b[DN@i]}
40 |
41 | Fourier2[e_]:= (e//.fourier2RuleList//Expand)//.fourier2RuleList
42 |
43 |
44 | EndPackage[]
--------------------------------------------------------------------------------
/util.m:
--------------------------------------------------------------------------------
1 | (* Yi Wang, 2013, tririverwangyi@gmail.com, GPLv3 *)
2 | BeginPackage["MathGR`util`", {"MathGR`tensor`"}]
3 |
4 | SolveExpr::usage = "SolveExpr[eqs, exprs] is a wraper of Solve[eqs, exprs], but now exprs can now be composed expression instead of atom"
5 | TReplace::usage = "TensorReplace[expr, rule] replaces expr using rule. times2prod is used to avoid power of dummy indices"
6 | TPower::usage = "TPower[expr, n] (where n is an integer) gives nth power of a tensor, taking care of the dummy indices"
7 | TSeries::usage = "TSeries[expr, {Eps, 0, n}] expands tensor expr wrt Eps"
8 | Eps::usage = "The perturbative expansion varible"
9 | CollectEps::usage = "CollectEps[vars, operation] First (outer) collects Eps, then (inner) collects vars, then apply operation"
10 | SS::usage = "SS[n] gives up to order n series in Eps"
11 | OO::usage = "OO[n] gives order n result in Eps"
12 | k::usage = "Default variable for Fourier transformation."
13 | LocalToK::usage = "LocalToK[term, optional:id] transforms a local term into Fourier space."
14 |
15 | Begin["`Private`"]
16 | Needs["MathGR`utilPrivate`"]
17 |
18 | PdT[Eps, _]:=0
19 |
20 | SolveExpr[eqs_, exprsRaw_] := Module[{exprs = Flatten@{exprsRaw}, repList},
21 | repList = Unique[] /@ exprs;
22 | Solve[eqs /. (exprs~replaceTo~repList), repList] /. (repList~replaceTo~exprs)]
23 |
24 | TReplace[expr_, rule_]:= prod2times[times2prod[expr] /. f_prod:>Map[#/.rule&, f] //. rule]
25 | TReplace[rule_][expr_]:= TReplace[expr, rule]
26 | TPower[expr_, n_Integer]:= Power[Product[expr, {i,Abs@n}],Sign@n]
27 |
28 | applyProtect[f_, e_]:=Module[{eLocal}, f //. g_ e^m_. /; FreeQ[g,protected] :> protectProd[g] eLocal^m /. eLocal -> e ];
29 | protectProd[f_]:=protected[Times@@#[[1]]]Times@@#[[2]]&@ {Select[#,FreeQ[#,Eps]&],Select[#,!FreeQ[#,Eps]&]} &@ times2list @ f;
30 | TSeries[f_,{e_,e0_,n_}]:=Series[applyProtect[f,e],{e,e0,n}]/.{protected[g_]^m_:>Product[SimpUq[g],{i,m}], protected->SimpUq};
31 |
32 | CollectEps[vars_:{tmp}, op_:Simp][f_]:= Collect[f, Eps, Collect[#, vars, op]&]
33 | SS[n_, vars_:{tmp}, op_:Simp][f_]:= CollectEps[vars, op]@Normal@TSeries[f,{Eps,0,n}]
34 | OO[n_, vars_:{tmp}, op_:Simp][f_]:= CollectEps[vars, op]@Coefficient[SS[n, vars, op][f], Eps, n]
35 |
36 | Options[LocalToK]={"Momentum"->k};
37 | LocalToK[expr_, id_:DN, OptionsPattern[]]:= apply2term[LocalToKTerm[#, id, OptionValue@"Momentum"]&, expr];
38 |
39 | LocalToKTerm[term_, id_: DN, kk_: k]:= Module[{cnt = 0, vars, pvars, testId, ruleK, ruleP, ruleR},
40 | vars = DeleteDuplicates[Variables[term] /. PdT[f_, __] :> f];
41 | pvars = Alternatives @@ Select[vars, Pd[#, id@testId] =!= 0 &];
42 | ruleK := (v : pvars) :> (cnt++; v[kk[cnt]]);
43 | ruleP := PdT[f_[kf_kk], PdVars[i : (_id ..), etc___]] :> Apply[Times, kf /@ {i}] PdT[f[kf], PdVars[etc]];
44 | ruleR := f_[i:(IdxPtn|_UE|_DE) ..][k0_kk] :> f[k0][i];
45 | term /. ruleK /. ruleP /. ruleR];
46 |
47 | End[]
48 | EndPackage[]
--------------------------------------------------------------------------------
/decomp.m:
--------------------------------------------------------------------------------
1 | (* Yi Wang, 2013, tririverwangyi@gmail.com, GPLv3 *)
2 | BeginPackage["MathGR`decomp`", {"MathGR`tensor`"}]
3 |
4 | Decomp::usage = "Decomp[expr, rule, idx_:dummy] decomposes idx into parts. If idx not given, decompose all dummy indices"
5 | Decomp0i::usage = "Decomp0i[expr, idx_:dummy] 1+d decomposition"
6 | Decomp01i::usage = "Decomp01i[expr, idx_:dummy] 1+1+d decomposition"
7 | Decomp1i::usage = "Decomp1i[expr, idx_:dummy] 1+d decomposition"
8 | Decomp123::usage = "Decomp123[expr, idx_:dummy] 3-idx into 1+1+1"
9 | Decomp0123::usage = "Decomp0123[expr, idx_:dummy] 4-idx into 1+1+1+1"
10 | DecompSe::usage = "DecompSe[expr, idx_:dummy] N-idx into m+n in general"
11 | DecompHook::usage = "Replacements after decomposition"
12 |
13 | Begin["`Private`"]
14 | Needs["MathGR`utilPrivate`"]
15 |
16 | DeclareIdx[{UTot, DTot}, DimTot, LatinCapitalIdx, Blue]
17 | DeclareIdx[{U1, D1}, Dim1, GreekIdx, Black]
18 | DeclareIdx[{U2, D2}, Dim2, LatinIdx, Red]
19 |
20 | If[!defQ@DecompHook,DecompHook = {}]
21 | (*SetAttributes[{Decomp0i, Decomp01i, Decomp0123, Decomp}, HoldFirst]*)
22 |
23 | Decomp[HoldPattern@SeriesData[x_, n_, coeffList_List, orders__], decRule_, idList___] :=
24 | SeriesData[x, n, Decomp[#, decRule, idList]& /@ coeffList, orders];
25 |
26 | Decomp[e_, decRule_, idList___] /;FreeQ[e, SeriesData] := apply2term[decompTerm[#, decRule,
27 | Alternatives@@Cases[decRule[[1]], (tid_[_] -> _) :> tid, Infinity](* this is type of idx, like DTot|TTot *), idList]&, e]
28 |
29 | decompTerm[t_, decRule_, idPtn_]:= Module[{totDummy},
30 | totDummy = Cases[Tally[ Cases[t, idPtn[a_]:>a,Infinity] ], {a_,2}:>a];
31 | decompTerm[t, decRule, idPtn, totDummy]]
32 |
33 | decompTerm[t_, decRule_, idPtn_, idList_List]:= Module[{s=t, rule, id},
34 | Do[ rule = #[id]& /@ decRule;
35 | If[(*Cases[s, Apply[Alternatives, #1 & @@@ rule[[1]]], Infinity] =!= {}, *) (* Should work the same as below *)
36 | (s/.rule[[1]])=!=s (*decompose only when idx exists*),
37 | s = Total[s/.rule//.DecompHook]], {id, idList}];
38 | s//.DecompHook]
39 |
40 | decompTerm[a_. (op:SimpInto1)[b_], decRule_, idPtn_, idList_List] /; !FreeQ[b, IdxPtn] :=
41 | decompTerm[a, decRule, idPtn, idList] * Op@Decomp[b, decRule, idList]
42 | decompTerm[a_. Power[b_, c_], decRule_, idPtn_, idList_List] /; !FreeQ[{b,c}, IdxPtn] && c=!=2 :=
43 | decompTerm[a, decRule, idPtn, idList] * Power[Decomp[b, decRule, idList], Decomp[c, decRule, idList]]
44 |
45 | Decomp0i[e_, i___]:= Decomp[e, {{DTot@#->DE@0, UTot@#->UE@0}&, {DTot@#->DN@#, UTot@#->UP@#}&}, i]
46 | Decomp01i[e_, i___]:= Decomp[e, {{DTot@#->DE@0, UTot@#->UE@0}&, {DTot@#->DE@1, UTot@#->UE@1}&, {DTot@#->DN@#, UTot@#->UP@#}&}, i]
47 | Decomp0123[e_, i___]:= Decomp[e, {{DTot@#->DE@0, UTot@#->UE@0}&, {DTot@#->DE@1, UTot@#->UE@1}&, {DTot@#->DE@2, UTot@#->UE@2}&, {DTot@#->DE@3,UTot@#->UE@3}&}, i]
48 | Decomp1i[e_, i___]:= Decomp[e, {{DTot@#->DE@1, UTot@#->UE@1}&, {DTot@#->DN@#, UTot@#->UP@#}&}, i]
49 | Decomp123[e_, i___]:= Decomp[e, {{DTot@#->DE@1, UTot@#->UE@1}&, {DTot@#->DE@2, UTot@#->UE@2}&, {DTot@#->DE@3,UTot@#->UE@3}&}, i]
50 | DecompSe[e_, i___] := Decomp[e, {{DTot@# -> D2@#, UTot@# -> U2@#}&, {DTot@# -> D1@#, UTot@# -> U1@#}&}, i]
51 |
52 | End[]
53 | EndPackage[]
--------------------------------------------------------------------------------
/gr.m:
--------------------------------------------------------------------------------
1 | (* ::Package:: *)
2 |
3 | (* Yi Wang, 2013, tririverwangyi@gmail.com, GPLv3 *)
4 | BeginPackage["MathGR`gr`", {"MathGR`tensor`"}]
5 |
6 | WithMetric::usage = "WithMetric[g, expr] calculates expr with metric g. It does not change the default metric"
7 | UseMetric::usage = "UseMetric[g] chooses g for contraction and calculation of affine ane curvatures. UseMetric[g, False] set attributes for g, but don't set g as default metric."
8 | Metric::usage = "The current metric for contraction, affine and curvatures"
9 | g::usage = "The default metric for contraction, affine and curvatures"
10 | IdxOfMetric::usage = "The indices used with the metric"
11 | DG::usage = "MetricContract pairs with lower idx"
12 | UG::usage = "MetricContract pairs with upper idx"
13 | MetricContract::usage = "MetricContract[expr] contracts expr with metric. The contraction variables are marked as UG pairs or DG pairs"
14 |
15 | CovD::usage = "CovD[t, DN@idx] is covariant derivative"
16 | Dsquare::usage = "Dsquate[f] is the covariant derivative squared"
17 | Affine::usage = "Affine[UP@a, DN@b, DN@c] is the affine connection calculated from Metric"
18 | R::usage = "Riemann, Ricci tensors and Ricci scalar"
19 | Rsimp::usage = "Ricci tensor and Ricci scalar, pre-simplified into metric"
20 | G::usage = "The Einstein tensor"
21 | K::usage = "Extrinic curvature"
22 | KK::usage = "[KK]"
23 | RADM::usage = "The ADM curvature, equal to R up to a total derivative"
24 | LapseN::usage = "The lapse function"
25 | ShiftN::usage = "The shift vector"
26 | X::usage = "X[field] gives -g[UP@a, UP@b]Pd[field,DN@a]PD[field,DN@b]/2"
27 | T::usage = "The stress tensor of a canonical scalar field"
28 | V::usage = "The potential of a canonical scalar field"
29 |
30 | Begin["`Private`"]
31 | Needs["MathGR`utilPrivate`"]
32 |
33 | iu:=IdxOfMetric[[1]]
34 | id:=IdxOfMetric[[2]]
35 | isu[a_]:=Head@a===iu
36 | isd[a_]:=Head@a===id
37 |
38 | SetAttributes[{WithMetric, UseMetric}, HoldAll]
39 |
40 | WithMetric[g_, idx_:{UP, DN}, e_]:= (UseMetric[g, idx, "SetAsDefault"->False];
41 | Block[{Metric=g, IdxOfMetric=idx}, e])
42 | Options[UseMetric]={"SetAsDefault"->True}
43 | UseMetric[g_, idx_:{UP, DN}, OptionsPattern[]]:= Module[{u=idx[[1]], d=idx[[2]], ids},
44 | If[OptionValue["SetAsDefault"], Metric = g; IdxOfMetric = idx]; (* When default=False, only set attributes, but don't set Metric *)
45 | DeclareSym[g, {u,u}, Symmetric[{1,2}]];
46 | DeclareSym[g, {d,d}, Symmetric[{1,2}]];
47 | (*g /: g[u@a_, d@b_]:= Dta[u@a, d@b];*) (* this is replaced by below because say, g[_UTot, _DTot] should also have g[_U1, _D1]=Dta*)
48 | If[Head@g[u@"a", d@"b"]===g (* g has not transformed to other things *), g /: g[i_@a_, j_@b_]/;i===IdxDual@j := Dta[i@a,j@b]];
49 | If[Head@g[u@"a", u@"b"]===g && Head@g[d@"a", d@"b"]===g, g /: g[u@a_, u@c_]g[d@c_, d@b_]:= Dta[u@a, d@b]];
50 | If[Head@Pd[g[u@"a", u@"b"], d@"c"]===PdT, g /: Pd[g[u@m_, u@a_], d@l_]:= -g[u@#1, u@a]g[u@#2, u@m]Pd[g[d@#1, d@#2], d@l] &@Uq[2];];
51 | If[IntegerQ[Dim@u],
52 | DeclareSym[LeviCivita, ConstantArray[#, d], Antisymmetric[All]]& /@ ids;
53 | LeviCivita /: LeviCivita[a:((u|d)[_]..)]*LeviCivita[b:((u|d)[_]..)]:= DtaGen[a, b, "DtaGenDta"->g]; ]]
54 |
55 | UseMetric[g]
56 |
57 | MetricContract[e_]:= mcTerm~apply2term~e
58 | mcTerm[tRaw_]:=Module[{t, cnt=1, idTab, metrics, tmp=Unique[]},
59 | t = times2prod[tRaw] /. {(f:UG|DG)[n_]:>f[n, cnt++]}; (* make contraction labels unique *)
60 | idTab = Cases[t, _UG|_DG, Infinity] // Gather[#,(#1/.f_[a_,b_]:>a)===(#2/.f_[a_,b_]:>a)&]&; (* construct idx list of the metric *)
61 | metrics = Times@@ReplaceAll[(Metric@@@idTab),{DG->UG,UG->DG}]; (* construct metric *)
62 | metrics*t /.{(f:UG|DG)[n_,m_]:>f[tmp[n,m]]}/.{UG->iu,DG->id} // prod2times]
63 |
64 | freeUD:= Function[x,Intersection[x,MathGR`tensor`Private`free@#]] /@ {Cases[times2prod@#, iu[a_]:>a, Infinity], Cases[times2prod@#, id[a_]:>a, Infinity] }&
65 | freeUDSample:= freeUD[getSampleTerm@#]&
66 |
67 | CovD[t_, m_?isd]:=Module[{uf, df, uniq=Unique[]},
68 | {uf, df} = freeUDSample[Expand@t];
69 | Pd[t,m] + Sum[Affine[i,m,id@uniq](t/.i->iu@uniq),{i,iu/@uf}] - Sum[Affine[iu@uniq,m,i](t/.i->id@uniq),{i,id/@df}]]
70 |
71 | CovD[t_, m_?isu] := With[{n = Unique[]},
72 | g[m, (Head@m)@n] CovD[t, IdxDual[Head@m] @ n]]
73 |
74 | With[{g:=Metric, r:=Affine},
75 | r[i_?isu, m_?isd, n_?isd]:= 1/2 g[i, iu@#](Pd[g[id@#, m], n] + Pd[g[id@#, n], m] - Pd[g[m, n], id@#]) &@Uq[1];
76 | R[l_?isu, m_?isd, n_?isd, s_?isd]:= Pd[r[l,m,s],n]-Pd[r[l,m,n],s]+r[iu@#,m,s]r[l,id@#,n]-r[iu@#,m,n]r[l,id@#,s] &@Uq[1];
77 | R[a_?isd, m_?isd, n_?isd, s_?isd]:= g[a, id@#]R[iu@#, m, n, s] &@Uq[1];
78 | R[m_?isd, n_?isd]:= R[iu@#, m, id@#, n] &@Uq[1];
79 | R[]:= R[DG@1,DG@1]//MetricContract;
80 | G[m_?isd, n_?isd]:= R[m,n] - 1/2 g[m,n] R[];
81 | G[m_?isu, n_?isd]:= g[m,iu@#1]G[id@#1,n] &@Uq[1];
82 | G[m_?isd, n_?isu]:= g[n,iu@#1]G[m,id@#1] &@Uq[1];
83 | G[m_?isu, n_?isu]:= g[m,iu@#1]g[n,iu@#2] G[id@#1,id@#2] &@Uq[2];
84 | K[i_?isd, j_?isd]:= 1/(2 LapseN)(Pd[g[i,j],DE@0]-CovD[ShiftN[i],j]-CovD[ShiftN[j],i]);
85 | K[]:= K[DG@1,DG@1]//MetricContract;
86 | KK[]:= K[DG@1,DG@2]K[DG@1,DG@2]//MetricContract;
87 | RADM[]:= R[]-K[]K[]+KK[];
88 | X[f_]:= -Pd[f,DG@1]Pd[f,DG@1]/2//MetricContract;
89 | Dsquare[f_]:= CovD[CovD[f, DG@1], DG@1]//MetricContract;
90 | T[f_][i_?isd, j_?isd]:= g[i,j](X[f] - V[f]) + Pd[f, i] Pd[f, j];
91 | (* Some pre-simplified quantities *)
92 | Rsimp[]:= (3*g[iu[#1], iu[#2]]*g[iu[#3], iu[#4]]*g[iu[#5], iu[#6]]*Pd[g[id[#1], id[#3]], id[#5]]* Pd[g[id[#2], id[#4]], id[#6]])/4 - (g[iu[#1], iu[#2]]*g[iu[#3], iu[#4]]*g[iu[#5], iu[#6]]* Pd[g[id[#1], id[#3]], id[#6]]*Pd[g[id[#2], id[#5]], id[#4]])/2 - g[iu[#1], iu[#2]]*g[iu[#3], iu[#4]]*g[iu[#5], iu[#6]]*Pd[g[id[#1], id[#3]], id[#4]]* Pd[g[id[#2], id[#5]], id[#6]] - (g[iu[#1], iu[#2]]*g[iu[#3], iu[#4]]*g[iu[#5], iu[#6]]* Pd[g[id[#1], id[#2]], id[#5]]*Pd[g[id[#3], id[#4]], id[#6]])/4 + g[iu[#1], iu[#2]]*g[iu[#3], iu[#4]]*g[iu[#5], iu[#6]]*Pd[g[id[#1], id[#2]], id[#4]]* Pd[g[id[#3], id[#5]], id[#6]] - g[iu[#1], iu[#2]]*g[iu[#3], iu[#4]]* Pd[Pd[g[id[#1], id[#2]], id[#3]], id[#4]] + g[iu[#1], iu[#2]]*g[iu[#3], iu[#4]]* Pd[Pd[g[id[#1], id[#3]], id[#2]], id[#4]] &@Uq[6];
93 | Rsimp[m_?isd, n_?isd]:= -(g[iu[#1], iu[#2]]*g[iu[#3], iu[#4]]*Pd[g[m, n], id[#4]]*Pd[g[id[#1], id[#2]], id[#3]])/4 + (g[iu[#1], iu[#2]]*g[iu[#3], iu[#4]]*Pd[g[m, n], id[#4]]*Pd[g[id[#1], id[#3]], id[#2]])/2 - (g[iu[#1], iu[#2]]*g[iu[#3], iu[#4]]*Pd[g[id[#1], id[#3]], id[#4]]*Pd[g[id[#2], m], n])/2 + (g[iu[#1], iu[#2]]*g[iu[#3], iu[#4]]*Pd[g[id[#1], n], id[#3]]*Pd[g[id[#2], m], id[#4]])/2 - (g[iu[#1], iu[#2]]*g[iu[#3], iu[#4]]*Pd[g[id[#1], id[#3]], id[#4]]*Pd[g[id[#2], n], m])/2 + (g[iu[#1], iu[#2]]*g[iu[#3], iu[#4]]*Pd[g[id[#1], id[#3]], n]*Pd[g[id[#2], id[#4]], m])/4 + (g[iu[#1], iu[#2]]*g[iu[#3], iu[#4]]*Pd[g[id[#1], id[#2]], id[#4]]*Pd[g[id[#3], m], n])/4 - (g[iu[#1], iu[#2]]*g[iu[#3], iu[#4]]*Pd[g[id[#1], n], id[#4]]*Pd[g[id[#3], m], id[#2]])/2 + (g[iu[#1], iu[#2]]*g[iu[#3], iu[#4]]*Pd[g[id[#1], id[#2]], id[#4]]*Pd[g[id[#3], n], m])/4 - (g[iu[#1], iu[#2]]*Pd[Pd[g[m, n], id[#1]], id[#2]])/2 + (g[iu[#1], iu[#2]]*Pd[Pd[g[id[#1], m], n], id[#2]])/2 + (g[iu[#1], iu[#2]]*Pd[Pd[g[id[#1], n], m], id[#2]])/2 - (g[iu[#1], iu[#2]]*Pd[Pd[g[id[#1], id[#2]], m], n])/2 &@Uq[4];
94 | ]
95 |
96 | End[]
97 |
98 | EndPackage[]
99 |
--------------------------------------------------------------------------------
/ibp.m:
--------------------------------------------------------------------------------
1 | (* ::Package:: *)
2 |
3 | (* Yi Wang, 2013, tririverwangyi@gmail.com, GPLv3 *)
4 | BeginPackage["MathGR`ibp`", {"MathGR`tensor`"}]
5 |
6 | TrySimp::usage = "TrySimp[expr, rule, rank] try to minimaize rank[expr] by applying rule"
7 | TrySimp2::usage = "TrySimp2[expr, rule, rank] try to minimaize rank[expr] by applying up to second order rules"
8 | Ibp::usage = "Ibp[expr, rank] do integration by parts and try to minimaize rank[expr]"
9 | IbpNB::usage = "IbpNB[f__] is Ibp, with boundary term set to zero"
10 | Pm2Rules::usage = "Rules to simplify Pm2 expressions"
11 | Pm2Simp::usage = "Simplify Pm2 using Pm2Rules"
12 | Ibp2::usage = "Ibp[expr, rank] do integration by parts and try to minimaize rank[expr]. Second order rules are tried"
13 | IbpRules::usage = "a list of rules to do ibp"
14 | PdHold::usage = "Total derivative"
15 | IdHold::usage = "Held identities"
16 | IbpCountLeaf::usage = "IbpCountLeaf[e] counts leaves of e outside PdHold or IdHold"
17 | IbpCountTerm::usage = "IbpCountTerm[e] counts terms of e outside PdHold or IdHold"
18 | IbpCountPt2::usage = "IbpCountPt2[e] counts second time derivatives"
19 | IbpCountPd2::usage = "IbpCountPd2[e] counts second derivatives"
20 | IbpRuleWithForbiddenPatterrn::usage = "IbpRuleWithForbiddenPatterrn[rule, ptn][e] is Infinity (i.e. forbidden transformation) if e contains ptn, otherwise return rule[e]"
21 | IbpVar::usage = "IbpVar[var][e] counts Pd on specified var"
22 | IbpStd2::usage = "Ibp count trying to bring second order Lagrangian to standard form"
23 | IbpVariation::usage = "IbpVariation[e, var] is Ibp which eliminates derivative on var"
24 | IbpReduceOrder::usage = "IbpReduceOrder[vars_List][e] counts power of vars"
25 | TrySimpPreferredPattern::usage = "a pattern which Ibp tries to keep"
26 | TrySimpPreferredPatternStrength::usage = "How strongly TrySimpPreferredPattern is preferred"
27 | Begin["`Private`"]
28 | Needs["MathGR`utilPrivate`"]
29 |
30 | try[rule_, rank_, 0][e_]:= e
31 |
32 | If[!defQ@TrySimpPreferredPattern, TrySimpPreferredPattern={}];
33 | If[!defQ@TrySimpPreferredPatternStrength, TrySimpPreferredPatternStrength=10^-4];
34 | TrySimpRank[rankf_][e_]:= rankf[e] - TrySimpPreferredPatternStrength Count[{e/.holdPtn->0}, TrySimpPreferredPattern, Infinity];
35 |
36 | tryCropList = take[#, 100]&
37 | (*tryCropList = Take[#, IntegerPart[Length@#/3.0]+1] &*)
38 | (*tryCropList = Identity*)
39 |
40 | try[rule_, rankRaw_, level_Integer?Positive][eRaw_]:= Module[{e, trials, tryRulesOnList, sortByRank, replaceListOnList, rank},
41 | replaceListOnList = Map[ReplaceList[#, rule]&, #]&;
42 | rank = TrySimpRank@rankRaw;
43 | e = try[rule, rank, level-1] @ eRaw;
44 | sortByRank=SortBy[#, rank]&;
45 | tryRulesOnList = tryCropList @ sortByRank @ DeleteDuplicates @ Flatten @ replaceListOnList @ # &;
46 | trials = Nest[tryRulesOnList, {e}, level];
47 | If[trials=!={} && rank@trials[[1]]ToString[level]<>", with rank "<>ToString@CForm@N@rank@trials[[1]] ]; trials[[1]];
50 | try[rule, rank, level][trials[[1]]],
51 | PrintTemporary["No improvement found at level "<>ToString[level]<>". Try harder or stop."];e] ]
52 |
53 | Options[TrySimp] = {"Rank"->LeafCount, "Level"->1}
54 | TrySimp[e_, rule_, OptionsPattern[]]:= try[rule, OptionValue@"Rank", OptionValue["Level"]][e]
55 |
56 |
57 | (* ::Section:: *)
58 | (* Below are IBP rules and rank functions *)
59 |
60 |
61 | PdHold[0,_]:=0
62 | PdHold /: -PdHold[a_,c_]:=PdHold[-a,c]
63 | PdHold /: n_?NumericQ PdHold[a_,c_]:=PdHold[n a,c]
64 | PdHold /: PdHold[a_,c_]+PdHold[b_,c_]:= PdHold[a+b,c]
65 | PdHold[a_,id_[c_]]/;c!="(PdId)"&&!FreeQ[a,c]&&id=!=DE:=PdHold[a/.c:>"(PdId)",id@"(PdId)"]
66 |
67 | Simp[b_. + f_. PdHold[a_,c_], opt:OptionsPattern[]]:= Simp[b, opt] + Simp[f, opt] PdHold[Simp[a, opt],c]
68 | Simp[b_. + f_. IdHold[a_], opt:OptionsPattern[]]:= Simp[b, opt] + Simp[f, opt] IdHold[Simp[a, opt]]
69 |
70 | Pm2Rules = Dispatch@{(* Note: Pm2 is defined in momentum space. Thus there is no well-defined boundary term *)
71 | x_. + a_ Pm2[b_, type_] /; Pd[a, type@testVar]=!=0 :> x + Simp[Pm2[a, type] b],
72 | x_. + a_ PdT[Pm2[b_, type_], PdVars[e__]] /; Pd[a, type@testVar]=!=0 :> x + Simp[Pm2[a, type] PdT[b, PdVars[e]]],
73 | x_. + a_. Pm2[ g_ PdT[f_, PdVars[type_@i_, type_@i_, e___]] , type_] :>
74 | x + Simp[ a (PdT[f, PdVars[e]] g - 2 Pm2[PdT[f, PdVars[type@i, e]] Pd[g, type@i], type] - Pm2[PdT[f, PdVars[e]] Pd[Pd[g, type@i], type@i], type]) ],
75 | x_. + b_. Pm2 [a_. f_ PdT[f_, PdVars[type_@i_, type_@i_]] , type_] :>
76 | x + Simp[ (b/2) ( a f^2 - Pm2[ Pd[Pd[a, type@i], type@i] f^2 + 4 Pd[a, type@i] f Pd[f, type@i] + 2 a Pd[f, type@i]^2 , type] ) ],
77 | x_. + b_. Pm2 [a_. PdT[h_, PdVars[e___]] PdT[h_, PdVars[type_@i_, type_@i_, e___]] , type_] :> With[{f = PdT[h, PdVars[e]]},
78 | x + Simp[ (b/2) ( a f^2 - Pm2[ Pd[Pd[a, type@i], type@i] f^2 + 4 Pd[a, type@i] f Pd[f, type@i] + 2 a Pd[f, type@i]^2 , type] ) ]]}
79 |
80 | IbpRules = Dispatch@({
81 | (*a_. PdT[b_, PdVars[c_, etc___]] + e_. :> PdHold[a PdT[b, PdVars[etc]], c] + e - Simp[PdT[b, PdVars[etc]] Pd[a,c]],*)
82 | a_. PdT[b_, PdVars[c_, etc___]]^n_. + e_. :> Simp[PdHold[a PdT[b, PdVars[etc]] PdT[b, PdVars[c, etc]]^(n-1), c] - PdT[b, PdVars[etc]] Pd[a PdT[b, PdVars[c, etc]]^(n-1), c]] + e,
83 | a_. PdT[b_, PdVars[c_, d_, etc___]] + e_. :> Simp[PdHold[a PdT[b, PdVars[d, etc]], c] - PdHold[PdT[b, PdVars[etc]] Pd[a, c], d] + PdT[b, PdVars[etc]] PdT[a, PdVars[c,d]]]+ e,
84 | a_. b_^n_. PdT[b_, PdVars[c_]] + e_. :> e + Simp[ PdHold[a b^(n+1)/(n+1), c] - b^(n+1) Pd[a, c] / (n+1) ] /;n=!=-1,
85 | a_. PdT[b_, PdVars[etc___]]^n_. PdT[b_, PdVars[c_, etc___]] + e_. :> e + Simp[ PdHold[a PdT[b, PdVars[etc]]^(n+1) / (n+1), c] - PdT[b, PdVars[etc]]^(n+1) Pd[a, c] / (n+1) ] /;n=!=-1,
86 |
87 | h_. + g_. PdT[t_, PdVars[a_, b_, e___]]^2 :> With[{f=PdT[t, PdVars[e]]}, h + Simp[
88 | PdHold[g Pd[Pd[f,a],b]Pd[f,b], a] - PdHold[g Pd[Pd[f,a],a]Pd[f,b], b] - Pd[g,a]Pd[Pd[f,a],b]Pd[f,b] + Pd[g,b]Pd[Pd[f,a],a]Pd[f,b] + g Pd[Pd[f,a],a]Pd[Pd[f,b],b] ]],
89 |
90 | PdT[f_,PdVars[a_,e1___]]PdT[g_,PdVars[b_,e2___]]h_. + n_. /; Order[a,b]>=0 :> Simp[PdHold[PdT[f,PdVars[e1]] Pd[PdT[g,PdVars[e2]],b]h, a] - PdHold[PdT[f,PdVars[e1]] Pd[PdT[g,PdVars[e2]],a]h, b]
91 | + Pd[PdT[f,PdVars[e1]],b]Pd[PdT[g,PdVars[e2]],a]h + PdT[f,PdVars[e1]] Pd[PdT[g,PdVars[e2]],a]Pd[h,b] - PdT[f,PdVars[e1]] Pd[PdT[g,PdVars[e2]],b] Pd[h,a]] + n,
92 | (* some special higher order rules *)
93 | x_. + f_. PdT[z_, PdVars[a_, e___]]PdT[z_, PdVars[b_, c_, e___]] /; Order[a,b]>=0 && MatchQ[a, IdxPtn] && MatchQ[b, IdxPtn] && !FreeQ[f,a] && !FreeQ[f,b]&& Expand[f-(f/.{a->b,b->a})]===0 :>
94 | x + Simp[PdHold[f PdT[z, PdVars[a, e]]PdT[z, PdVars[b, e]]/2, c] - Pd[f,c]PdT[z, PdVars[a, e]]PdT[z, PdVars[b, e]]/2],
95 | x_. + f_. PdT[h_, PdVars[c_, e___]]PdT[h_, PdVars[a_, b_, e___]]PdT[h_, PdVars[a_, b_, e___]] /; Order[a,b]>=0 :> With[{g=PdT[h,PdVars[e]]},
96 | x + Simp[PdHold[f Pd[g,c]Pd[g,b]Pd[Pd[g,a],b] - f Pd[g,b]^2 Pd[Pd[g,a],c]/2 - Pd[f,a] Pd[g,b]^2 Pd[g,c]/2, a]
97 | - PdHold[f Pd[g,c]Pd[g,b]Pd[Pd[g,a],a], b] + PdHold[f Pd[g,b]^2 Pd[Pd[g,a],a]/2, c]
98 | + f Pd[g,c]Pd[Pd[g,a],a]Pd[Pd[g,b],b] - Pd[f,c]Pd[g,b]^2 Pd[Pd[g,a],a]/2
99 | + Pd[f,b]Pd[g,c]Pd[g,b]Pd[Pd[g,a],a] + Pd[Pd[f,a],a]Pd[g,c]Pd[g,b]^2/2 + Pd[f,a]Pd[Pd[g,a],c]Pd[g,b]^2] ],
100 | (*x_. + f_. g_ PdT[g_, PdVars[a_,b_,b_]] :> x + Simp[PdHold[f g Pd[Pd[g,a],b], b] - PdHold[f Pd[g,b]^2/2, a] - Pd[f,b] g Pd[Pd[g,a],b] + Pd[f,a]Pd[g,b]^2/2],*)
101 | x_. + f_. PdT[h_, PdVars[c_, e___]]PdT[h_, PdVars[a_, b_, e___]] \
102 | /; Order[a,b]>=0 && MatchQ[a, IdxPtn] && MatchQ[b, IdxPtn] && !FreeQ[f,a] && !FreeQ[f,b] && Expand[f-(f/.{a->b,b->a})]===0 (* make sure a and b are summation indices, and f actually depends on a, b and is symmetric *) \
103 | :> With[{g=PdT[h,PdVars[e]]}, x + Simp[PdHold[f Pd[g,c]Pd[g,b], a] - PdHold[f Pd[g,a]Pd[g,b]/2, c] -Pd[f,a]Pd[g,c]Pd[g,b] + Pd[f,c]Pd[g,a]Pd[g,b]/2] ]} ~Join~ Normal[Pm2Rules])
104 |
105 | Options[Ibp] = {"Rule":>IbpRules, "Rank"->IbpCountLeaf, "Level"->1}
106 | Ibp[e_, OptionsPattern[]]:= try[OptionValue@"Rule", OptionValue@"Rank", OptionValue["Level"]][Simp@e]
107 | IbpNB[e__]:= Block[{PdHold=0&}, Ibp[e]]
108 |
109 | holdPtn=_PdHold|_IdHold
110 | IbpCountLeaf[e_]:= Count[{e/.holdPtn->0}, PdT[v_[DE@0,___],PdVars[__]], Infinity] * 10^-7 + LeafCount[e/.holdPtn->0] * 10^-5 + Count[{e/.holdPtn->0}, Pm2[__]] * 10^-3 + Count[{e/.holdPtn->0}, Pm2[Times[f__], _] * 10^-1 ]
111 | IbpCountTerm[e_]:=Length[expand2list[e/.holdPtn->0]] * 10^-5 + Count[{e/.holdPtn->0}, Pm2[__]] * 10^-3 + Count[{e/.holdPtn->0}, Pm2[Times[f__], _] * 10^-1 ]
112 | IbpCountPt2[e_]:= Count[{e/.holdPtn->0}, PdT[_, PdVars[_DE, _DE, ___]], Infinity] + IbpCountLeaf[e]
113 | IbpCountPd2[e_]:= Count[{e/.holdPtn->0}, PdT[_, PdVars[IdxPtn, IdxPtn, ___]], Infinity] + IbpCountLeaf[e]
114 | IbpVar[var_][e_]:= 10000*Count[{e/.holdPtn->0}, Pd[Pd[Pd[a_/;!FreeQ[a, var], _],_],_], Infinity] + 100*Count[{e/.holdPtn->0}, Pd[Pd[a_/;!FreeQ[a, var], _],_], Infinity] + Count[{e/.holdPtn->0}, Pd[a_/;!FreeQ[a, var], _], Infinity] + IbpCountLeaf[e]
115 | IbpStd2[e_]:= IbpCountPt2[e]*1000 + IbpCountPd2[e]*100 + Count[{e/.holdPtn->0}, v_*Pd[v_,_]*_ | PdT[v_, PdVars[a__]]*PdT[v_, PdVars[b_,a__]]*_, Infinity]*10 + Count[{e/.holdPtn->0}, PdT[v_[DE@0,___],PdVars[DE@0,___]], Infinity] + IbpCountLeaf[e]
116 |
117 | IbpRuleWithForbiddenPatterrn[rule_, ptn_][e_]:= If[!FreeQ[e,ptn],Infinity, rule[e]];
118 | (* For example: Ibp[#,"Rank"\[Rule]IbpRuleWithForbiddenPatterrn[IbpCountLeaf,PdHold[_,_DN]]]& (* Only time derivative, no space derivative *) *)
119 |
120 | IbpReduceOrder[vars_List][e_]:=Module[{eOrderList, tmp},
121 | eOrderList = Count[{#}, Alternatives@@vars, Infinity] & /@ times2prod@expand2list[e+tmp /.holdPtn->0];
122 | Total[100^(5-#)&/@eOrderList]-100^5 + IbpCountLeaf[e] + IbpCountTerm[e]]
123 |
124 | IbpVariation[e_, v_]:= FixedPoint[Replace[#, a_. + b_.*PdT[f_, PdVars[i_, j___]] /; FreeQ[b, v] && ! FreeQ[f, v] :> a - Simp[PdT[f, PdVars[j]]*Pd[b, i]]] &, Simp[e]]
125 |
126 | Pm2Simp[e_]:= TrySimp[Simp@e, Pm2Rules, "Rank"->IbpCountLeaf]
127 |
128 | End[]
129 | EndPackage[]
130 |
--------------------------------------------------------------------------------
/resources/test.m:
--------------------------------------------------------------------------------
1 | (* Test setup *)
2 | startTestTime=SessionTime[]
3 | testPassed={};
4 | testFailed={};
5 |
6 | streamMsg = OpenWrite["test_message.txt"];
7 | $Messages = {streamMsg};
8 |
9 | SetAttributes[test,HoldAll]
10 | testPrecision=10^-7;
11 | test[in_,out_,tagRaw_:"Unspecified"]:=Module[{tag},
12 | tag=If[tagRaw==="Unspecified",HoldForm@in, tagRaw];
13 | If[in==out || Abs[in-out] <= testPrecision,
14 | testPassed~AppendTo~tag; Return[]];
15 | testFailed~AppendTo~{tag,
16 | "\n\tInput: " <> (ToString@HoldForm@InputForm@in) <>
17 | "\n\tCalculated: " <> (ToString@InputForm@in) <>
18 | "\n\tExpected: " <> (ToString@InputForm@out)}; Last@testFailed]
19 |
20 | testReport[]:= Module[{str="", addLine},
21 | addLine:=(str=str<>Apply[StringJoin, ToString/@{##}]<>"\n")&;
22 | addLine["\nTest Report on ", DateString[]];
23 | addLine["Number of tests: ", Length@testPassed + Length@testFailed, "\n"];
24 | If[Length@testFailed===0,
25 | addLine["All tests passed."],
26 | addLine["Failed tests: ", Length@testFailed]; addLine[#1, " ", #2]& @@@ testFailed];
27 | Print@OutputForm@str;
28 | Export["test_result.txt", str]];
29 |
30 | <<"MathGR/MathGR.m"
31 |
32 | (* ::Section:: *)
33 | (* Tests for tensor.m *)
34 |
35 | ClearAll[u, d, dimTest, f, f1, f2, f3, g, undefined]
36 |
37 | (* ::Subsection:: *)
38 | (* DeclareIdx *)
39 |
40 | DeclareIdx[{u,d}, dimTest, LatinIdx, Blue]
41 | test[
42 | MemberQ[IdxList, u] && MemberQ[IdxList, d] && MemberQ[IdxUpList, u] && MemberQ[IdxDnList, d],
43 | True, "DeclareIdx idx lists"]
44 | test[
45 | MatchQ[u["a"], IdxPtn] && MatchQ[d["a"], IdxPtn] && MatchQ[u["a"], IdxUpPtn] && MatchQ[d["a"], IdxDnPtn],
46 | True, "DeclareIdx idx patterns"]
47 | test[
48 | IdxDual[u]==d && IdxDual[d]==u && IdxSet[u]==LatinIdx && IdxSet[d]==LatinIdx
49 | && IdxColor[u]==Blue && IdxColor[d]==Blue && Dim[u]==dimTest && Dim[d]==dimTest,
50 | True, "DeclareIdx properties"]
51 |
52 | (* ::Subsection:: *)
53 | (* Dta *)
54 |
55 | test[f[u@"a", f1[u@"b"]]Dta[u@"b", u@"c"], f[u@"a", f1[u@"c"]], "Dta up-up, with nest func"]
56 | test[f[u@"a", d@"b"]Dta[u@"b", d@"c"], f[u@"a", d@"c"], "Dta up-dn"]
57 | test[f[d@"a", d@"b"]Dta[d@"b", d@"c"], f[d@"a", d@"c"], "Dta dn-dn"]
58 | test[f[u@"a", u@"b"]Dta[d@"b", d@"c"], f[u@"a", u@"c"], "Dta does not raise/lower idx"]
59 | test[Dta[u@"a", u@"c"]Dta[u@"b", u@"c"], Dta[u@"a", u@"b"], "Dta-Dta contraction up-up"]
60 | test[Dta[u@"a", d@"c"]Dta[d@"b", u@"c"], Dta[u@"a", d@"b"], "Dta-Dta contraction up-dn"]
61 | test[Dta[d@"a", d@"c"]Dta[d@"b", d@"c"], Dta[d@"a", d@"b"], "Dta-Dta contraction dn-dn"]
62 | test[Dta[u@"a", u@"a"]==dimTest && Dta[u@"a", d@"a"]==dimTest && Dta[d@"a", d@"a"]==dimTest
63 | && Dta[u@"a", u@"b"]Dta[u@"a", u@"b"]==dimTest && Dta[u@"a", u@"b"]Dta[d@"a", d@"b"]==dimTest
64 | && Dta[u@"a", d@"b"]Dta[u@"a", d@"b"]==dimTest
65 | && Dta[u@"a", u@"b"]Dta[u@"b", u@"c"]Dta[u@"c", u@"d"]Dta[u@"d", u@"a"]==dimTest,
66 | True, "Dta sum"]
67 | test[Dta[UE@1, DE@0]==0 && Dta[UE@1, DE@1]==1, True, "Dta explicit idx"]
68 |
69 | test[DtaGen[UP@"a", UP@"b", DN@"m", DN@"n"],-Identity[Dta][DN["m"], UP["b"]] Identity[Dta][DN["n"], UP["a"]] +
70 | Identity[Dta][DN["m"], UP["a"]] Identity[Dta][DN["n"], UP["b"]], "DtaGen"]
71 |
72 | (* ::Subsection:: *)
73 | (* LeviCivita *)
74 |
75 | DeclareIdx[{u3,d3}, 3, LatinIdx, Brown]
76 | test[LeviCivita[u3@"a", u3@"b", u3@"c"] LeviCivita[d3@"d", d3@"e", d3@"f"], -Identity[Dta][d3["d"], u3["c"]] Identity[Dta][d3["e"], u3["b"]] Identity[Dta][
77 | d3["f"], u3["a"]] +
78 | Identity[Dta][d3["d"], u3["b"]] Identity[Dta][d3["e"], u3["c"]] Identity[Dta][
79 | d3["f"], u3["a"]] +
80 | Identity[Dta][d3["d"], u3["c"]] Identity[Dta][d3["e"], u3["a"]] Identity[Dta][
81 | d3["f"], u3["b"]] -
82 | Identity[Dta][d3["d"], u3["a"]] Identity[Dta][d3["e"], u3["c"]] Identity[Dta][
83 | d3["f"], u3["b"]] -
84 | Identity[Dta][d3["d"], u3["b"]] Identity[Dta][d3["e"], u3["a"]] Identity[Dta][
85 | d3["f"], u3["c"]] +
86 | Identity[Dta][d3["d"], u3["a"]] Identity[Dta][d3["e"], u3["b"]] Identity[Dta][
87 | d3["f"], u3["c"]], "2 LeviCivita's"]
88 | test[LeviCivita[u3@"a", u3@"b", u3@"c"] LeviCivita[d3@"a", d3@"d", d3@"e"], -Identity[Dta][d3["d"], u3["c"]] Identity[Dta][d3["e"], u3["b"]] +
89 | Identity[Dta][d3["d"], u3["b"]] Identity[Dta][d3["e"], u3["c"]], "LeviCivita contract 1"]
90 | test[LeviCivita[u3@"a", u3@"b", u3@"c"] LeviCivita[d3@"a", d3@"b", d3@"d"], 2 Identity[Dta][d3["d"], u3["c"]], "LeviCivita contract 2"]
91 | test[LeviCivita[u3@"a", u3@"b", u3@"c"] LeviCivita[d3@"a", d3@"b", d3@"c"], 6, "LeviCivita contract 3"]
92 |
93 | UseMetric[g3, {u3,d3}]
94 | test[LeviCivita[u3@"a", u3@"b", u3@"c"] LeviCivita[u3@"d", u3@"e", u3@"f"], -(g3[u3["a"], u3["f"]]*g3[u3["b"], u3["e"]]*g3[u3["c"], u3["d"]]) + g3[u3["a"], u3["e"]]*g3[u3["b"], u3["f"]]*g3[u3["c"], u3["d"]] + g3[u3["a"], u3["f"]]*g3[u3["b"], u3["d"]]*g3[u3["c"], u3["e"]] - g3[u3["a"], u3["d"]]*g3[u3["b"], u3["f"]]*g3[u3["c"], u3["e"]] - g3[u3["a"], u3["e"]]*g3[u3["b"], u3["d"]]*g3[u3["c"], u3["f"]] + g3[u3["a"], u3["d"]]*g3[u3["b"], u3["e"]]*g3[u3["c"], u3["f"]], "LeviCivita up up"]
95 |
96 | (* ::Subsection:: *)
97 | (* Sym, Asym *)
98 |
99 | test[Sym[f[d@"a",d@"b"]],f[d@"a",d@"b"]+f[d@"b",d@"a"], "Sym"]
100 | test[AntiSym[f[d@"a",d@"b"]],f[d@"a",d@"b"]-f[d@"b",d@"a"], "AntiSym"]
101 |
102 | (* ::Subsection:: *)
103 | (* Pd *)
104 |
105 | test[Pd[Dta[u@"a", d@"b"], d@"c"]==0 && Pd[Sin[1], d@"c"]==0&& Pd[dimTest, d@"c"]==0,
106 | True, "Pd on constants"]
107 | test[Pd[f[u@"a"]g+h[u@"a"], d@"b"],
108 | Pd[f[u@"a"], d@"b"]g+f[u@"a"]Pd[g, d@"b"]+Pd[h[u@"a"], d@"b"], "Pd add and times"]
109 | test[Pd[undefined, d@"x"], Pd[undefined, d@"x"], "PD on unknown var"]
110 | test[Pd[a_,d@b_]:>f[a,b],Pd[a_,d@b_]:>f[a,b], "Pattern is not considered as background or constant"]
111 |
112 | (* ::Subsection:: *)
113 | (* Pm2 *)
114 | test[x Pm2[(a + b)^2, DN] // Simp, x*Pm2[a^2, DN] + 2*x*Pm2[a*b, DN] + x*Pm2[b^2, DN], "Pm2 expand"]
115 | test[PdT[f0test, PdVars[_DN, ___]] := 0; Pm2[f0test g, DN], f0test*Pm2[g, DN], "Pm2 constant"]
116 | test[Pd[Pm2[PdT[f[DN@"a"], PdVars[DN@"b", DE@0]], DN], DN@"b"], PdT[f[DN["a"]], PdVars[DE[0]]], "Pm2 on Pd2"]
117 | (* ::Subsection:: *)
118 | (* Simp Fast *)
119 |
120 | test[Simp[f[u@"x", d@"b"] f1[d@"b"], "Method"->"Fast"], f[u["x"], d["a"]] f1[d["a"]], "SimpF re-arrange idx"]
121 |
122 | (* ::Subsection:: *)
123 | (* Simp on patterns *)
124 | (* note: patterns can only be on free indices *)
125 | test[Simp[f[DN@a_,DN@c_]x[UP@d_,UP@b_]], f[DN@a_,DN@c_]x[UP@d_,UP@b_], "Simp with patterns"]
126 |
127 | (* ::Subsection:: *)
128 | (* DeclareSym *)
129 |
130 | test[DeclareSym[fTmp, {UP, UP, DE@0, DN, DN}, Symmetric[{1, 2}]], {Symmetric[{1, 2}]}, "DeclareSym"]
131 | test[DeclareSym[fTmp, {UP, UP, DE@0, DN, DN}, Symmetric[{3, 4}]], {Symmetric[{1, 2}], Symmetric[{3, 4}]}, "DeclareSym combination"]
132 |
133 | DeclareSym[fTmp, {UP, UP, DE@0, UP, UP}, Symmetric[{1, 2, 3, 4}]]
134 | test[Attributes[fTmp], {Orderless}, "set orderless for symmetric All"]
135 | test[DeleteSym[fTmp, {UP, UP, DE@0, UP, UP}], Null, "DeleteSym"]
136 | test[Attributes[fTmp], {}, "remove orderless for symmetric All"]
137 |
138 | (* ::Subsection:: *)
139 | (* Simp *)
140 | DeclareSym[f3, {DN, DN, DN, DN}, Symmetric[{1, 2}]];
141 | DeclareSym[f3, {DN, DN, DN, DN}, Antisymmetric[{3, 4}]];
142 | test[f3[DN@"i", DN@"j", DN@"i", DN@"j"] // Simp, 0, TestID -> "SimpM symmetric"]
143 | test[Pd[f3[DN@"i", DN@"j", DN@"i", DN@"j"], DN@"k"] // Simp, 0, TestID -> "SimpM antisymmetric"]
144 |
145 | test[Pd[f3[d@"i", DE@0, d@"i", DE@0],d@"k"] // Simp, Pd[f3[d["a"], DE[0], d["a"], DE[0]], d["k"]], "SimpM with explicit idx"]
146 | test[c[D2@"b", D2@"c", U2@"a"] A[U2@"b", DN@"\[Mu]"] A[U2@"c",DN@"\[Nu]"] // Simp,
147 | A[U2["b"], DN["\[Mu]"]] A[U2["c"], DN["\[Nu]"]] c[D2["b"], D2["c"], U2["a"]], "Simp with free idx sorted"]
148 |
149 | (*test[Exp[1+ff[DN@"a"] gg[DN@"a"]]//Simp, Exp[1+ff[DN@"a0"] gg[DN@"a0"]], "Simp through Exp"]*)
150 | (*test[Sqrt[1+ff[DN@"a"] gg[DN@"a"]]//Simp, Sqrt[1+ff[DN@"a0"] gg[DN@"a0"]], "Simp through Power"]*)
151 | test[(Series[(1+Eps xx)(1+Eps yy)(1+Eps zz)ff[DN@"a"], {Eps,0,1}]//Simp//Normal)/.Eps->1, (1+xx+yy+zz)ff[DN@"a"]//Expand, "Simp through SeriesData"]
152 |
153 | test[a^2 (f[UP@"a"]^4 + 1) // Simp, a^2 + a^2 f[UP["a"]]^2 f[UP["b"]]^2, "Simp with higher than standard powers"]
154 |
155 | (* ::Subsection:: *)
156 | (* private functions in tensor.m and util.m *)
157 |
158 | <<"MathGR/utilPrivate.m"
159 | test[plus2list[1+a+c], {1, a, c}, "plus2list"]
160 | test[expand2list[1+2(a+c)], {1, 2a, 2c}, "expand2list"]
161 | test[apply2term[testf, 1+2(a+c)], testf[1]+testf[2a]+testf[2c], "apply2term"]
162 | test[getSampleTerm[2(a+c)], 2a, "getSampleTerm"]
163 | test[times2prod[a+b^3 c+d^n], a+prod[b,b,b,c]+d^n, "times2prod"]
164 | test[prod2times[a+prod[b,b,b,c]+d^n], a+b^3 c+d^n, "prod2times"]
165 | test[f[a,b,c]/.{a,b,c}~replaceTo~{x,y,z}, f[x,y,z], "replaceTo"]
166 |
167 | test[MathGR`tensor`Private`idx[a[u@"a", d@"b"]Pd[f[u@"c",u@"b"],d@"a"]], {"a","b","c","b","a"}, "idx"]
168 | test[MathGR`tensor`Private`idx[a[u@"a", d@"b"]Pd[f[u@"c",u@"b"],d@"a"]f[d@"x"]^2], {"a","b","x","x","c","b","a"}, "idx2"]
169 | test[MathGR`tensor`Private`free[a[u@"a", d@"b"]Pd[f[u@"c",u@"b"],d@"a"]f[d@"x"]^2], {"c"}, "free"]
170 | test[MathGR`tensor`Private`dummy[a[u@"a", d@"b"]Pd[f[u@"c",u@"b"],d@"a"]f[d@"x"]^2], {"a","b","x"}, "dummy"]
171 | test[MathGR`tensor`Private`pd2pdts[Pd[f[u@"a"],d@"a"]], MathGR`tensor`Private`pdts[1][f][u@"a", d@"a"], "Pd to pdts"]
172 | test[MathGR`tensor`Private`pdts2pd[MathGR`tensor`Private`pdts[1][f][u@"a", d@"a"]], Pd[f[u@"a"],d@"a"], "pdts to Pd"]
173 |
174 | test[MathGR`tensor`Private`rmE[{UE@0,u@"a",d@"b",DE@1,d@"c"}], {u@"a",d@"b",d@"c"}, "rmE"]
175 |
176 | (* ::Section:: *)
177 | (* Tests for gr.m *)
178 |
179 | UseMetric[g, {u,d}]
180 |
181 | (* ::Subsection:: *)
182 | (* MetricContract *)
183 |
184 | test[MetricContract[f[UG@1, DG@2]f1[UG@1, DG@2]] // Simp,
185 | f[u["a"], d["b"]]*f1[u["c"], d["d"]]*g[d["a"], d["c"]]*g[u["b"], u["d"]], "MetricContract"]
186 |
187 | (* ::Subsection:: *)
188 | (* Affine and curvature *)
189 |
190 | test[Affine[u@"a",d@"b",d@"c"]//Simp,
191 | -(g[u["a"], u["d"]]*Pd[g[d["b"], d["c"]], d["d"]])/2 + (g[u["a"], u["d"]]*Pd[g[d["b"], d["d"]], d["c"]])/2 + (g[u["a"], u["d"]]*Pd[g[d["c"], d["d"]], d["b"]])/2,
192 | "Affine"]
193 | test[R[]//Simp,
194 | (3*g[u["a"], u["b"]]*g[u["c"], u["d"]]*g[u["e"], u["f"]]*Pd[g[d["a"], d["c"]], d["e"]]*Pd[g[d["b"], d["d"]], d["f"]])/4 - (g[u["a"], u["b"]]*g[u["c"], u["d"]]*g[u["e"], u["f"]]*Pd[g[d["a"], d["c"]], d["f"]]*Pd[g[d["b"], d["e"]], d["d"]])/2 - g[u["a"], u["b"]]*g[u["c"], u["d"]]*g[u["e"], u["f"]]*Pd[g[d["a"], d["c"]], d["d"]]*Pd[g[d["b"], d["e"]], d["f"]] - (g[u["a"], u["b"]]*g[u["c"], u["d"]]*g[u["e"], u["f"]]*Pd[g[d["a"], d["b"]], d["e"]]*Pd[g[d["c"], d["d"]], d["f"]])/4 + g[u["a"], u["b"]]*g[u["c"], u["d"]]*g[u["e"], u["f"]]*Pd[g[d["a"], d["b"]], d["d"]]*Pd[g[d["c"], d["e"]], d["f"]] - g[u["a"], u["b"]]*g[u["c"], u["d"]]*Pd[Pd[g[d["a"], d["b"]], d["c"]], d["d"]] + g[u["a"], u["b"]]*g[u["c"], u["d"]]*Pd[Pd[g[d["a"], d["c"]], d["b"]], d["d"]],
195 | "Ricci scalar"]
196 |
197 | test[CovD[R[d@"a", d@"b", d@"c", d@"d"], d@"e"] + CovD[R[d@"a", d@"b", d@"d", d@"e"], d@"c"] + CovD[R[d@"a", d@"b", d@"e", d@"c"], d@"d"]// Simp, 0, "Second Bianchi of Riemann"]
198 |
199 | (* ::Subsection:: *)
200 | (* CovD *)
201 |
202 | test[CovD[f2 f[u@"a",d@"b"]f1[d@"c"] ,d@"d"]//Simp,
203 | f[u["a"], d["b"]]*f1[d["c"]]*Pd[f2, d["d"]] + f2*f1[d["c"]]*Pd[f[u["a"], d["b"]], d["d"]] + f2*f[u["a"], d["b"]]*Pd[f1[d["c"]], d["d"]] + (f2*f[u["a"], d["e"]]*f1[d["c"]]*g[u["e"], u["f"]]*Pd[g[d["b"], d["d"]], d["f"]])/2 - (f2*f[u["a"], d["e"]]*f1[d["c"]]*g[u["e"], u["f"]]*Pd[g[d["b"], d["f"]], d["d"]])/2 + (f2*f[u["a"], d["b"]]*f1[d["e"]]*g[u["e"], u["f"]]*Pd[g[d["c"], d["d"]], d["f"]])/2 - (f2*f[u["a"], d["b"]]*f1[d["e"]]*g[u["e"], u["f"]]*Pd[g[d["c"], d["f"]], d["d"]])/2 - (f2*f[u["e"], d["b"]]*f1[d["c"]]*g[u["a"], u["f"]]*Pd[g[d["d"], d["e"]], d["f"]])/2 - (f2*f[u["a"], d["e"]]*f1[d["c"]]*g[u["e"], u["f"]]*Pd[g[d["d"], d["f"]], d["b"]])/2 - (f2*f[u["a"], d["b"]]*f1[d["e"]]*g[u["e"], u["f"]]*Pd[g[d["d"], d["f"]], d["c"]])/2 + (f2*f[u["e"], d["b"]]*f1[d["c"]]*g[u["a"], u["f"]]*Pd[g[d["d"], d["f"]], d["e"]])/2 + (f2*f[u["e"], d["b"]]*f1[d["c"]]*g[u["a"], u["f"]]*Pd[g[d["e"], d["f"]], d["d"]])/2,
204 | "CovD"]
205 |
206 | (* ::Section:: *)
207 | (* Tests for ibp.m *)
208 |
209 | test[Ibp[y Pd[x, d@"a"] + x Pd[y, d@"a"] + f[d@"a"] + xx yy Pd[zz, d@"a"] + xx zz Pd[yy, d@"a"] + xxx Pd[yyy, d@"a"]],
210 | f[d@"a"] - yy zz Pd[xx, d["a"]] + xxx Pd[yyy, d["a"]] + PdHold[x y, d["a"]] + PdHold[xx yy zz, d["a"]], "Ibp CountLeaf"]
211 |
212 | test[Ibp[y Pd[Pd[x, DE@0], DE@0], "Rank"->IbpCountPt2], -Pd[x, DE[0]] Pd[y, DE[0]] + PdHold[y Pd[x, DE[0]], DE[0]], "Ibp CountPt2"]
213 |
214 | test[Ibp[y Pd[x, d@"i"], "Rank"->IbpVar[x]], -x Pd[y, d["i"]] + PdHold[x y, d["i"]], "IbpVar"]
215 |
216 | test[f Pm2[g, DN] - g Pm2[f, DN] // Ibp , 0, "Ibp on Pm2, rule 1"]
217 |
218 | test[Pm2[g*PdT[f, PdVars[DE[0], DN["i"], DN["i"]]], DN] + 2*Pm2[PdT[f, PdVars[DE[0], DN["i"]]]*PdT[g, PdVars[DN["i"]]], DN]//Ibp, g*PdT[f, PdVars[DE[0]]] - Pm2[PdT[f, PdVars[DE[0]]]*PdT[g, PdVars[DN["a"], DN["a"]]], DN], "Ibp on Pm2, rule 2"]
219 |
220 | (* ::Section:: *)
221 | (* Tests for decomp.m *)
222 |
223 | test[Sqrt[1 + f[DTot@"a"] f[UTot@"a"]] // Decomp0i, Sqrt[1 + f[DE[0]]*f[UE[0]] + f[DN["a"]]*f[UP["a"]]], "Decomp0i in sqrt"];
224 | test[fx[DTot@"A", UTot@"A"] - 1/(1 + f[DTot@"A", UTot@"A"]) // Decomp0i, -(1 + f[DE[0], UE[0]] + f[DN["A"], UP["A"]])^(-1) + fx[DE[0], UE[0]] + fx[DN["A"], UP["A"]], "Decomp0i ordinary term and power"];
225 |
226 |
227 | (* ::Section:: *)
228 | (* Tests for util.m *)
229 |
230 | test[LocalToK[2 x PdT[y, PdVars[DN@"a", DN@"b"]]], 2*x[k[1]]*y[k[2]]*k[2][DN["a"]]*k[2][DN["b"]], "LocalToK"];
231 |
232 | (* ::Section:: *)
233 | (* Cosmic perturbations *)
234 | Remove[a,b,h,f]
235 | Get["MathGR/util.m"]
236 | Get["MathGR/ibp.m"]
237 | Get["MathGR/frwadm.m"]
238 | DeclareIdx[{UP, DN}, DefaultDim, LatinIdx, Black]
239 | PdHold[__] := 0
240 | phi = phi0
241 | Evaluate[Pd[phi0, DN@_]] := 0
242 | s012 = Sqrtg (RADM[]/2 + Simp@DecompG2H[X[phi]] - V[phi] ) // SS[2]
243 | Print["Result of s012 =========="];Print[s012]
244 | s1 = s012 // OO[1]
245 | Print["Result of s1 =========="];Print[s1]
246 | SimpHook = SimpHook~Union~(SolveExpr[{D[s1, \[Alpha]] == 0, D[Ibp[s1, "Rank"->IbpVar[\[Zeta]]], \[Zeta]] == 0}, {V[phi0], Pd[phi0, DE@0]^2}][[1]])
247 | s2 = s012 // OO[2] // Fourier2 // Ibp
248 | Print["Result of s2 =========="];Print[s2]
249 | solCons = Solve[{D[s2, \[Alpha]] == 0, D[s2, \[Beta]] == 0, D[s2, b[DN@"a"]] == 0}, {\[Alpha], \[Beta], b[DN@"a"]}][[1]]
250 | s2Solved = s2 /. solCons // Ibp[#, "Rank"->IbpStd2] &
251 | Print["Result of s2Solved =========="];Print[s2Solved]
252 | test[s2Solved, -(a*k^2*\[Epsilon]*\[Zeta]^2) + a^3*\[Epsilon]*Pd[\[Zeta], DE[0]]^2, "zeta gauge 2nd order action"]
253 | PdHold[__]=.
254 |
255 | (* ::Section:: *)
256 | (* Decomposition *)
257 |
258 | test[Sqrt[f1[DTot["b"]]*f2[DTot["b"]]]//Decomp0i, Sqrt[f1[DE[0]]*f2[DE[0]] + f1[DN["b"]]*f2[DN["b"]]], "Decomp0i sqrt"]
259 | test[SeriesData[Eps, 0, {f1[DTot["a"]]*f2[DTot["a"]], Sqrt[f1[DTot["b"]]*f2[DTot["b"]]]}, 1, 3, 1]//Decomp0i,
260 | SeriesData[Eps, 0, {f1[DE[0]]*f2[DE[0]] + f1[DN["a"]]*f2[DN["a"]], Sqrt[f1[DE[0]]*f2[DE[0]] + f1[DN["b"]]*f2[DN["b"]]]}, 1, 3, 1], "Decomp0i Series" ]
261 |
262 | UseMetric[\[DoubleStruckG], {UTot, DTot}]
263 | UseMetric[\[Eta], {U1, D1}, "SetAsDefault" -> False]
264 | UseMetric[\[Gamma], {U2, D2}, "SetAsDefault" -> False]
265 |
266 | test[\[DoubleStruckG][U1@"a",D1@"b"], Dta[U1@"a",D1@"b"], "metric on other dual pairs of indices"]
267 | test[\[DoubleStruckG][UTot@"a",D1@"b"], \[DoubleStruckG][UTot@"a",D1@"b"], "metric on non-dual pairs of indices is unevaluated"]
268 |
269 | DecompHook={\[DoubleStruckG][D1[\[Alpha]_], D1[\[Beta]_]] :> (\[Eta][Sequence[D1[\[Alpha]], D1[\[Beta]]]] + A[Sequence[U2[#1], D1[\[Alpha]]]]*
270 | A[Sequence[U2[#1], D1[\[Beta]]]] & )[Uq[1]], \[DoubleStruckG][D1[\[Alpha]_], D2[b_]] :> A[Sequence[U2[b], D1[\[Alpha]]]],
271 | \[DoubleStruckG][U1[\[Alpha]_], U1[\[Beta]_]] :> \[Eta][Sequence[U1[\[Alpha]], U1[\[Beta]]]],
272 | \[DoubleStruckG][U1[\[Alpha]_], U2[b_]] :> ((-\[Eta][Sequence[U1[\[Alpha]], U1[#1]]])*A[Sequence[U2[b], D1[#1]]] & )[Uq[1]],
273 | \[DoubleStruckG][U2[a_], U2[b_]] :> (Dta[Sequence[U2[a], U2[b]]] + \[Eta][Sequence[U1[#1], U1[#2]]]*
274 | A[Sequence[U2[a], D1[#1]]]*A[Sequence[U2[b], D1[#2]]] & )[Uq[2]],
275 | \[DoubleStruckG][D2[a_], D2[b_]] :> Dta[Sequence[U2[a], U2[b]]]}
276 |
277 | Evaluate[Pd[\[Eta][__], _]] := 0;
278 | Evaluate[Pd[\[Gamma][__], _]] := 0;
279 | Evaluate[Pd[A[__], _D2]] := 0;
280 | Evaluate[Pd[Pd[A[__], _], _D2]] := 0;
281 |
282 | R\[Bullet]decomp = DecompSe[R[] // Simp]//Simp
283 |
284 | test[TrySimp[R\[Bullet]decomp, (a_.) + (b_.)*Pd[A[U2[m_], D1[\[Alpha]_]], D1[\[Beta]_]] :>
285 | a + Simp[b*(F[Sequence[U2[m], D1[\[Alpha]], D1[\[Beta]]]] + Pd[A[Sequence[U2[m], D1[\[Beta]]]], D1[\[Alpha]]])]],
286 | -(F[U2["a"], D1["\[Alpha]"], D1["\[Beta]"]]*Pd[A[U2["a"], D1["\[Gamma]"]], D1["\[Delta]"]]*\[Eta][U1["\[Alpha]"], U1["\[Gamma]"]]*
287 | \[Eta][U1["\[Beta]"], U1["\[Delta]"]])/2, "Decomposition of non-diag metric into Maxwell"]
288 |
289 | (* Generate report *)
290 | testReport[]
291 | Print["Total time used:", OutputForm[SessionTime[]-startTestTime]]
292 | Close[streamMsg];
293 |
--------------------------------------------------------------------------------
/tensor.m:
--------------------------------------------------------------------------------
1 | (* ::Package:: *)
2 |
3 | (* Yi Wang, 2013, tririverwangyi@gmail.com, GPLv3 *)
4 | BeginPackage["MathGR`tensor`"]
5 |
6 | DeclareIdx::usage = "DeclareIdx[ids_List, dim, set, color] defines dim, which set of idx to use and color for a pair of indices (upper, lower)"
7 | DeclareExplicitIdx::usage = "DeclareExplicitIdx[ids_List, color] defines a pair of explicit index and display color"
8 | IdxList::usage = "list of idx headers, e.g. {UP, DN}"
9 | IdxPtn::usage = "pattern of idx, e.g. _DN|_UP"
10 | IdxHeadPtn::usage = "Pattern of head of idx, e.g. DN|UP"
11 | IdxUpList::usage = "A list of upper index identifiers"
12 | IdxUpPtn::usage = "A pattern object to label upper index identifiers"
13 | IdxDnList::usage = "A list of lower index identifiers"
14 | IdxDnPtn::usage = "A pattern object to label lower index identifiers"
15 | IdxDual::usage = "IdxDual[identifier] gives dual index. E.g. IdxDual[UP] gives DN."
16 | IdxSet::usage = "Set of indices to use for a identifiers"
17 | IdxColor::usage = "IdxColor[idx] gives color for given idx"
18 |
19 | Dim::usage = "Dim[id] returns dimension associated with tensor index"
20 | DefaultDim::usage = "Default dimension of the tensors (with UP and DN)"
21 |
22 | UP::usage = "Default upper idx prefix"
23 | DN::usage = "Default lower idx prefix"
24 | UE::usage = "Explicit upper idx prefix"
25 | DE::usage = "Explicit lower idx prefix"
26 |
27 | (* Actually used in decomp.m. declared here so that typeset.m can use those variables in case of need *)
28 | UTot::usage = "Upper index in higher dimensions"
29 | DTot::usage = "Lower index in higher dimensions"
30 | U1::usage = "Upper index in first dimensions"
31 | D1::usage = "Lower index in first dimensions"
32 | U2::usage = "Upper index in second dimensions"
33 | D2::usage = "Lower index in second dimensions"
34 | DimTot::usage = "Dimension of the tensors, higher demension for decomposition."
35 | Dim1::usage = "Dimension of the tensors, first dimensions for decomposition."
36 | Dim2::usage = "Dimension of the tensors, second dimensions for decomposition."
37 |
38 | Uniq::usage = "Uniq[n] generates a list of Unique[] of length n"
39 | Uq::usage = "Uq[n] generates a sequence of Unique[] of length n"
40 | Sym::usage = "Sym[expr, {a, b, ...}] symmetrizes indices a, b, ... Sym[expr] symmetrizes all free indices"
41 | AntiSym::usage = "AntiSym[expr, {a, b, ...}] anti-symmetrizes indices a, b, ... AntiSym[expr] anti-symmetrizes all free indices"
42 |
43 | Dta::usage = "Delta symbol"
44 | DtaGen::usage = "DtaGen[up..., dn...] is the generalized delta symbol"
45 | Pd::usage = "Pd[f, DN@a] is partial derivative"
46 | PdT::usage = "PdT[f, PdVars[DN@a, DN@b, ...]] is partial derivative"
47 | PdVars::usage = "Pdvars[DN@a, DN@b, ...] is a list of derivative variables"
48 | P::usage = "P[DN@a, DN@b, ...][f] is partial derivative, which is internally converted to PdT"
49 | Pm2::usage = "Pm2[expr] is \\partial^{-2} expr. This inversed Laplacian should be understood in momentum space"
50 | LeviCivita::usage = "LeviCivita[a, b, ...] is the Levi Civita tensor, defined only if dimension is given as an explicit number"
51 |
52 | LatinIdx::usage = "strings {a, b, ..., }"
53 | GreekIdx::usage = "strings {alpha, beta, ...}"
54 | LatinCapitalIdx::usage = "strings {A, B, ...}"
55 | UniqueIdx::usage = "unique vars {$n1, $n2, ...}"
56 |
57 | DeclareSym::usage = "Declare tensor symmetry"
58 | DeleteSym::usage = "DeleteSym[tensor, {UP, DN, ...}] deletes tensor symmetry"
59 | ShowSym::usage = "ShowSym[tensor, {UP, DN, ...}] shows defined tensor symmetry"
60 | Simp::usage = "Simplification, which brings tensors into canonical form."
61 | SimpHook::usage = "Rules to apply before and after Simp"
62 | SimpSelect::usage = "A function to select terms to simplify, disregard others"
63 | SimpUq::usage = "SimpUq is identical to Simp[#, \"Dummy\"->UniqueIdx]&"
64 | SimpInto1::usage = "Pattern list of single variable functions that Simp should go into"
65 |
66 | TensorReplace::usage = "TensorReplace[expr, rel] or TensorReplace[rel][expr] does expr/.rel taking care of dummy indices in powers."
67 |
68 | \[Bullet]::usage = "Symbol for time derivative"
69 | \[CapitalSampi]::usage = "Symbol for general derivative"
70 |
71 | Begin["`Private`"]
72 | Needs["MathGR`utilPrivate`"]
73 |
74 | Uniq[n_Integer]:= Table[Unique[],{n}]
75 | Uq[n_Integer]:= Sequence@@Uniq[n]
76 | Uq[100]; (* Becaues of unknown reasons, the first 100 unique variables are much slower to use in some operations (that Simp used). *)
77 |
78 |
79 |
80 | (* ::Section:: *)
81 | (* Idx utilities *)
82 |
83 |
84 | LatinIdx = Join[FromCharacterCode /@ Range[97, 97 + 24], "y"<>ToString[#]&/@Range[26]]
85 | GreekIdx = Join[FromCharacterCode /@ Range[945, 945 + 24], "\[Omega]"<>ToString[#]&/@Range[26]]
86 | LatinCapitalIdx = Join[FromCharacterCode /@ Range[65, 65 + 24], "Y"<>ToString[#]&/@Range[26]]
87 | inFuncIdx= StringJoin[#,"0"] & /@ LatinIdx
88 | UniqueIdx:= Unique[]& /@ Range[50]
89 |
90 | SetAttributes[Dta, Orderless]
91 | PdT[_Dta, PdVars[__]]:= 0
92 |
93 | Options[DtaGen]={"DtaGenDta"->Dta}
94 | DtaGen[ids:(_[_]..), OptionsPattern[]]:= Module[{btmp, tmp, i, d=Length[{ids}]/2, a, b},
95 | a = Take[{ids}, d]; b = Take[{ids}, -d];
96 | btmp = MapThread[#1[#2] &, {(b[[#]][[0]] & /@ Range[d]), tmp /@ Range[d]}];
97 | AntiSym[Product[OptionValue["DtaGenDta"][a[[i]], btmp[[i]]], {i, d}],btmp]/. (btmp[[#]]->b[[#]] &/@Range[d])]
98 |
99 | DeclareIdx[ids_List, d_, set_List, color_]:= Module[{idsAlt=Alternatives@@ids}, PdT[d, PdVars[__]]:=0;
100 | Dim[idsAlt]:=d; IdxSet[idsAlt]:=set; IdxColor[idsAlt]:=color; add2set[IdxList, {ids}]; IdxHeadPtn=Alternatives@@IdxList; IdxPtn=Alternatives@@(Blank/@IdxList);
101 | IdxDual[ids[[1]]]=ids[[2]]; IdxDual[ids[[2]]]=ids[[1]];
102 | idxIdentity[ids[[1]]] = idxIdentity[ids[[2]]] = Unique[];
103 | add2set[IdxUpList,ids[[1]]]; IdxUpPtn=Alternatives@@(Blank/@IdxUpList);
104 | add2set[IdxDnList,ids[[2]]]; IdxDnPtn=Alternatives@@(Blank/@IdxDnList);
105 | Dta[idsAlt@a_, idsAlt@a_]:= d;
106 | Dta/:Power[Dta[idsAlt@a_, idsAlt@b_], 2]:= d;
107 | Dta/:HoldPattern[Times][f__, Dta[(a:idsAlt)@m_, (b:idsAlt)@n_]]
108 | /; !FreeQ[Hold[f], (ids[[1]][Verbatim@n])|(ids[[2]][Verbatim@n])|(ids[[1]][Verbatim@m])|(ids[[2]][Verbatim@m])]
109 | := Piecewise[{{Times[f]/.(c:idsAlt)@Verbatim@n -> c@m, !FreeQ[Hold[f], (ids[[1]][Verbatim@n])|(ids[[2]][Verbatim@n])]},
110 | {Times[f]/.(c:idsAlt)@Verbatim@m -> c@n, !FreeQ[Hold[f], (ids[[1]][Verbatim@m])|(ids[[2]][Verbatim@m])]}}, Times[f, Dta[a@m, b@n]]];
111 | If[IntegerQ[d],
112 | DeclareSym[LeviCivita, ConstantArray[#, d], Antisymmetric[All]]& /@ ids;
113 | LeviCivita /: LeviCivita[a:(ids[[1]][_]..)]*LeviCivita[b:(ids[[2]][_]..)]:= DtaGen[a,b]; ]]
114 |
115 | DeclareIdx[{UP, DN}, DefaultDim, LatinIdx, Black]
116 |
117 | IdxColor[UE|DE]=Gray;
118 | Dta[(UE|DE)@i_, (UE|DE)@j_]:= KroneckerDelta[i, j]
119 | rmE = DeleteCases[#, _UE|_DE]&
120 |
121 | idx:= Cases[times2prod@#,a:IdxPtn:>a[[1]],Infinity]& (* only find indices with Einstein convention *)
122 | free:= Cases[Tally[idx@#], {a_,1}:>a] &
123 | dummy:= Cases[Tally[idx@#], {a_,2}:>a] &
124 | getFreeSample:= free[getSampleTerm@#]&
125 |
126 | Sym[e_, iList_]:= Plus@@ ( (e/.(iList~replaceTo~#)&) /@ Permutations[iList] )
127 | AntiSym[e_, iList_]:= Signature[iList] * Plus@@ ( (Signature[#] e/.(iList~replaceTo~#)&) /@ Permutations[iList] )
128 | Sym[e_]:= Sym[e, free@e]
129 | AntiSym[e_]:= AntiSym[e, free@e]
130 |
131 |
132 |
133 | (* ::Section:: *)
134 | (* Partial derivative *)
135 |
136 |
137 | Pd[a_Plus, i_]:= Pd[#,i]& /@ a
138 | Pd[a_*b_, i_]:= Pd[a,i]*b + a*Pd[b,i]
139 | Pd[f_^g_, i_]:= f^(g-1)*g*Pd[f,i] + f^g*Log[f]*Pd[g,i]
140 | Pd[a_?NumericQ, i_]:=0
141 |
142 | Pd[f_, i_]:= Piecewise[{
143 | {PdT[f, PdVars[i]], FreeQ[f, PdT]},
144 | {PdT[f[[1]], PdVars[i, Sequence@@f[[2]]]], Head[f]===PdT},
145 | {Pm2[Pd[f[[1]], i], f[[2]]], Head[f]===Pm2} },
146 | Message[PdT::nonpoly, f];PdT[f, PdVars[i]]]
147 |
148 | SetAttributes[PdVars, Orderless]
149 | PdT::nonpoly="Pd acting on non-polynomial objects (as `1`) is not supported."
150 | PdT[f_, PdVars[]]:= f
151 | PdT[a_?NumericQ, PdVars[__]]:=0
152 | PdT[f_/;MatchQ[Head[f],Plus|Times|Power|Pd|PdT], PdVars[i__]]:= Fold[Pd, f, {i}]
153 |
154 | pd2pdts[expr_]:= expr /. PdT[f_, i_] :> If[FreeQ[f, IdxPtn|_UE|_DE], pdts[Length@i][f][Sequence@@i], pdts[Length@i][Head@f][Sequence@@f, Sequence@@i]]
155 | pdts2pd = #/. pdts[n_][f_][i__] :> If[n==Length@{i}, PdT[f, PdVars[i]], PdT[f@@Take[{i}, Length@{i} - n], PdVars@@Take[{i}, -n]]] &
156 |
157 | Pm2[f_. Power[a_Plus, n_.], type_] /; IntegerQ[n]&&0<=n<5 := Pm2[f #, type]& /@ Expand[a^n]
158 | Pm2[f_*g_, type_] /; Pd[f, type@testVar]===0 := f Pm2[g, type]
159 | Pm2[PdT[f_, PdVars[i__]], type_]:= PdT[Pm2[f, type], PdVars[i]]
160 | PdT[Pm2[f_, type_], PdVars[type_@i_, type_@i_, etc___]]:= PdT[f, PdVars[etc]]
161 |
162 | P[i___][f_]:=PdT[f, PdVars[i]]
163 |
164 |
165 |
166 | (* ::Section:: *)
167 | (* Declare and delete symmetries *)
168 |
169 |
170 | TensorDimensions[MAT[_][g__]] ^:= Dim[#] & /@ rmE[{g}];
171 | TensorRank[MAT[_][g__]] ^:= Length @ rmE @ {g};
172 | TensorSymmetry[MAT[_][___]] ^:= {};
173 |
174 | TensorSymmetry[MAT[pdts[n_][t_]][i__]] ^:= Module[{tId = rmE @ Drop[{i}, -n] (* idx in t *), dId = rmE @ Take[{i}, -n] (* idx of derivative *), symT},
175 | symT = TensorSymmetry[MAT[t]@@tId] /. All:>{1, Length @ tId};
176 | If[Length@dId>1 && Length@DeleteDuplicates[dId]===1 (* only one type of id *), symT ~Join~ {Symmetric[Range[Length@tId+1, Length@tId+Length@dId]]}, symT] ];
177 |
178 | DeclareSym::difi = "Symmetries cannot be declared on indices with different identifiers. Symmetries not declared."
179 | DeclareSym[t_, id_, sym_] := Module[{thisSym, totSym, explicitAll=Range@Length@rmE@id},
180 | (* make sure thisSym is a list of symmetries, instead of a single symmetry *)
181 | thisSym = If[MatchQ[sym, _Symmetric|_Antisymmetric|List[_Cycles, __]] || (Head[sym]===List && Depth[sym]===3 (* a single permutation list *)), {sym}, sym];
182 | thisSym = thisSym /. All -> explicitAll; (* All does not work for internal handling of tensor symmetry *)
183 | If[MatchQ[#, _Symmetric|_Antisymmetric],
184 | If[Length@DeleteDuplicates@Part[rmE@id, #[[1]]]=!=1, Message[DeclareSym::difi]]; Return[] (* check Symmetric or Antisymmetric *),
185 | If[$VersionNumber>8.99, If[Permute[rmE@id, #[[1]] ] =!= rmE@id, Message[DeclareSym::difi]]; Return[] (* check permutation lists or cycles *) ]] & /@ thisSym;
186 | If[thisSym === {Symmetric[explicitAll]}, SetAttributes[t, Orderless]];
187 | If[$VersionNumber>8.99, totSym = DeleteCases[#, {} | _TensorSymmetry]& @ Union[TensorSymmetry[MAT[t][Sequence @@ id]] ~Join~ thisSym]]; (* delete cases (unknown symmetry) to avoid recursion *)
188 | MAT /: TensorSymmetry[MAT[t][Sequence @@ id]] = totSym]
189 |
190 | DeleteSym[t_, id_] := (ClearAttributes[t, Orderless]; MAT /: TensorSymmetry[MAT[t][Sequence @@ id]] =. )
191 |
192 | ShowSym[t_, id_] := TensorSymmetry[MAT[t][Sequence @@ id]]
193 |
194 |
195 |
196 | (* ::Section:: *)
197 | (*Other helpful functions*)
198 |
199 |
200 | TensorReplace[expr_,rel_]:= prod2times[times2prod[expr]/.rel]
201 | TensorReplace[rel_][expr_]:=TensorReplace[expr,rel]
202 |
203 |
204 | (* ::Section:: *)
205 | (* Simp functions *)
206 |
207 |
208 | Simp::overdummy = "Index `1` appears `2` times in `3`"
209 | Simp::diffree = "Free index in term `1` is different from that of first term (`2`)"
210 | Simp::ld = "Warning: Memory constraint reached in `1`, simplification skipped"
211 | Simp::tsrInFunc="Thesors detected in more than one functions at `1`. Result may be wrong.";
212 |
213 | SimpUq:= Simp[#, "Dummy"->UniqueIdx]&
214 |
215 | tReduceMaxMemory=10^9 (* 1GB max memory *)
216 | (* After TensorReduce, TensorContract and TensorTranspose are replaced to undefined functions.
217 | Otherwise those functions may evaluate during transformation of expressions, which may cause problem, and also waste time. *)
218 | tReduce[e_]:= MemoryConstrained[TensorReduce[e], tReduceMaxMemory, Message[Simp::ld, term]; e] /. {TensorContract->tContract}
219 | If[!defQ@SimpSelect, SimpSelect = Identity]
220 | If[!defQ@SimpHook, SimpHook = {}]
221 | SetAttributes[Simp, HoldFirst] (* Otherwise passing expression into Simp could take long. E.g. dBianchi2, ~30 000 terms, takes 8 seconds merely passing expression *)
222 | Options[Simp] = {"Method"->If[$VersionNumber>8.99, "Hybrid", "Fast"] (* Fast for simple pass only *), "Dummy"->Automatic (* or UniqueIdx *), "Parallel"->False (* or True *) }
223 |
224 | Simp[f_, opt:OptionsPattern[]]:= simpPower[Expand[f, Power], opt];
225 |
226 | (* simpPower: treatment of power in the expansion. The recipe is as follows: for g f^n, where n is a positive integer, and f has index in it:
227 | (Q1) indices in f are free indince?
228 | Q1-yes: (Q2) Does g share same free indices with f? || Is n an odd number?
229 | Q2-yes: fire overdummy error.
230 | Q2-no: (Q3) n==2?
231 | Q3-yes: proceed to SimpInFunc
232 | Q3-no: expand f^n into Power[SimpUq[f^2]*SimpUq[f^2]...*SimpUq[f^2], Sign[n]]
233 | Q2-no: expand f^n into SimpUq[f]*SimpUq[f]...*SimpUq[f]
234 | *)
235 |
236 | simpPower[a_. + g_. Power[f_, n_Integer], opt:OptionsPattern[Simp]] /; idx[f]=!={} && n>0 := If[free[f]=!={},
237 | If[Intersection[free[g],free[f]]=!={} || OddQ[n],
238 | Message[Simp::overdummy, "", "more than two", g*f^n]; a + g*f^n,
239 | If[n===2,
240 | Simp[a, opt] + simpInFunc[g * f^2, opt],
241 | Simp[a, opt] + simpInFunc[g * Product[SimpUq[f^2], {i, n/2}], opt] ] ],
242 | Simp[a, opt] + simpInFunc[g * Product[SimpUq@f, {i, n}], opt] ]
243 |
244 | simpPower[f_, opt:OptionsPattern[Simp]]:= simpInFunc[Expand@f, opt];
245 |
246 | (* List of single argument functions where simpInFunc operates into its arguments (with Unique dummies). *)
247 | If[!defQ@inFuncChoice, inFuncChoice:= inFuncIdx]; (* or inFuncChoice:= UniqueIdx *)
248 | SimpInto1 = Exp|Sin|Cos|Sinh|Cosh;
249 | simpInFunc[a_. + b_. (op:SimpInto1)[c_], opt:OptionsPattern[Simp]] /; !FreeQ[c, IdxPtn] :=
250 | simpInFunc[a, opt] + simpInFunc[b, opt] op[Simp[c, "Dummy"->inFuncChoice]];
251 | (* The same thing for Power[c, d]. Note that Power[c,2] is not included here since (f_a)^2 can be dealt with simpInFunc directly. *)
252 | simpInFunc[a_. + b_. Power[c_, d_], opt:OptionsPattern[Simp]] /; !FreeQ[{c,d}, IdxPtn] && !(d==2 || free[c]=!={}) :=
253 | simpInFunc[a, opt] + simpInFunc[b, opt] Power[Simp[c, "Dummy"->inFuncChoice], Simp[d, "Dummy"->inFuncChoice]];
254 | (* simpInFunc through Series *)
255 | simpInFunc[HoldPattern@SeriesData[x_, n_, coeffList_List, orders__], opt:OptionsPattern[Simp]] := SeriesData[x, n, Simp[#, opt]& /@ coeffList, orders];
256 | simpInFunc[f_, opt:OptionsPattern[]]:= simpRaw[f, opt];
257 |
258 | simpRaw[e_, OptionsPattern[Simp]]:= Module[{mapSum, eList, fr, simpTermFast, aaPdT, fastIds, idStat, frTerm, dum, simpTerm, t0, tM, idSet, dumSet, conTsr, zMat},
259 | mapSum := If[OptionValue@"Parallel"=!=True, Total@Map[#1, #2],
260 | ParallelCombine[Function[lst,Total@Map[#1,lst]], #2, Plus, DistributedContexts -> "MathGR`", Method -> "CoarsestGrained"]]&;
261 | eList = SimpSelect @ expand2list @ (e//.SimpHook);
262 | If[eList==={} || eList==={0}, Return @ 0];
263 | fr = Sort @ free @ eList[[1]];
264 |
265 | (* 1st pass, check tensor and replace dummy, try to cancel some terms *)
266 | fastIds = If[OptionValue@"Dummy"===Automatic, LatinIdx, OptionValue@"Dummy"];
267 | simpTermFast[t_]/; FreeQ[t, IdxPtn]:=t;
268 | simpTermFast[t_]:= ( idStat=Tally@idx@(t/.PdT->aaPdT);
269 | frTerm = Sort@Cases[idStat, {a_,1}:>a];
270 | If[Cases[idStat, {a_,b_}/;b>2]=!={}, Message[Simp::overdummy, Sequence@@(Cases[idStat, {a_,b_}/;b>2][[1]]), t]];
271 | If[frTerm=!=fr, Message[Simp::diffree, t, fr]];
272 | dum = Cases[idStat, {a_,2}:>a];
273 | t /. replaceTo[(a0:IdxHeadPtn) /@ dum, a0 /@ Take[Complement[fastIds, frTerm], Length@dum]] );
274 | eList = plus2list @ mapSum[simpTermFast, eList];
275 | If[OptionValue@"Method"==="Fast", Return @ Total @ eList];
276 |
277 | (* 2nd pass, with M engine *)
278 | conTsr = If[fr==={}, 1, zMat @@ SortBy[Cases[eList[[1]], (i:IdxHeadPtn)[a_]/;MemberQ[fr, a], Infinity], First]];
279 | simpTerm[f_]/; !FreeQ[f, Pm2]:=f; (* unsupported functions for 2nd & 3rd passes *)
280 | simpTerm[f_]/; FreeQ[f, IdxPtn]:=f;
281 | simpTerm[f_ t_] /; FreeQ[f, IdxPtn]:=f * simpTerm[t];
282 | simpTerm[term_]:= (t0 = conTsr~TensorProduct~times2prod[term, TensorProduct];
283 | tM = TensorContract[t0 /. id:IdxPtn:>id[[0]] /. f_[id__]:>MAT[f][id] /; !FreeQ[{id},IdxHeadPtn,1], Map[Flatten@Position[(idx@t0),#]&, Verbatim/@(dummy@t0)]];
284 | tReduce[tM]);
285 | eList = plus2list @ mapSum[simpTerm, pd2pdts @ eList];
286 |
287 | (* 3rd pass, get indices back *)
288 | idSet = If[OptionValue@"Dummy"===Automatic, IdxSet[#], OptionValue@"Dummy"]&;
289 | (dumSet[#] = Complement[idSet[#], fr]) & /@ IdxList;
290 | (SimpSelect @ pdts2pd @ mapSum[assignIdx[#, fr, dumSet, conTsr, zMat]&, eList])//.SimpHook]
291 |
292 | assignIdx[tM_, fr_, dumSet_, conTsr_, zMat_]/; !FreeQ[tM, Pm2]:= tM; (* unsupported functions for 2nd & 3rd passes *)
293 | assignIdx[tM_, fr_, dumSet_, conTsr_, zMat_]/; FreeQ[tM, IdxHeadPtn]:= tM;
294 | assignIdx[f_ tM_, fr_, dumSet_, conTsr_, zMat_]/; FreeQ[f, IdxHeadPtn]:= f assignIdx[tM, fr, dumSet, conTsr, zMat];
295 | assignIdx[tM_, fr_, dumSet_, conTsr_, zMat_]:= Module[{tcGetId, nthCT=0 (* count currently in which TensorContract *) , nthIdx (* count idx number within a TensorContract *),
296 | mark (* mark idx with mark[nthCT, nthIdX] *), nthDummy (* used by assignDummy, count which dummy variable to use from dumSet *), marked, assignFree, assignDummy},
297 | tcGetId[t_, pairs_]:= (nthIdx=1; nthCT++; t /. a:IdxHeadPtn:>a[mark[nthCT, nthIdx++]] /. (mark[nthCT, #[[2]]]->mark[nthCT, #[[1]]] &/@ pairs));
298 | assignFree[x_]:= x /. Flatten@Cases[{x}, MAT[zMat][a__] :> replaceTo[#[[1]]&/@{a}, fr], Infinity]; (* put free indices *)
299 | (nthDummy[#]=1)& /@ IdxList; (* Initialize counter for assignDummy -- each type is initially 1 *)
300 | assignDummy[x_]:= x /. (marked = DeleteDuplicates[#, First[#1] === First[#2] &]& @ Cases[x, _@mark[__], Infinity]; (* find dummy indices, one representive for each pair *)
301 | replaceTo[First/@marked, dumSet[#[[0]]][[(nthDummy[#[[0]]])++;(nthDummy@IdxDual[#[[0]]])++]] & /@ marked]); (* replace those marked indices with standard dummies *)
302 | assignDummy @ assignFree @ (times2prod @ tM/.tContract->tcGetId) /. MAT[f_]:>f /. zMat[i__]:>1 // prod2times[#, prod|TensorProduct]&]
303 |
304 |
305 |
306 | (* ::Section:: *)
307 | (* Check tensor validity at $Pre *)
308 |
309 |
310 | preCheckList = {checkNestIdx}
311 |
312 | $PreRead::nestidx = "Nested indices are not allowed in `1`."
313 | checkNestIdx = Module[{t=Cases[{#}, (a:IdxPtn|_UE|_DE)/;!FreeQ[List@@a,IdxPtn|_UE|_DE], Infinity]},
314 | If[t =!= {}, Message[$PreRead::nestidx, t]]]&
315 |
316 | $PreRead := (Through@preCheckList@MakeExpression[#, StandardForm]; #)&
317 |
318 | End[]
319 | EndPackage[]
320 |
--------------------------------------------------------------------------------
/typeset.m:
--------------------------------------------------------------------------------
1 | (* ::Package:: *)
2 |
3 | (* Yi Wang, 2013, tririverwangyi@gmail.com, GPLv3 *)
4 | BeginPackage["MathGR`typeset`", {"MathGR`tensor`"}]
5 |
6 | ToTeXString::usage="ToTeXString[expr] translates expr into TeXForm and return the result in a string"
7 | ToTeX::usage="ToTeX[expr] prints expr into TeXForm"
8 | ToTeXHook::usage="ToTeXHook is set of transformations before export to TeX"
9 | ToTeXTemplate::usage="ToTeXTemplate = True (default, export header and tail of tex) or False (no header or tail, only the equation)."
10 | DecorateTeXString::usage="DecorateTeXString[s] does post processing for a TeX string."
11 | Begin["`Private`"]
12 | Needs["MathGR`utilPrivate`"]
13 |
14 |
15 | (* ::Section:: *)
16 | (* TraditionalForm and TeX output *)
17 |
18 |
19 | altUp:= Alternatives @@ IdxUpList
20 | altDn:= Alternatives @@ IdxDnList
21 | idxQ[idx__]:= MatchQ[{idx}, {(IdxPtn|_UE|_DE) ..}]
22 | makeBoxesTsrQ = !MatchQ[#, List|Rule|Alternatives|Sequence]&
23 | mkPd[form_][i___] := Sequence @@ (MakeBoxes[\[CapitalSampi]@#, form] & /@ {i})
24 |
25 | (*SetOptions[$Output, PageWidth -> 200]*)
26 | If[!defQ@ToTeXHook, ToTeXHook = {}]
27 |
28 | removeTextAndCurly[s_String]:= s // StringReplace[#, "\\text{"~~f__~~"}"/;StringFreeQ[f,{"{","}"}] :>f ] & // StringReplace[#, "$":>""] &
29 | removeWaste[s_String]:= s // StringReplace[#, "\\text{}" :> "{}"] & // StringReplace[#, "){}^" :> ")^"] & // StringReplace[#, "\\partial {}_" :> "\\partial_"] &
30 | replaceTimeDot[s_String]:= If[!StringFreeQ[s, "\\partial ^{-2}"], s (* dot acting on Pm2 looks wrong *),
31 | StringReplace[s, {"\\partial_0\\partial_0\\partial_0" :> "\\dddot", "\\partial_0\\partial_0" :> "\\ddot", "\\partial_0" :> "\\dot"}]]
32 | breakLine[s_String]:= s // StringReplace[#, {"+":>"\n + ", f_~~"-" /; f=!="\n"&&f=!="{" :> f<>"\n - ", "=":>"\n= ", "\\to":>"\n \\to "}] &
33 | addHeaderTail[s_String]:= If[!ToTeXTemplate, s, Print["Hint: set ToTeXTemplate = False to output equation only."]; "%Generated by MathGR/typeset.m, "<>DateString[]<>
34 | ".\n\\documentclass{revtex4}\n\\usepackage{breqn}\n\\begin{document}\n\\begin{dmath}\n"<>s<>"\n\\end{dmath}\n\\end{document}\n"]
35 | finalCleanUp[s_String]:= s // StringReplace[#, {"\n\n"->"\n"}] & (* Shouldn't be necessary. Just in case. *)
36 |
37 | If[!defQ@DecorateTeXString, DecorateTeXString = (# // removeWaste // replaceTimeDot // removeTextAndCurly // breakLine // addHeaderTail // finalCleanUp) & ]
38 |
39 | If[!defQ[ToTeXTemplate], ToTeXTemplate = True]
40 | ToTeXString[e_]:= e//.ToTeXHook // PolynomialForm[#, TraditionalOrder -> False]& // ToString[#, TeXForm] & // DecorateTeXString
41 | ToTeX[e_] := ToTeXString[e] // Print
42 |
43 | MakeBoxes[\[CapitalSampi], TraditionalForm]:="\[PartialD]"
44 | MakeBoxes[Dta, TraditionalForm]:="\[Delta]"
45 | MakeBoxes[tsr_[idx__], TraditionalForm]/;(idxQ[idx]&&makeBoxesTsrQ[tsr]):= With[
46 | {idList={idx}/.{altUp[i_]:>SuperscriptBox["", i], UE[i_]:>SuperscriptBox["", ToString@i], altDn[i_]:>SubscriptBox["", i], DE[i_]:>SubscriptBox["", ToString@i]}},
47 | TagBox[RowBox[{MakeBoxes[tsr, TraditionalForm]}~Join~idList], "mgrTsr", SyntaxForm->"symbol"]]
48 | MakeBoxes[PdT[f_, PdVars[i0:DE@0..., i__]], TraditionalForm] /; FreeQ[{i}, DE@0] := With[{id0 = mkPd[TraditionalForm]@i0, id = mkPd[TraditionalForm]@i},
49 | TagBox[RowBox[{id, id0, MakeBoxes[f, TraditionalForm]}], "mgrPdT", SyntaxForm -> "^"]]
50 | MakeBoxes[PdT[f_, PdVars[i0:DE@0..]], TraditionalForm] := With[{id0 = mkPd[TraditionalForm]@i0},
51 | TagBox[RowBox[{id0, MakeBoxes[f, TraditionalForm]}], "mgrPdT", SyntaxForm -> "symbol"]]
52 |
53 |
54 | (* ::Section:: *)
55 | (* All the below only run with a frontend *)
56 |
57 |
58 | If[$FrontEnd===Null, Print["(typeset.m): No FrontEnd detected. StandardForm and input aliases definitions skipped."],
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 | (* ::Section:: *)
72 | (* Tensor *)
73 |
74 |
75 | (*
76 | MakeBoxes[tsr_[idx__], StandardForm]/;(idxQ[idx]&&makeBoxesTsrQ[tsr]):= TagBox[RowBox[{AdjustmentBox[MakeBoxes[tsr, StandardForm], BoxMargins -> {{0, -0.2}, {0, 0}}],
77 | StyleBox[ GridBox[{idx} /. {
78 | {(a:altUp)[i_]:>TagBox[StyleBox[MakeBoxes[i, StandardForm], FontColor->IdxColor@a], a],
79 | IdxDnPtn:>"", UE@n_:>TagBox[StyleBox[MakeBoxes[n, StandardForm], FontColor->IdxColor@UE],UE], DE@n_:>""},
80 | {IdxUpPtn:>"", (a:altDn)[i_]:>TagBox[StyleBox[MakeBoxes[i, StandardForm], FontColor->IdxColor@a], a],
81 | DE@n_:>TagBox[StyleBox[MakeBoxes[n, StandardForm], FontColor->IdxColor@DE],DE], UE@n_:>""}
82 | }, ColumnSpacings->0, RowSpacings->0], FontSize->10]}], "mgrTsr"(*, SyntaxForm->"symbol"*)];
83 | parseUD[lst_, StandardForm]:= Sequence @@ (Map[If[#[[1]] === "", #[[2]], #[[1]]] &, Transpose[lst]] /. {TagBox[i_ | StyleBox[i_, __], tag_] :> tag@ToExpression[i, StandardForm]});
84 | MakeExpression[TagBox[RowBox[{AdjustmentBox[t_, ___], StyleBox[GridBox[idx__, ___], ___]}], "mgrTsr", OptionsPattern[]], StandardForm] :=
85 | With[{h = ToExpression[t, StandardForm], i = parseUD[idx, StandardForm]}, HoldComplete@h@i];
86 | *)
87 |
88 | (* The new box form has advantages: (1) Uniform look in input/output/code blocks/pdf. (2) Robust against edit/copy-paste. Not possible to leave imcomplete boxes. (3) No longer additional brackets. *)
89 | MakeBoxes[tsr_[idx__], StandardForm]/;(idxQ[idx]&&makeBoxesTsrQ[tsr]):= TagBox[GridBox[{{GridBox[{{MakeBoxes[tsr, StandardForm]}}, Selectable->True],
90 | GridBox[{idx} /. {
91 | {(a:altUp)[i_]:>StyleBox[TagBox[GridBox[{{MakeBoxes[i, StandardForm]}}, Selectable->True], a], FontColor->IdxColor@a, FontSize->10],
92 | IdxDnPtn:>"", UE@n_:>StyleBox[TagBox[GridBox[{{MakeBoxes[n, StandardForm]}}, Selectable->True],UE], FontColor->IdxColor@UE, FontSize->10], DE@n_:>""},
93 | {IdxUpPtn:>"", (a:altDn)[i_]:>StyleBox[TagBox[GridBox[{{MakeBoxes[i, StandardForm]}}, Selectable->True], a], FontColor->IdxColor@a, FontSize->10],
94 | DE@n_:>StyleBox[TagBox[GridBox[{{MakeBoxes[n, StandardForm]}}, Selectable->True],DE], FontColor->IdxColor@DE, FontSize->10], UE@n_:>""}
95 | }, ColumnSpacings->0, RowSpacings->-0.5]}}, ColumnSpacings->0, RowSpacings->0, Selectable->False], "mgrTensor", SyntaxForm->"symbol", Selectable->False];
96 |
97 | parseId[lst_, StandardForm]:= Sequence @@ (Map[If[#[[1]] === "", #[[2]], #[[1]]] &, Transpose[lst]]
98 | /. {StyleBox[TagBox[GridBox[{{i_}},___] , tag_,___], ___] | TagBox[GridBox[{{i_}},___] , tag_,___] :> tag@ToExpression[i, StandardForm]});
99 | MakeExpression[TagBox[GridBox[{{GridBox[{{t_}}, ___], GridBox[idx__, ___]}},___], "mgrTensor", ___], StandardForm] :=
100 | With[{h = ToExpression[t, StandardForm], i = parseId[idx, StandardForm]}, HoldComplete@h@i];
101 |
102 |
103 | (* ::Section:: *)
104 | (* Derivative *)
105 |
106 |
107 | (*
108 | MakeBoxes[PdT[f_, PdVars[i__]], StandardForm] /; FreeQ[{i}, DE@0] || !FreeQ[{f}, Pm2] :=
109 | With[{id = mkPd[StandardForm]@i}, TagBox[GridBox[{{id, GridBox[{{MakeBoxes[f, StandardForm]}},Selectable\[Rule]True]}}, ColumnSpacings->0, RowSpacings->0], "mgrPd", SyntaxForm -> "^", Selectable\[Rule]False]];
110 | MakeBoxes[PdT[a_, PdVars[dt : DE@0 .., i__]], StandardForm] /; FreeQ[{i}, DE@0]:= With[{id = mkPd[StandardForm]@i, bu = StringJoin@ConstantArray["\[Bullet]", Length@{dt}]},
111 | TagBox[GridBox[{{id, GridBox[{{OverscriptBox[MakeBoxes[a, StandardForm], bu]}},Selectable\[Rule]True]}}, ColumnSpacings->0, RowSpacings->0], "mgrPd", SyntaxForm -> "^", Selectable\[Rule]False]];
112 | MakeBoxes[PdT[a_, PdVars[dt : DE@0 ..]], StandardForm] /; FreeQ[{a}, Pm2] := With[{bu = StringJoin@ConstantArray["\[Bullet]", Length@{dt}]}, OverscriptBox[MakeBoxes[a, StandardForm], bu]];
113 |
114 | MakeExpression[TagBox[GridBox[{{d__,GridBox[{{f_}},___]}},___], "mgrPd", ___], StandardForm]:=
115 | With[{idExpr=PdVars@@Cases[ToExpression[{d}, StandardForm], \[CapitalSampi][a_]:>a], fExpr=ToExpression[f, StandardForm]}, HoldComplete@PdT[fExpr, idExpr]];
116 |
117 | MakeExpression[TagBox[GridBox[{{d__,GridBox[{{f_}},___]}},___], "mgrPd", ___], StandardForm]:=
118 | With[{idExpr=ToExpression/@{d}, fExpr=ToExpression[f, StandardForm]}, HoldComplete@PdT[fExpr, idExpr]];
119 |
120 | MakeExpression[OverscriptBox[a_, str_String], StandardForm] := With[{pds = Nest[Pd[#, DE@0] &, ToExpression[a, StandardForm],
121 | StringLength[str]]}, HoldComplete[pds]] /; StringMatchQ[str, "\[Bullet]" ..];
122 |
123 | MakeBoxes[Pm2[a_, type_], form_] := TagBox[RowBox[{TagBox[StyleBox[SuperscriptBox[MakeBoxes[\[CapitalSampi], form], "-2"], FontColor->IdxColor[type]], type],
124 | "(", MakeBoxes[a, form], ")" }], "mgrPm2"];
125 | MakeExpression[TagBox[RowBox[{TagBox[_, type_], "(", a_, ")"}], "mgrPm2"], StandardForm]:= With[{expr=Pm2[ToExpression[a, StandardForm], type]}, HoldComplete[expr]];
126 | *)
127 |
128 |
129 | (*
130 | MakeBoxes[PdT[f_, PdVars[i__]], StandardForm] /; FreeQ[{i}, DE@0] || !FreeQ[{f}, Pm2] :=
131 | With[{id = mkPd[StandardForm]@i}, TagBox[RowBox[{id, MakeBoxes[f, StandardForm]}], "mgrPd", Selectable->False]];
132 | MakeBoxes[PdT[a_, PdVars[dt : DE@0 .., i__]], StandardForm] /; FreeQ[{i}, DE@0]:= With[{id = mkPd[StandardForm]@i, bu = StringJoin@ConstantArray["\[Bullet]", Length@{dt}]},
133 | TagBox[RowBox[{id, OverscriptBox[MakeBoxes[a, StandardForm], bu]}], "mgrPd", Selectable->False]];
134 | MakeBoxes[PdT[a_, PdVars[dt : DE@0 ..]], StandardForm] /; FreeQ[{a}, Pm2] := With[{bu = StringJoin@ConstantArray["\[Bullet]", Length@{dt}]}, OverscriptBox[MakeBoxes[a, StandardForm], bu]];
135 |
136 | MakeExpression[TagBox[RowBox[{d__,f_}], "mgrPd", ___], StandardForm]:=
137 | With[{idExpr=PdVars@@Cases[ToExpression[{d}, StandardForm], \[CapitalSampi][a_]:>a], fExpr=ToExpression[f, StandardForm]}, HoldComplete@PdT[fExpr, idExpr]];
138 |
139 | MakeExpression[OverscriptBox[a_, str_String], StandardForm] := With[{pds = Nest[Pd[#, DE@0] &, ToExpression[a, StandardForm],
140 | StringLength[str]]}, HoldComplete[pds]] /; StringMatchQ[str, "\[Bullet]" ..];
141 |
142 | MakeBoxes[Pm2[a_, type_], form_] := TagBox[RowBox[{TagBox[StyleBox[SuperscriptBox[MakeBoxes[\[CapitalSampi], form], "-2"], FontColor->IdxColor[type]], type],
143 | "(", MakeBoxes[a, form], ")" }], "mgrPm2", Selectable->False];
144 | MakeExpression[TagBox[RowBox[{TagBox[_, type_], "(", a_, ")"}], "mgrPm2",___], StandardForm]:= With[{expr=Pm2[ToExpression[a, StandardForm], type]}, HoldComplete[expr]];
145 | *)
146 |
147 |
148 | MakeBoxes[\[CapitalSampi], StandardForm]:= TagBox["\[PartialD]", "mgrSa", Selectable->False];
149 | MakeExpression[TagBox["\[PartialD]","mgrSa",___], StandardForm]:= HoldComplete@\[CapitalSampi];
150 |
151 | MakeBoxes[PdT[f_, PdVars[i__]], StandardForm] /; FreeQ[{i}, DE@0] || !FreeQ[{f}, Pm2] :=
152 | With[{id = mkPd[StandardForm]@i}, TagBox[RowBox[{GridBox[{{id, GridBox[{{MakeBoxes[f, StandardForm]}},Selectable->True]}}, ColumnSpacings->0, RowSpacings->0],""}], "mgrPd", Selectable->False]];
153 | MakeBoxes[PdT[a_, PdVars[dt : DE@0 .., i__]], StandardForm] /; FreeQ[{i}, DE@0]:= With[{id = mkPd[StandardForm]@i, bu = StringJoin@ConstantArray["\[Bullet]", Length@{dt}]},
154 | TagBox[RowBox[{GridBox[{{id, GridBox[{{OverscriptBox[MakeBoxes[a, StandardForm], bu]}},Selectable->True]}}, ColumnSpacings->0, RowSpacings->0],""}], "mgrPd", Selectable->False]];
155 | MakeBoxes[PdT[a_, PdVars[dt : DE@0 ..]], StandardForm] /; FreeQ[{a}, Pm2] := With[{bu = StringJoin@ConstantArray["\[Bullet]", Length@{dt}]}, OverscriptBox[MakeBoxes[a, StandardForm], bu]];
156 |
157 | MakeExpression[TagBox[GridBox[{{d__,GridBox[{{f_}},___]}},___], "mgrPd", ___], StandardForm]:=
158 | With[{idExpr=PdVars@@Cases[ToExpression[{d}, StandardForm], \[CapitalSampi][a_]:>a], fExpr=ToExpression[f, StandardForm]}, HoldComplete@PdT[fExpr, idExpr]];
159 |
160 | MakeExpression[OverscriptBox[a_, str_String], StandardForm] := With[{pds = Nest[Pd[#, DE@0] &, ToExpression[a, StandardForm],
161 | StringLength[str]]}, HoldComplete[pds]] /; StringMatchQ[str, "\[Bullet]" ..];
162 |
163 | MakeBoxes[Pm2[a_, type_], form_] := TagBox[RowBox[{TagBox[StyleBox[SuperscriptBox[MakeBoxes[\[CapitalSampi], form], "-2"], FontColor->IdxColor[type]], type],
164 | "(", MakeBoxes[a, form], ")" }], "mgrPm2", Selectable->False];
165 | MakeExpression[TagBox[RowBox[{TagBox[_, type_], "(", a_, ")"}], "mgrPm2",___], StandardForm]:= With[{expr=Pm2[ToExpression[a, StandardForm], type]}, HoldComplete[expr]];
166 |
167 |
168 | (* ::Section:: *)
169 | (* Paste the blob calculated in InputAliases.nb *)
170 |
171 |
172 | aliasesList = {"tp0"->OverscriptBox["\[SelectionPlaceholder]","\[Bullet]"],
173 | "tu"->\!\(\*
174 | TagBox[GridBox[{
175 | {GridBox[{
176 | {"\"\<\[SelectionPlaceholder]\>\""}
177 | },
178 | Selectable->True], GridBox[{
179 | {
180 | StyleBox[
181 | TagBox[GridBox[{
182 | {"\"\<\[Placeholder]\>\""}
183 | },
184 | Selectable->True],
185 | MathGR`tensor`UP],
186 | FontSize->10,
187 | FontColor->GrayLevel[0]]},
188 | {""}
189 | },
190 | GridBoxSpacings->{"Columns" -> {Offset[0.27999999999999997`], {Offset[0.]}, Offset[0.27999999999999997`]}, "Rows" -> {Offset[0.2], {Offset[-0.2]}, Offset[0.2]}}]}
191 | },
192 | GridBoxSpacings->{"Columns" -> {Offset[0.27999999999999997`], {Offset[0.]}, Offset[0.27999999999999997`]}, "Rows" -> {Offset[0.2], {Offset[0.]}, Offset[0.2]}},
193 | Selectable->False],
194 | "mgrTensor",
195 | Selectable->False,
196 | SyntaxForm->"symbol"]\),"td"->\!\(\*
197 | TagBox[GridBox[{
198 | {GridBox[{
199 | {"\"\<\[SelectionPlaceholder]\>\""}
200 | },
201 | Selectable->True], GridBox[{
202 | {""},
203 | {
204 | StyleBox[
205 | TagBox[GridBox[{
206 | {"\"\<\[Placeholder]\>\""}
207 | },
208 | Selectable->True],
209 | MathGR`tensor`DN],
210 | FontSize->10,
211 | FontColor->GrayLevel[0]]}
212 | },
213 | GridBoxSpacings->{"Columns" -> {Offset[0.27999999999999997`], {Offset[0.]}, Offset[0.27999999999999997`]}, "Rows" -> {Offset[0.2], {Offset[-0.2]}, Offset[0.2]}}]}
214 | },
215 | GridBoxSpacings->{"Columns" -> {Offset[0.27999999999999997`], {Offset[0.]}, Offset[0.27999999999999997`]}, "Rows" -> {Offset[0.2], {Offset[0.]}, Offset[0.2]}},
216 | Selectable->False],
217 | "mgrTensor",
218 | Selectable->False,
219 | SyntaxForm->"symbol"]\),"tuu"->\!\(\*
220 | TagBox[GridBox[{
221 | {GridBox[{
222 | {"\"\<\[SelectionPlaceholder]\>\""}
223 | },
224 | Selectable->True], GridBox[{
225 | {
226 | StyleBox[
227 | TagBox[GridBox[{
228 | {"\"\<\[Placeholder]\>\""}
229 | },
230 | Selectable->True],
231 | MathGR`tensor`UP],
232 | FontSize->10,
233 | FontColor->GrayLevel[0]],
234 | StyleBox[
235 | TagBox[GridBox[{
236 | {"\"\<\[Placeholder]\>\""}
237 | },
238 | Selectable->True],
239 | MathGR`tensor`UP],
240 | FontSize->10,
241 | FontColor->GrayLevel[0]]},
242 | {"", ""}
243 | },
244 | GridBoxSpacings->{"Columns" -> {Offset[0.27999999999999997`], {Offset[0.]}, Offset[0.27999999999999997`]}, "Rows" -> {Offset[0.2], {Offset[-0.2]}, Offset[0.2]}}]}
245 | },
246 | GridBoxSpacings->{"Columns" -> {Offset[0.27999999999999997`], {Offset[0.]}, Offset[0.27999999999999997`]}, "Rows" -> {Offset[0.2], {Offset[0.]}, Offset[0.2]}},
247 | Selectable->False],
248 | "mgrTensor",
249 | Selectable->False,
250 | SyntaxForm->"symbol"]\),"tud"->\!\(\*
251 | TagBox[GridBox[{
252 | {GridBox[{
253 | {"\"\<\[SelectionPlaceholder]\>\""}
254 | },
255 | Selectable->True], GridBox[{
256 | {
257 | StyleBox[
258 | TagBox[GridBox[{
259 | {"\"\<\[Placeholder]\>\""}
260 | },
261 | Selectable->True],
262 | MathGR`tensor`UP],
263 | FontSize->10,
264 | FontColor->GrayLevel[0]], ""},
265 | {"",
266 | StyleBox[
267 | TagBox[GridBox[{
268 | {"\"\<\[Placeholder]\>\""}
269 | },
270 | Selectable->True],
271 | MathGR`tensor`DN],
272 | FontSize->10,
273 | FontColor->GrayLevel[0]]}
274 | },
275 | GridBoxSpacings->{"Columns" -> {Offset[0.27999999999999997`], {Offset[0.]}, Offset[0.27999999999999997`]}, "Rows" -> {Offset[0.2], {Offset[-0.2]}, Offset[0.2]}}]}
276 | },
277 | GridBoxSpacings->{"Columns" -> {Offset[0.27999999999999997`], {Offset[0.]}, Offset[0.27999999999999997`]}, "Rows" -> {Offset[0.2], {Offset[0.]}, Offset[0.2]}},
278 | Selectable->False],
279 | "mgrTensor",
280 | Selectable->False,
281 | SyntaxForm->"symbol"]\),"tdu"->\!\(\*
282 | TagBox[GridBox[{
283 | {GridBox[{
284 | {"\"\<\[SelectionPlaceholder]\>\""}
285 | },
286 | Selectable->True], GridBox[{
287 | {"",
288 | StyleBox[
289 | TagBox[GridBox[{
290 | {"\"\<\[Placeholder]\>\""}
291 | },
292 | Selectable->True],
293 | MathGR`tensor`UP],
294 | FontSize->10,
295 | FontColor->GrayLevel[0]]},
296 | {
297 | StyleBox[
298 | TagBox[GridBox[{
299 | {"\"\<\[Placeholder]\>\""}
300 | },
301 | Selectable->True],
302 | MathGR`tensor`DN],
303 | FontSize->10,
304 | FontColor->GrayLevel[0]], ""}
305 | },
306 | GridBoxSpacings->{"Columns" -> {Offset[0.27999999999999997`], {Offset[0.]}, Offset[0.27999999999999997`]}, "Rows" -> {Offset[0.2], {Offset[-0.2]}, Offset[0.2]}}]}
307 | },
308 | GridBoxSpacings->{"Columns" -> {Offset[0.27999999999999997`], {Offset[0.]}, Offset[0.27999999999999997`]}, "Rows" -> {Offset[0.2], {Offset[0.]}, Offset[0.2]}},
309 | Selectable->False],
310 | "mgrTensor",
311 | Selectable->False,
312 | SyntaxForm->"symbol"]\),"tdd"->\!\(\*
313 | TagBox[GridBox[{
314 | {GridBox[{
315 | {"\"\<\[SelectionPlaceholder]\>\""}
316 | },
317 | Selectable->True], GridBox[{
318 | {"", ""},
319 | {
320 | StyleBox[
321 | TagBox[GridBox[{
322 | {"\"\<\[Placeholder]\>\""}
323 | },
324 | Selectable->True],
325 | MathGR`tensor`DN],
326 | FontSize->10,
327 | FontColor->GrayLevel[0]],
328 | StyleBox[
329 | TagBox[GridBox[{
330 | {"\"\<\[Placeholder]\>\""}
331 | },
332 | Selectable->True],
333 | MathGR`tensor`DN],
334 | FontSize->10,
335 | FontColor->GrayLevel[0]]}
336 | },
337 | GridBoxSpacings->{"Columns" -> {Offset[0.27999999999999997`], {Offset[0.]}, Offset[0.27999999999999997`]}, "Rows" -> {Offset[0.2], {Offset[-0.2]}, Offset[0.2]}}]}
338 | },
339 | GridBoxSpacings->{"Columns" -> {Offset[0.27999999999999997`], {Offset[0.]}, Offset[0.27999999999999997`]}, "Rows" -> {Offset[0.2], {Offset[0.]}, Offset[0.2]}},
340 | Selectable->False],
341 | "mgrTensor",
342 | Selectable->False,
343 | SyntaxForm->"symbol"]\),
344 | "tudd"->\!\(\*
345 | TagBox[GridBox[{
346 | {GridBox[{
347 | {"\"\<\[SelectionPlaceholder]\>\""}
348 | },
349 | Selectable->True], GridBox[{
350 | {
351 | StyleBox[
352 | TagBox[GridBox[{
353 | {"\"\<\[Placeholder]\>\""}
354 | },
355 | Selectable->True],
356 | MathGR`tensor`UP],
357 | FontSize->10,
358 | FontColor->GrayLevel[0]], "", ""},
359 | {"",
360 | StyleBox[
361 | TagBox[GridBox[{
362 | {"\"\<\[Placeholder]\>\""}
363 | },
364 | Selectable->True],
365 | MathGR`tensor`DN],
366 | FontSize->10,
367 | FontColor->GrayLevel[0]],
368 | StyleBox[
369 | TagBox[GridBox[{
370 | {"\"\<\[Placeholder]\>\""}
371 | },
372 | Selectable->True],
373 | MathGR`tensor`DN],
374 | FontSize->10,
375 | FontColor->GrayLevel[0]]}
376 | },
377 | GridBoxSpacings->{"Columns" -> {Offset[0.27999999999999997`], {Offset[0.]}, Offset[0.27999999999999997`]}, "Rows" -> {Offset[0.2], {Offset[-0.2]}, Offset[0.2]}}]}
378 | },
379 | GridBoxSpacings->{"Columns" -> {Offset[0.27999999999999997`], {Offset[0.]}, Offset[0.27999999999999997`]}, "Rows" -> {Offset[0.2], {Offset[0.]}, Offset[0.2]}},
380 | Selectable->False],
381 | "mgrTensor",
382 | Selectable->False,
383 | SyntaxForm->"symbol"]\),"tuddd"->\!\(\*
384 | TagBox[GridBox[{
385 | {GridBox[{
386 | {"\"\<\[SelectionPlaceholder]\>\""}
387 | },
388 | Selectable->True], GridBox[{
389 | {
390 | StyleBox[
391 | TagBox[GridBox[{
392 | {"\"\<\[Placeholder]\>\""}
393 | },
394 | Selectable->True],
395 | MathGR`tensor`UP],
396 | FontSize->10,
397 | FontColor->GrayLevel[0]], "", "", ""},
398 | {"",
399 | StyleBox[
400 | TagBox[GridBox[{
401 | {"\"\<\[Placeholder]\>\""}
402 | },
403 | Selectable->True],
404 | MathGR`tensor`DN],
405 | FontSize->10,
406 | FontColor->GrayLevel[0]],
407 | StyleBox[
408 | TagBox[GridBox[{
409 | {"\"\<\[Placeholder]\>\""}
410 | },
411 | Selectable->True],
412 | MathGR`tensor`DN],
413 | FontSize->10,
414 | FontColor->GrayLevel[0]],
415 | StyleBox[
416 | TagBox[GridBox[{
417 | {"\"\<\[Placeholder]\>\""}
418 | },
419 | Selectable->True],
420 | MathGR`tensor`DN],
421 | FontSize->10,
422 | FontColor->GrayLevel[0]]}
423 | },
424 | GridBoxSpacings->{"Columns" -> {Offset[0.27999999999999997`], {Offset[0.]}, Offset[0.27999999999999997`]}, "Rows" -> {Offset[0.2], {Offset[-0.2]}, Offset[0.2]}}]}
425 | },
426 | GridBoxSpacings->{"Columns" -> {Offset[0.27999999999999997`], {Offset[0.]}, Offset[0.27999999999999997`]}, "Rows" -> {Offset[0.2], {Offset[0.]}, Offset[0.2]}},
427 | Selectable->False],
428 | "mgrTensor",
429 | Selectable->False,
430 | SyntaxForm->"symbol"]\)};
431 |
432 |
433 | addAlias[alias_]:=CurrentValue[$FrontEndSession,{InputAliases,alias[[1]]}]=alias[[2]];
434 | addAlias/@(aliasList);
435 |
436 |
437 |
438 | ] (* end of the big if (or tell me how to stop in the middle of a package gracefully?) *)
439 |
440 | End[]
441 | EndPackage[]
442 |
--------------------------------------------------------------------------------
/resources/examples/2nd_order_GW_pert.nb:
--------------------------------------------------------------------------------
1 | (* Content-type: application/vnd.wolfram.mathematica *)
2 |
3 | (*** Wolfram Notebook File ***)
4 | (* http://www.wolfram.com/nb *)
5 |
6 | (* CreatedBy='Mathematica 12.0' *)
7 |
8 | (*CacheID: 234*)
9 | (* Internal cache information:
10 | NotebookFileLineBreakTest
11 | NotebookFileLineBreakTest
12 | NotebookDataPosition[ 158, 7]
13 | NotebookDataLength[ 19541, 567]
14 | NotebookOptionsPosition[ 18768, 545]
15 | NotebookOutlinePosition[ 19141, 561]
16 | CellTagsIndexPosition[ 19098, 558]
17 | WindowFrame->Normal*)
18 |
19 | (* Beginning of Notebook Content *)
20 | Notebook[{
21 |
22 | Cell[CellGroupData[{
23 | Cell[BoxData[
24 | RowBox[{"<<", "MathGR`"}]], "Input",
25 | CellChangeTimes->{{3.77685100791722*^9, 3.776851009552264*^9}},
26 | CellLabel->"In[1]:=",ExpressionUUID->"a79a70c0-85a4-4312-9f94-a6a5d184ed3f"],
27 |
28 | Cell[BoxData["\<\"MathGR, by Yi Wang (2013, 2014), \
29 | https://github.com/tririver/MathGR. \\nBugs can be reported to \
30 | https://github.com/tririver/MathGR/issues\\nLoaded components tensor, decomp, \
31 | gr, ibp, typeset, util.\"\>"], "Output",
32 | CellChangeTimes->{3.776851010267892*^9, 3.7768521655069366`*^9,
33 | 3.7768522991325912`*^9, 3.7768523718777504`*^9, 3.7768527255134296`*^9,
34 | 3.7768527844269047`*^9, 3.776854477229577*^9},
35 | CellLabel->"Out[1]=",ExpressionUUID->"37b425f6-0e15-4f83-8239-9619aed9192c"]
36 | }, Open ]],
37 |
38 | Cell[BoxData[{
39 | RowBox[{
40 | RowBox[{"DeclareIdx", "[",
41 | RowBox[{
42 | RowBox[{"{",
43 | RowBox[{"UP", ",", " ", "DN"}], "}"}], ",", " ", "3", ",", " ",
44 | "LatinIdx"}], "]"}], ";"}], "\[IndentingNewLine]",
45 | RowBox[{
46 | RowBox[{
47 | RowBox[{"PdT", "[",
48 | RowBox[{"Mp", ",", "_"}], "]"}], ":=", "0"}], ";"}], "\n",
49 | RowBox[{
50 | RowBox[{
51 | RowBox[{"PdT", "[",
52 | RowBox[{
53 | RowBox[{"a", "|", "H", "|", "\[Epsilon]", "|", "\[Eta]"}], ",", " ",
54 | RowBox[{"PdVars", "[",
55 | RowBox[{"_DN", ",", " ", "___"}], "]"}]}], "]"}], ":=", "0"}],
56 | ";"}], "\[IndentingNewLine]",
57 | RowBox[{
58 | RowBox[{
59 | RowBox[{"SimpHook", " ", "=", " ",
60 | RowBox[{"{",
61 | RowBox[{
62 | RowBox[{"DefaultDim", "->", "3"}], ",", " ",
63 | RowBox[{
64 | RowBox[{"Pd", "[",
65 | RowBox[{"a", ",", " ",
66 | RowBox[{"DE", "@", "0"}]}], "]"}], "->",
67 | RowBox[{"a", "*", "H"}]}], ",", " ",
68 | RowBox[{
69 | RowBox[{"PdT", "[",
70 | RowBox[{"a", ",", " ",
71 | RowBox[{"PdVars", "[",
72 | RowBox[{
73 | RowBox[{"DE", "@", "0"}], ",",
74 | RowBox[{"DE", "@", "0"}]}], "]"}]}], "]"}], " ", "->", " ",
75 | RowBox[{
76 | RowBox[{"a", " ",
77 | RowBox[{"H", "^", "2"}]}], " ", "-", " ",
78 | RowBox[{"a", " ",
79 | RowBox[{"H", "^", "2"}], " ", "\[Epsilon]"}]}]}], ",", "\n", "\t",
80 | RowBox[{
81 | RowBox[{"Pd", "[",
82 | RowBox[{"H", ",", " ",
83 | RowBox[{"DE", "@", "0"}]}], "]"}], "->",
84 | RowBox[{
85 | RowBox[{"-", "\[Epsilon]"}], "*", "H", "*", "H"}]}], ",", " ",
86 | RowBox[{
87 | RowBox[{"PdT", "[",
88 | RowBox[{"H", ",", " ",
89 | RowBox[{"PdVars", "[",
90 | RowBox[{
91 | RowBox[{"DE", "@", "0"}], ",",
92 | RowBox[{"DE", "@", "0"}]}], "]"}]}], "]"}], " ", "->", " ",
93 | RowBox[{
94 | RowBox[{"2", " ",
95 | RowBox[{"H", "^", "3"}], " ",
96 | RowBox[{"\[Epsilon]", "^", "2"}]}], " ", "-", " ",
97 | RowBox[{
98 | RowBox[{"H", "^", "3"}], " ", "\[Epsilon]", " ", "\[Eta]"}]}]}], ",",
99 | "\n", "\t",
100 | RowBox[{
101 | RowBox[{"PdT", "[",
102 | RowBox[{"H", ",", " ",
103 | RowBox[{"PdVars", "[",
104 | RowBox[{
105 | RowBox[{"DE", "@", "0"}], ",",
106 | RowBox[{"DE", "@", "0"}], ",",
107 | RowBox[{"DE", "@", "0"}]}], "]"}]}], "]"}], " ", "->", " ",
108 | RowBox[{
109 | RowBox[{
110 | RowBox[{"-", "6"}], " ",
111 | RowBox[{"H", "^", "4"}], " ",
112 | RowBox[{"\[Epsilon]", "^", "3"}]}], " ", "+", " ",
113 | RowBox[{"7", " ",
114 | RowBox[{"H", "^", "4"}], " ",
115 | RowBox[{"\[Epsilon]", "^", "2"}], " ", "\[Eta]"}], " ", "-", " ",
116 | RowBox[{
117 | RowBox[{"H", "^", "4"}], " ", "\[Epsilon]", " ",
118 | RowBox[{"\[Eta]", "^", "2"}]}], " ", "-", " ",
119 | RowBox[{
120 | RowBox[{"H", "^", "4"}], " ", "\[Epsilon]", " ", "\[Eta]", " ",
121 | "\[Eta]2"}]}]}], ",", "\n", "\t",
122 | RowBox[{
123 | RowBox[{"Pd", "[",
124 | RowBox[{"\[Epsilon]", ",", " ",
125 | RowBox[{"DE", "@", "0"}]}], "]"}], "->",
126 | RowBox[{"H", "*", "\[Epsilon]", "*", "\[Eta]"}]}], ",", " ",
127 | RowBox[{
128 | RowBox[{"Pd", "[",
129 | RowBox[{"\[Eta]", ",", " ",
130 | RowBox[{"DE", "@", "0"}]}], "]"}], " ", "->", " ",
131 | RowBox[{"H", "*", "\[Eta]2", "*", "\[Eta]"}]}], ",", " ",
132 | RowBox[{
133 | RowBox[{"Pd", "[",
134 | RowBox[{"\[Eta]2", ",", " ",
135 | RowBox[{"DE", "@", "0"}]}], "]"}], " ", "->", " ",
136 | RowBox[{"H", "*", "\[Eta]3", "*", "\[Eta]2"}]}]}], "\t", "}"}]}],
137 | ";"}], "\[IndentingNewLine]"}], "\[IndentingNewLine]",
138 | RowBox[{
139 | RowBox[{"LapseN", " ", "=", " ", "1"}], ";"}], "\[IndentingNewLine]",
140 | RowBox[{
141 | RowBox[{
142 | RowBox[{"ShiftN", "[",
143 | RowBox[{"DN", "@", "i_"}], "]"}], " ", ":=", " ", "0"}],
144 | ";"}], "\[IndentingNewLine]",
145 | RowBox[{
146 | RowBox[{
147 | RowBox[{"Sqrtg", ":=", " ",
148 | RowBox[{"a", "^", "3"}]}], ";"}],
149 | "\[IndentingNewLine]"}], "\[IndentingNewLine]",
150 | RowBox[{"UseMetric", "[", "h", "]"}], "\[IndentingNewLine]",
151 | RowBox[{
152 | RowBox[{"SetAttributes", "[",
153 | RowBox[{"\[Gamma]", ",", " ", "Orderless"}], "]"}], ";"}], "\n",
154 | RowBox[{
155 | RowBox[{
156 | RowBox[{"PdT", "[",
157 | RowBox[{
158 | RowBox[{"\[Gamma]", "[",
159 | RowBox[{
160 | RowBox[{"DN", "@", "i_"}], ",", " ",
161 | RowBox[{"DN", "@", "j_"}]}], "]"}], ",", " ",
162 | RowBox[{"PdVars", "[",
163 | RowBox[{
164 | RowBox[{"DN", "@", "i_"}], ",", " ", "___"}], "]"}]}], "]"}], ":=",
165 | "0"}], ";"}], "\[IndentingNewLine]",
166 | RowBox[{
167 | RowBox[{
168 | RowBox[{"\[Gamma]", "[",
169 | RowBox[{
170 | RowBox[{"DN", "@", "i_"}], ",",
171 | RowBox[{"DN", "@", "i_"}]}], "]"}], ":=", "0"}],
172 | ";"}], "\[IndentingNewLine]",
173 | RowBox[{
174 | RowBox[{
175 | RowBox[{"h", "[",
176 | RowBox[{
177 | RowBox[{"DN", "@", "i_"}], ",", " ",
178 | RowBox[{"DN", "@", "j_"}]}], "]"}], ":=", " ",
179 | RowBox[{"With", "[",
180 | RowBox[{
181 | RowBox[{"{",
182 | RowBox[{"m", "=",
183 | RowBox[{"Unique", "[", "]"}]}], "}"}], ",",
184 | RowBox[{"a", " ", "*", " ", "a", " ", "*", " ",
185 | RowBox[{"(",
186 | RowBox[{
187 | RowBox[{"Dta", "[",
188 | RowBox[{
189 | RowBox[{"DN", "@", "i"}], ",", " ",
190 | RowBox[{"DN", "@", "j"}]}], "]"}], " ", "+", " ",
191 | RowBox[{"Eps", " ", "*", " ",
192 | RowBox[{"\[Gamma]", "[",
193 | RowBox[{
194 | RowBox[{"DN", "@", "i"}], ",", " ",
195 | RowBox[{"DN", "@", "j"}]}], "]"}]}], "+", " ",
196 | RowBox[{
197 | SuperscriptBox["Eps", "2"], "*",
198 | RowBox[{"\[Gamma]", "[",
199 | RowBox[{
200 | RowBox[{"DN", "@", "i"}], ",", " ",
201 | RowBox[{"DN", "@", "m"}]}], "]"}], "*",
202 | RowBox[{
203 | RowBox[{"\[Gamma]", "[",
204 | RowBox[{
205 | RowBox[{"DN", "@", "m"}], ",",
206 | RowBox[{"DN", "@", "j"}]}], "]"}], "/", "2"}]}]}], ")"}]}]}],
207 | "]"}]}], ";"}], "\n",
208 | RowBox[{
209 | RowBox[{
210 | RowBox[{
211 | RowBox[{"h", "[",
212 | RowBox[{
213 | RowBox[{"UP", "@", "i_"}], ",", " ",
214 | RowBox[{"UP", "@", "j_"}]}], "]"}], ":=", " ",
215 | RowBox[{"With", "[",
216 | RowBox[{
217 | RowBox[{"{",
218 | RowBox[{"m", "=",
219 | RowBox[{"Unique", "[", "]"}]}], "}"}], ",",
220 | RowBox[{
221 | RowBox[{
222 | RowBox[{"(",
223 | RowBox[{
224 | RowBox[{"Dta", "[",
225 | RowBox[{
226 | RowBox[{"DN", "@", "i"}], ",", " ",
227 | RowBox[{"DN", "@", "j"}]}], "]"}], " ", "-", " ",
228 | RowBox[{"Eps", " ", "*", " ",
229 | RowBox[{"\[Gamma]", "[",
230 | RowBox[{
231 | RowBox[{"DN", "@", "i"}], ",", " ",
232 | RowBox[{"DN", "@", "j"}]}], "]"}]}], " ", "+", " ",
233 | RowBox[{
234 | SuperscriptBox["Eps", "2"], "*",
235 | RowBox[{"\[Gamma]", "[",
236 | RowBox[{
237 | RowBox[{"DN", "@", "i"}], ",", " ",
238 | RowBox[{"DN", "@", "m"}]}], "]"}], "*",
239 | RowBox[{
240 | RowBox[{"\[Gamma]", "[",
241 | RowBox[{
242 | RowBox[{"DN", "@", "m"}], ",",
243 | RowBox[{"DN", "@", "j"}]}], "]"}], "/", "2"}]}]}], ")"}], "/",
244 | "a"}], " ", "/", "a"}]}], "]"}]}], ";"}],
245 | "\[IndentingNewLine]"}], "\[IndentingNewLine]",
246 | RowBox[{
247 | RowBox[{
248 | RowBox[{"DecompHook", " ", "=", " ",
249 | RowBox[{"{", " ", "\n", "\t",
250 | RowBox[{
251 | RowBox[{
252 | RowBox[{"g", "[",
253 | RowBox[{
254 | RowBox[{"DN", "@", "i_"}], ",", " ",
255 | RowBox[{"DN", "@", "j_"}]}], "]"}], ":>", " ",
256 | RowBox[{"h", "[",
257 | RowBox[{
258 | RowBox[{"DN", "@", "i"}], ",", " ",
259 | RowBox[{"DN", "@", "j"}]}], "]"}]}], ",", "\n", "\t",
260 | RowBox[{
261 | RowBox[{"g", "[",
262 | RowBox[{
263 | RowBox[{"DE", "@", "0"}], ",", " ",
264 | RowBox[{"DE", "@", "0"}]}], "]"}], ":>", " ",
265 | RowBox[{"(",
266 | RowBox[{
267 | RowBox[{
268 | RowBox[{
269 | RowBox[{"-",
270 | RowBox[{"LapseN", "^", "2"}]}], " ", "+", " ",
271 | RowBox[{
272 | RowBox[{"h", "[",
273 | RowBox[{
274 | RowBox[{"UP", "@", "#1"}], ",", " ",
275 | RowBox[{"UP", "@", "#2"}]}], "]"}],
276 | RowBox[{"ShiftN", "[",
277 | RowBox[{"DN", "@", "#1"}], "]"}],
278 | RowBox[{"ShiftN", "[",
279 | RowBox[{"DN", "@", "#2"}], "]"}]}]}], " ", "&"}], "@",
280 | RowBox[{"Uq", "[", "2", "]"}]}], ")"}]}], ",", "\n", "\t",
281 | RowBox[{
282 | RowBox[{"g", "[",
283 | RowBox[{
284 | RowBox[{"DE", "@", "0"}], ",", " ",
285 | RowBox[{"DN", "@", "i_"}]}], "]"}], ":>", " ",
286 | RowBox[{"ShiftN", "[",
287 | RowBox[{"DN", "@", "i"}], "]"}]}], ",", "\n", "\t",
288 | RowBox[{
289 | RowBox[{"g", "[",
290 | RowBox[{
291 | RowBox[{"UP", "@", "i_"}], ",", " ",
292 | RowBox[{"UP", "@", "j_"}]}], "]"}], ":>", " ",
293 | RowBox[{"(",
294 | RowBox[{
295 | RowBox[{
296 | RowBox[{
297 | RowBox[{"h", "[",
298 | RowBox[{
299 | RowBox[{"UP", "@", "i"}], ",", " ",
300 | RowBox[{"UP", "@", "j"}]}], "]"}], " ", "-", " ",
301 | RowBox[{
302 | RowBox[{"ShiftN", "[",
303 | RowBox[{"DN", "@", "#1"}], "]"}],
304 | RowBox[{"ShiftN", "[",
305 | RowBox[{"DN", "@", "#2"}], "]"}],
306 | RowBox[{"h", "[",
307 | RowBox[{
308 | RowBox[{"UP", "@", "#1"}], ",", " ",
309 | RowBox[{"UP", "@", "i"}]}], "]"}],
310 | RowBox[{
311 | RowBox[{"h", "[",
312 | RowBox[{
313 | RowBox[{"UP", "@", "#2"}], ",", " ",
314 | RowBox[{"UP", "@", "j"}]}], "]"}], "/",
315 | RowBox[{"LapseN", "^", "2"}]}]}]}], " ", "&"}], "@",
316 | RowBox[{"Uq", "[", "2", "]"}]}], ")"}]}], ",", "\n", "\t",
317 | RowBox[{
318 | RowBox[{"g", "[",
319 | RowBox[{
320 | RowBox[{"UE", "@", "0"}], ",", " ",
321 | RowBox[{"UE", "@", "0"}]}], "]"}], ":>", " ",
322 | RowBox[{
323 | RowBox[{"-", "1"}], "/",
324 | RowBox[{"LapseN", "^", "2"}]}]}], ",", "\n", "\t",
325 | RowBox[{
326 | RowBox[{"g", "[",
327 | RowBox[{
328 | RowBox[{"UE", "@", "0"}], ",", " ",
329 | RowBox[{"UP", "@", "i_"}]}], "]"}], ":>", " ",
330 | RowBox[{"(",
331 | RowBox[{
332 | RowBox[{
333 | RowBox[{
334 | RowBox[{"h", "[",
335 | RowBox[{
336 | RowBox[{"UP", "@", "i"}], ",", " ",
337 | RowBox[{"UP", "@", "#"}]}], "]"}],
338 | RowBox[{
339 | RowBox[{"ShiftN", "[",
340 | RowBox[{"DN", "@", "#"}], "]"}], "/",
341 | RowBox[{"LapseN", "^", "2"}]}]}], " ", "&"}], "@",
342 | RowBox[{"Uq", "[", "1", "]"}]}], ")"}]}]}], "}"}]}], ";"}],
343 | "\[IndentingNewLine]"}], "\[IndentingNewLine]",
344 | RowBox[{"SetAttributes", "[",
345 | RowBox[{"DecompG2H", ",", " ", "HoldAll"}], "]"}], "\n",
346 | RowBox[{
347 | RowBox[{
348 | RowBox[{"DecompG2H", "[", "f_", "]"}], ":=", " ",
349 | RowBox[{"Decomp0i", "@",
350 | RowBox[{"WithMetric", "[",
351 | RowBox[{"g", ",", " ",
352 | RowBox[{"{",
353 | RowBox[{"UTot", ",", " ", "DTot"}], "}"}], ",", " ",
354 | RowBox[{"MetricContract", "[", "f", "]"}]}], "]"}]}]}],
355 | ";"}], "\n"}], "Input",
356 | CellChangeTimes->{{3.7768510647120075`*^9, 3.7768512174046125`*^9}, {
357 | 3.77685130944748*^9, 3.7768513309889274`*^9}, {3.776851556117264*^9,
358 | 3.7768516418490295`*^9}, {3.776851777763562*^9, 3.7768518910548515`*^9}, {
359 | 3.7768519238883667`*^9, 3.7768519247693887`*^9}, {3.7768519961500854`*^9,
360 | 3.776852001493024*^9}, 3.7768522811159525`*^9, {3.7768523598785553`*^9,
361 | 3.7768523604126115`*^9}, {3.7768526821236873`*^9,
362 | 3.7768527178026075`*^9}, {3.77685276721873*^9, 3.7768527721957674`*^9}, {
363 | 3.7768545192848563`*^9,
364 | 3.7768545194567385`*^9}},ExpressionUUID->"66d649d1-11f6-48ad-b806-\
365 | 3d4bfcbc920d"],
366 |
367 | Cell[CellGroupData[{
368 |
369 | Cell[BoxData[
370 | RowBox[{"sFull", "=",
371 | RowBox[{
372 | RowBox[{
373 | RowBox[{"Sqrtg", " ",
374 | RowBox[{"(",
375 | RowBox[{"DecompG2H", "[",
376 | RowBox[{
377 | SuperscriptBox["Mp", "2"], " ",
378 | RowBox[{
379 | RowBox[{"R", "[", "]"}], "/", "2"}]}], "]"}], " ", ")"}]}], "//",
380 | RowBox[{"OO", "[", "2", "]"}]}], "//", "Simp"}]}]], "Input",
381 | CellChangeTimes->{{3.7768520097894955`*^9, 3.77685204709175*^9}, {
382 | 3.776852111971092*^9, 3.77685212659484*^9}, {3.776852170310563*^9,
383 | 3.776852170436559*^9}, {3.7768523448948803`*^9, 3.776852345011881*^9}, {
384 | 3.776852522649412*^9, 3.7768525267419825`*^9}, {3.776852742651534*^9,
385 | 3.7768527543751707`*^9}, {3.776854464014407*^9, 3.7768545077677455`*^9}},
386 | CellLabel->"In[21]:=",ExpressionUUID->"b74ba538-7fed-4999-ab79-012c9ef62808"],
387 |
388 | Cell[BoxData[
389 | RowBox[{
390 | RowBox[{
391 | FractionBox["1", "8"], " ",
392 | SuperscriptBox["a", "3"], " ",
393 | SuperscriptBox["Mp", "2"], " ",
394 | SuperscriptBox[
395 | OverscriptBox[
396 | TagBox[GridBox[{
397 | {GridBox[{
398 | {"\[Gamma]"}
399 | },
400 | Selectable->True], GridBox[{
401 | {"", ""},
402 | {
403 | StyleBox[
404 | TagBox[GridBox[{
405 | {"\<\"a\"\>"}
406 | },
407 | Selectable->True],
408 | MathGR`tensor`DN],
409 | FontSize->10,
410 | FontColor->GrayLevel[0]],
411 | StyleBox[
412 | TagBox[GridBox[{
413 | {"\<\"b\"\>"}
414 | },
415 | Selectable->True],
416 | MathGR`tensor`DN],
417 | FontSize->10,
418 | FontColor->GrayLevel[0]]}
419 | },
420 | GridBoxSpacings->{"Columns" -> {
421 | Offset[0.27999999999999997`], {
422 | Offset[0.]},
423 | Offset[0.27999999999999997`]}, "Rows" -> {
424 | Offset[0.2], {
425 | Offset[-0.2]},
426 | Offset[0.2]}}]}
427 | },
428 | GridBoxSpacings->{"Columns" -> {
429 | Offset[0.27999999999999997`], {
430 | Offset[0.]},
431 | Offset[0.27999999999999997`]}, "Rows" -> {
432 | Offset[0.2], {
433 | Offset[0.]},
434 | Offset[0.2]}},
435 | Selectable->False],
436 | "mgrTensor",
437 | Selectable->False,
438 | SyntaxForm->"symbol"], "\[Bullet]"], "2"]}], "-",
439 | RowBox[{
440 | FractionBox["1", "8"], " ", "a", " ",
441 | SuperscriptBox["Mp", "2"], " ",
442 | SuperscriptBox[
443 | RowBox[{"(",
444 | TagBox[GridBox[{
445 | {
446 | TagBox[GridBox[{
447 | {GridBox[{
448 | {
449 | TagBox["\[PartialD]",
450 | "mgrSa",
451 | Selectable->False]}
452 | },
453 | Selectable->True], GridBox[{
454 | {""},
455 | {
456 | StyleBox[
457 | TagBox[GridBox[{
458 | {"\<\"c\"\>"}
459 | },
460 | Selectable->True],
461 | MathGR`tensor`DN],
462 | FontSize->10,
463 | FontColor->GrayLevel[0]]}
464 | },
465 | GridBoxSpacings->{"Columns" -> {
466 | Offset[0.27999999999999997`], {
467 | Offset[0.]},
468 | Offset[0.27999999999999997`]}, "Rows" -> {
469 | Offset[0.2], {
470 | Offset[-0.2]},
471 | Offset[0.2]}}]}
472 | },
473 | GridBoxSpacings->{"Columns" -> {
474 | Offset[0.27999999999999997`], {
475 | Offset[0.]},
476 | Offset[0.27999999999999997`]}, "Rows" -> {
477 | Offset[0.2], {
478 | Offset[0.]},
479 | Offset[0.2]}},
480 | Selectable->False],
481 | "mgrTensor",
482 | Selectable->False,
483 | SyntaxForm->"symbol"], GridBox[{
484 | {
485 | TagBox[GridBox[{
486 | {GridBox[{
487 | {"\[Gamma]"}
488 | },
489 | Selectable->True], GridBox[{
490 | {"", ""},
491 | {
492 | StyleBox[
493 | TagBox[GridBox[{
494 | {"\<\"a\"\>"}
495 | },
496 | Selectable->True],
497 | MathGR`tensor`DN],
498 | FontSize->10,
499 | FontColor->GrayLevel[0]],
500 | StyleBox[
501 | TagBox[GridBox[{
502 | {"\<\"b\"\>"}
503 | },
504 | Selectable->True],
505 | MathGR`tensor`DN],
506 | FontSize->10,
507 | FontColor->GrayLevel[0]]}
508 | },
509 | GridBoxSpacings->{"Columns" -> {
510 | Offset[0.27999999999999997`], {
511 | Offset[0.]},
512 | Offset[0.27999999999999997`]}, "Rows" -> {
513 | Offset[0.2], {
514 | Offset[-0.2]},
515 | Offset[0.2]}}]}
516 | },
517 | GridBoxSpacings->{"Columns" -> {
518 | Offset[0.27999999999999997`], {
519 | Offset[0.]},
520 | Offset[0.27999999999999997`]}, "Rows" -> {
521 | Offset[0.2], {
522 | Offset[0.]},
523 | Offset[0.2]}},
524 | Selectable->False],
525 | "mgrTensor",
526 | Selectable->False,
527 | SyntaxForm->"symbol"]}
528 | },
529 | Selectable->True]}
530 | },
531 | GridBoxSpacings->{"Columns" -> {
532 | Offset[0.27999999999999997`], {
533 | Offset[0.]},
534 | Offset[0.27999999999999997`]}, "Rows" -> {
535 | Offset[0.2], {
536 | Offset[0.]},
537 | Offset[0.2]}}],
538 | "mgrPd",
539 | Selectable->False], ")"}], "2"]}]}]], "Output",
540 | CellChangeTimes->{
541 | 3.7768525282178497`*^9, 3.7768527284414043`*^9, 3.7768527882039924`*^9, {
542 | 3.7768544784951925`*^9, 3.776854509236477*^9}},
543 | CellLabel->"Out[21]=",ExpressionUUID->"54b6d26d-7633-4121-906a-9cc63af803c2"]
544 | }, Open ]]
545 | },
546 | WindowSize->{1503, 1676},
547 | WindowMargins->{{-7, Automatic}, {Automatic, 0}},
548 | Magnification:>1.5 Inherited,
549 | FrontEndVersion->"12.0 for Microsoft Windows (64-bit) (April 8, 2019)",
550 | StyleDefinitions->"Default.nb"
551 | ]
552 | (* End of Notebook Content *)
553 |
554 | (* Internal cache information *)
555 | (*CellTagsOutline
556 | CellTagsIndex->{}
557 | *)
558 | (*CellTagsIndex
559 | CellTagsIndex->{}
560 | *)
561 | (*NotebookFileOutline
562 | Notebook[{
563 | Cell[CellGroupData[{
564 | Cell[580, 22, 194, 3, 43, "Input",ExpressionUUID->"a79a70c0-85a4-4312-9f94-a6a5d184ed3f"],
565 | Cell[777, 27, 506, 7, 108, "Output",ExpressionUUID->"37b425f6-0e15-4f83-8239-9619aed9192c"]
566 | }, Open ]],
567 | Cell[1298, 37, 11648, 327, 1014, "Input",ExpressionUUID->"66d649d1-11f6-48ad-b806-3d4bfcbc920d"],
568 | Cell[CellGroupData[{
569 | Cell[12971, 368, 795, 17, 48, "Input",ExpressionUUID->"b74ba538-7fed-4999-ab79-012c9ef62808"],
570 | Cell[13769, 387, 4983, 155, 78, "Output",ExpressionUUID->"54b6d26d-7633-4121-906a-9cc63af803c2"]
571 | }, Open ]]
572 | }
573 | ]
574 | *)
575 |
576 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | GNU GENERAL PUBLIC LICENSE
2 | Version 3, 29 June 2007
3 |
4 | Copyright (C) 2007 Free Software Foundation, Inc. {http://fsf.org/}
5 | Everyone is permitted to copy and distribute verbatim copies
6 | of this license document, but changing it is not allowed.
7 |
8 | Preamble
9 |
10 | The GNU General Public License is a free, copyleft license for
11 | software and other kinds of works.
12 |
13 | The licenses for most software and other practical works are designed
14 | to take away your freedom to share and change the works. By contrast,
15 | the GNU General Public License is intended to guarantee your freedom to
16 | share and change all versions of a program--to make sure it remains free
17 | software for all its users. We, the Free Software Foundation, use the
18 | GNU General Public License for most of our software; it applies also to
19 | any other work released this way by its authors. You can apply it to
20 | your programs, too.
21 |
22 | When we speak of free software, we are referring to freedom, not
23 | price. Our General Public Licenses are designed to make sure that you
24 | have the freedom to distribute copies of free software (and charge for
25 | them if you wish), that you receive source code or can get it if you
26 | want it, that you can change the software or use pieces of it in new
27 | free programs, and that you know you can do these things.
28 |
29 | To protect your rights, we need to prevent others from denying you
30 | these rights or asking you to surrender the rights. Therefore, you have
31 | certain responsibilities if you distribute copies of the software, or if
32 | you modify it: responsibilities to respect the freedom of others.
33 |
34 | For example, if you distribute copies of such a program, whether
35 | gratis or for a fee, you must pass on to the recipients the same
36 | freedoms that you received. You must make sure that they, too, receive
37 | or can get the source code. And you must show them these terms so they
38 | know their rights.
39 |
40 | Developers that use the GNU GPL protect your rights with two steps:
41 | (1) assert copyright on the software, and (2) offer you this License
42 | giving you legal permission to copy, distribute and/or modify it.
43 |
44 | For the developers' and authors' protection, the GPL clearly explains
45 | that there is no warranty for this free software. For both users' and
46 | authors' sake, the GPL requires that modified versions be marked as
47 | changed, so that their problems will not be attributed erroneously to
48 | authors of previous versions.
49 |
50 | Some devices are designed to deny users access to install or run
51 | modified versions of the software inside them, although the manufacturer
52 | can do so. This is fundamentally incompatible with the aim of
53 | protecting users' freedom to change the software. The systematic
54 | pattern of such abuse occurs in the area of products for individuals to
55 | use, which is precisely where it is most unacceptable. Therefore, we
56 | have designed this version of the GPL to prohibit the practice for those
57 | products. If such problems arise substantially in other domains, we
58 | stand ready to extend this provision to those domains in future versions
59 | of the GPL, as needed to protect the freedom of users.
60 |
61 | Finally, every program is threatened constantly by software patents.
62 | States should not allow patents to restrict development and use of
63 | software on general-purpose computers, but in those that do, we wish to
64 | avoid the special danger that patents applied to a free program could
65 | make it effectively proprietary. To prevent this, the GPL assures that
66 | patents cannot be used to render the program non-free.
67 |
68 | The precise terms and conditions for copying, distribution and
69 | modification follow.
70 |
71 | TERMS AND CONDITIONS
72 |
73 | 0. Definitions.
74 |
75 | "This License" refers to version 3 of the GNU General Public License.
76 |
77 | "Copyright" also means copyright-like laws that apply to other kinds of
78 | works, such as semiconductor masks.
79 |
80 | "The Program" refers to any copyrightable work licensed under this
81 | License. Each licensee is addressed as "you". "Licensees" and
82 | "recipients" may be individuals or organizations.
83 |
84 | To "modify" a work means to copy from or adapt all or part of the work
85 | in a fashion requiring copyright permission, other than the making of an
86 | exact copy. The resulting work is called a "modified version" of the
87 | earlier work or a work "based on" the earlier work.
88 |
89 | A "covered work" means either the unmodified Program or a work based
90 | on the Program.
91 |
92 | To "propagate" a work means to do anything with it that, without
93 | permission, would make you directly or secondarily liable for
94 | infringement under applicable copyright law, except executing it on a
95 | computer or modifying a private copy. Propagation includes copying,
96 | distribution (with or without modification), making available to the
97 | public, and in some countries other activities as well.
98 |
99 | To "convey" a work means any kind of propagation that enables other
100 | parties to make or receive copies. Mere interaction with a user through
101 | a computer network, with no transfer of a copy, is not conveying.
102 |
103 | An interactive user interface displays "Appropriate Legal Notices"
104 | to the extent that it includes a convenient and prominently visible
105 | feature that (1) displays an appropriate copyright notice, and (2)
106 | tells the user that there is no warranty for the work (except to the
107 | extent that warranties are provided), that licensees may convey the
108 | work under this License, and how to view a copy of this License. If
109 | the interface presents a list of user commands or options, such as a
110 | menu, a prominent item in the list meets this criterion.
111 |
112 | 1. Source Code.
113 |
114 | The "source code" for a work means the preferred form of the work
115 | for making modifications to it. "Object code" means any non-source
116 | form of a work.
117 |
118 | A "Standard Interface" means an interface that either is an official
119 | standard defined by a recognized standards body, or, in the case of
120 | interfaces specified for a particular programming language, one that
121 | is widely used among developers working in that language.
122 |
123 | The "System Libraries" of an executable work include anything, other
124 | than the work as a whole, that (a) is included in the normal form of
125 | packaging a Major Component, but which is not part of that Major
126 | Component, and (b) serves only to enable use of the work with that
127 | Major Component, or to implement a Standard Interface for which an
128 | implementation is available to the public in source code form. A
129 | "Major Component", in this context, means a major essential component
130 | (kernel, window system, and so on) of the specific operating system
131 | (if any) on which the executable work runs, or a compiler used to
132 | produce the work, or an object code interpreter used to run it.
133 |
134 | The "Corresponding Source" for a work in object code form means all
135 | the source code needed to generate, install, and (for an executable
136 | work) run the object code and to modify the work, including scripts to
137 | control those activities. However, it does not include the work's
138 | System Libraries, or general-purpose tools or generally available free
139 | programs which are used unmodified in performing those activities but
140 | which are not part of the work. For example, Corresponding Source
141 | includes interface definition files associated with source files for
142 | the work, and the source code for shared libraries and dynamically
143 | linked subprograms that the work is specifically designed to require,
144 | such as by intimate data communication or control flow between those
145 | subprograms and other parts of the work.
146 |
147 | The Corresponding Source need not include anything that users
148 | can regenerate automatically from other parts of the Corresponding
149 | Source.
150 |
151 | The Corresponding Source for a work in source code form is that
152 | same work.
153 |
154 | 2. Basic Permissions.
155 |
156 | All rights granted under this License are granted for the term of
157 | copyright on the Program, and are irrevocable provided the stated
158 | conditions are met. This License explicitly affirms your unlimited
159 | permission to run the unmodified Program. The output from running a
160 | covered work is covered by this License only if the output, given its
161 | content, constitutes a covered work. This License acknowledges your
162 | rights of fair use or other equivalent, as provided by copyright law.
163 |
164 | You may make, run and propagate covered works that you do not
165 | convey, without conditions so long as your license otherwise remains
166 | in force. You may convey covered works to others for the sole purpose
167 | of having them make modifications exclusively for you, or provide you
168 | with facilities for running those works, provided that you comply with
169 | the terms of this License in conveying all material for which you do
170 | not control copyright. Those thus making or running the covered works
171 | for you must do so exclusively on your behalf, under your direction
172 | and control, on terms that prohibit them from making any copies of
173 | your copyrighted material outside their relationship with you.
174 |
175 | Conveying under any other circumstances is permitted solely under
176 | the conditions stated below. Sublicensing is not allowed; section 10
177 | makes it unnecessary.
178 |
179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law.
180 |
181 | No covered work shall be deemed part of an effective technological
182 | measure under any applicable law fulfilling obligations under article
183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or
184 | similar laws prohibiting or restricting circumvention of such
185 | measures.
186 |
187 | When you convey a covered work, you waive any legal power to forbid
188 | circumvention of technological measures to the extent such circumvention
189 | is effected by exercising rights under this License with respect to
190 | the covered work, and you disclaim any intention to limit operation or
191 | modification of the work as a means of enforcing, against the work's
192 | users, your or third parties' legal rights to forbid circumvention of
193 | technological measures.
194 |
195 | 4. Conveying Verbatim Copies.
196 |
197 | You may convey verbatim copies of the Program's source code as you
198 | receive it, in any medium, provided that you conspicuously and
199 | appropriately publish on each copy an appropriate copyright notice;
200 | keep intact all notices stating that this License and any
201 | non-permissive terms added in accord with section 7 apply to the code;
202 | keep intact all notices of the absence of any warranty; and give all
203 | recipients a copy of this License along with the Program.
204 |
205 | You may charge any price or no price for each copy that you convey,
206 | and you may offer support or warranty protection for a fee.
207 |
208 | 5. Conveying Modified Source Versions.
209 |
210 | You may convey a work based on the Program, or the modifications to
211 | produce it from the Program, in the form of source code under the
212 | terms of section 4, provided that you also meet all of these conditions:
213 |
214 | a) The work must carry prominent notices stating that you modified
215 | it, and giving a relevant date.
216 |
217 | b) The work must carry prominent notices stating that it is
218 | released under this License and any conditions added under section
219 | 7. This requirement modifies the requirement in section 4 to
220 | "keep intact all notices".
221 |
222 | c) You must license the entire work, as a whole, under this
223 | License to anyone who comes into possession of a copy. This
224 | License will therefore apply, along with any applicable section 7
225 | additional terms, to the whole of the work, and all its parts,
226 | regardless of how they are packaged. This License gives no
227 | permission to license the work in any other way, but it does not
228 | invalidate such permission if you have separately received it.
229 |
230 | d) If the work has interactive user interfaces, each must display
231 | Appropriate Legal Notices; however, if the Program has interactive
232 | interfaces that do not display Appropriate Legal Notices, your
233 | work need not make them do so.
234 |
235 | A compilation of a covered work with other separate and independent
236 | works, which are not by their nature extensions of the covered work,
237 | and which are not combined with it such as to form a larger program,
238 | in or on a volume of a storage or distribution medium, is called an
239 | "aggregate" if the compilation and its resulting copyright are not
240 | used to limit the access or legal rights of the compilation's users
241 | beyond what the individual works permit. Inclusion of a covered work
242 | in an aggregate does not cause this License to apply to the other
243 | parts of the aggregate.
244 |
245 | 6. Conveying Non-Source Forms.
246 |
247 | You may convey a covered work in object code form under the terms
248 | of sections 4 and 5, provided that you also convey the
249 | machine-readable Corresponding Source under the terms of this License,
250 | in one of these ways:
251 |
252 | a) Convey the object code in, or embodied in, a physical product
253 | (including a physical distribution medium), accompanied by the
254 | Corresponding Source fixed on a durable physical medium
255 | customarily used for software interchange.
256 |
257 | b) Convey the object code in, or embodied in, a physical product
258 | (including a physical distribution medium), accompanied by a
259 | written offer, valid for at least three years and valid for as
260 | long as you offer spare parts or customer support for that product
261 | model, to give anyone who possesses the object code either (1) a
262 | copy of the Corresponding Source for all the software in the
263 | product that is covered by this License, on a durable physical
264 | medium customarily used for software interchange, for a price no
265 | more than your reasonable cost of physically performing this
266 | conveying of source, or (2) access to copy the
267 | Corresponding Source from a network server at no charge.
268 |
269 | c) Convey individual copies of the object code with a copy of the
270 | written offer to provide the Corresponding Source. This
271 | alternative is allowed only occasionally and noncommercially, and
272 | only if you received the object code with such an offer, in accord
273 | with subsection 6b.
274 |
275 | d) Convey the object code by offering access from a designated
276 | place (gratis or for a charge), and offer equivalent access to the
277 | Corresponding Source in the same way through the same place at no
278 | further charge. You need not require recipients to copy the
279 | Corresponding Source along with the object code. If the place to
280 | copy the object code is a network server, the Corresponding Source
281 | may be on a different server (operated by you or a third party)
282 | that supports equivalent copying facilities, provided you maintain
283 | clear directions next to the object code saying where to find the
284 | Corresponding Source. Regardless of what server hosts the
285 | Corresponding Source, you remain obligated to ensure that it is
286 | available for as long as needed to satisfy these requirements.
287 |
288 | e) Convey the object code using peer-to-peer transmission, provided
289 | you inform other peers where the object code and Corresponding
290 | Source of the work are being offered to the general public at no
291 | charge under subsection 6d.
292 |
293 | A separable portion of the object code, whose source code is excluded
294 | from the Corresponding Source as a System Library, need not be
295 | included in conveying the object code work.
296 |
297 | A "User Product" is either (1) a "consumer product", which means any
298 | tangible personal property which is normally used for personal, family,
299 | or household purposes, or (2) anything designed or sold for incorporation
300 | into a dwelling. In determining whether a product is a consumer product,
301 | doubtful cases shall be resolved in favor of coverage. For a particular
302 | product received by a particular user, "normally used" refers to a
303 | typical or common use of that class of product, regardless of the status
304 | of the particular user or of the way in which the particular user
305 | actually uses, or expects or is expected to use, the product. A product
306 | is a consumer product regardless of whether the product has substantial
307 | commercial, industrial or non-consumer uses, unless such uses represent
308 | the only significant mode of use of the product.
309 |
310 | "Installation Information" for a User Product means any methods,
311 | procedures, authorization keys, or other information required to install
312 | and execute modified versions of a covered work in that User Product from
313 | a modified version of its Corresponding Source. The information must
314 | suffice to ensure that the continued functioning of the modified object
315 | code is in no case prevented or interfered with solely because
316 | modification has been made.
317 |
318 | If you convey an object code work under this section in, or with, or
319 | specifically for use in, a User Product, and the conveying occurs as
320 | part of a transaction in which the right of possession and use of the
321 | User Product is transferred to the recipient in perpetuity or for a
322 | fixed term (regardless of how the transaction is characterized), the
323 | Corresponding Source conveyed under this section must be accompanied
324 | by the Installation Information. But this requirement does not apply
325 | if neither you nor any third party retains the ability to install
326 | modified object code on the User Product (for example, the work has
327 | been installed in ROM).
328 |
329 | The requirement to provide Installation Information does not include a
330 | requirement to continue to provide support service, warranty, or updates
331 | for a work that has been modified or installed by the recipient, or for
332 | the User Product in which it has been modified or installed. Access to a
333 | network may be denied when the modification itself materially and
334 | adversely affects the operation of the network or violates the rules and
335 | protocols for communication across the network.
336 |
337 | Corresponding Source conveyed, and Installation Information provided,
338 | in accord with this section must be in a format that is publicly
339 | documented (and with an implementation available to the public in
340 | source code form), and must require no special password or key for
341 | unpacking, reading or copying.
342 |
343 | 7. Additional Terms.
344 |
345 | "Additional permissions" are terms that supplement the terms of this
346 | License by making exceptions from one or more of its conditions.
347 | Additional permissions that are applicable to the entire Program shall
348 | be treated as though they were included in this License, to the extent
349 | that they are valid under applicable law. If additional permissions
350 | apply only to part of the Program, that part may be used separately
351 | under those permissions, but the entire Program remains governed by
352 | this License without regard to the additional permissions.
353 |
354 | When you convey a copy of a covered work, you may at your option
355 | remove any additional permissions from that copy, or from any part of
356 | it. (Additional permissions may be written to require their own
357 | removal in certain cases when you modify the work.) You may place
358 | additional permissions on material, added by you to a covered work,
359 | for which you have or can give appropriate copyright permission.
360 |
361 | Notwithstanding any other provision of this License, for material you
362 | add to a covered work, you may (if authorized by the copyright holders of
363 | that material) supplement the terms of this License with terms:
364 |
365 | a) Disclaiming warranty or limiting liability differently from the
366 | terms of sections 15 and 16 of this License; or
367 |
368 | b) Requiring preservation of specified reasonable legal notices or
369 | author attributions in that material or in the Appropriate Legal
370 | Notices displayed by works containing it; or
371 |
372 | c) Prohibiting misrepresentation of the origin of that material, or
373 | requiring that modified versions of such material be marked in
374 | reasonable ways as different from the original version; or
375 |
376 | d) Limiting the use for publicity purposes of names of licensors or
377 | authors of the material; or
378 |
379 | e) Declining to grant rights under trademark law for use of some
380 | trade names, trademarks, or service marks; or
381 |
382 | f) Requiring indemnification of licensors and authors of that
383 | material by anyone who conveys the material (or modified versions of
384 | it) with contractual assumptions of liability to the recipient, for
385 | any liability that these contractual assumptions directly impose on
386 | those licensors and authors.
387 |
388 | All other non-permissive additional terms are considered "further
389 | restrictions" within the meaning of section 10. If the Program as you
390 | received it, or any part of it, contains a notice stating that it is
391 | governed by this License along with a term that is a further
392 | restriction, you may remove that term. If a license document contains
393 | a further restriction but permits relicensing or conveying under this
394 | License, you may add to a covered work material governed by the terms
395 | of that license document, provided that the further restriction does
396 | not survive such relicensing or conveying.
397 |
398 | If you add terms to a covered work in accord with this section, you
399 | must place, in the relevant source files, a statement of the
400 | additional terms that apply to those files, or a notice indicating
401 | where to find the applicable terms.
402 |
403 | Additional terms, permissive or non-permissive, may be stated in the
404 | form of a separately written license, or stated as exceptions;
405 | the above requirements apply either way.
406 |
407 | 8. Termination.
408 |
409 | You may not propagate or modify a covered work except as expressly
410 | provided under this License. Any attempt otherwise to propagate or
411 | modify it is void, and will automatically terminate your rights under
412 | this License (including any patent licenses granted under the third
413 | paragraph of section 11).
414 |
415 | However, if you cease all violation of this License, then your
416 | license from a particular copyright holder is reinstated (a)
417 | provisionally, unless and until the copyright holder explicitly and
418 | finally terminates your license, and (b) permanently, if the copyright
419 | holder fails to notify you of the violation by some reasonable means
420 | prior to 60 days after the cessation.
421 |
422 | Moreover, your license from a particular copyright holder is
423 | reinstated permanently if the copyright holder notifies you of the
424 | violation by some reasonable means, this is the first time you have
425 | received notice of violation of this License (for any work) from that
426 | copyright holder, and you cure the violation prior to 30 days after
427 | your receipt of the notice.
428 |
429 | Termination of your rights under this section does not terminate the
430 | licenses of parties who have received copies or rights from you under
431 | this License. If your rights have been terminated and not permanently
432 | reinstated, you do not qualify to receive new licenses for the same
433 | material under section 10.
434 |
435 | 9. Acceptance Not Required for Having Copies.
436 |
437 | You are not required to accept this License in order to receive or
438 | run a copy of the Program. Ancillary propagation of a covered work
439 | occurring solely as a consequence of using peer-to-peer transmission
440 | to receive a copy likewise does not require acceptance. However,
441 | nothing other than this License grants you permission to propagate or
442 | modify any covered work. These actions infringe copyright if you do
443 | not accept this License. Therefore, by modifying or propagating a
444 | covered work, you indicate your acceptance of this License to do so.
445 |
446 | 10. Automatic Licensing of Downstream Recipients.
447 |
448 | Each time you convey a covered work, the recipient automatically
449 | receives a license from the original licensors, to run, modify and
450 | propagate that work, subject to this License. You are not responsible
451 | for enforcing compliance by third parties with this License.
452 |
453 | An "entity transaction" is a transaction transferring control of an
454 | organization, or substantially all assets of one, or subdividing an
455 | organization, or merging organizations. If propagation of a covered
456 | work results from an entity transaction, each party to that
457 | transaction who receives a copy of the work also receives whatever
458 | licenses to the work the party's predecessor in interest had or could
459 | give under the previous paragraph, plus a right to possession of the
460 | Corresponding Source of the work from the predecessor in interest, if
461 | the predecessor has it or can get it with reasonable efforts.
462 |
463 | You may not impose any further restrictions on the exercise of the
464 | rights granted or affirmed under this License. For example, you may
465 | not impose a license fee, royalty, or other charge for exercise of
466 | rights granted under this License, and you may not initiate litigation
467 | (including a cross-claim or counterclaim in a lawsuit) alleging that
468 | any patent claim is infringed by making, using, selling, offering for
469 | sale, or importing the Program or any portion of it.
470 |
471 | 11. Patents.
472 |
473 | A "contributor" is a copyright holder who authorizes use under this
474 | License of the Program or a work on which the Program is based. The
475 | work thus licensed is called the contributor's "contributor version".
476 |
477 | A contributor's "essential patent claims" are all patent claims
478 | owned or controlled by the contributor, whether already acquired or
479 | hereafter acquired, that would be infringed by some manner, permitted
480 | by this License, of making, using, or selling its contributor version,
481 | but do not include claims that would be infringed only as a
482 | consequence of further modification of the contributor version. For
483 | purposes of this definition, "control" includes the right to grant
484 | patent sublicenses in a manner consistent with the requirements of
485 | this License.
486 |
487 | Each contributor grants you a non-exclusive, worldwide, royalty-free
488 | patent license under the contributor's essential patent claims, to
489 | make, use, sell, offer for sale, import and otherwise run, modify and
490 | propagate the contents of its contributor version.
491 |
492 | In the following three paragraphs, a "patent license" is any express
493 | agreement or commitment, however denominated, not to enforce a patent
494 | (such as an express permission to practice a patent or covenant not to
495 | sue for patent infringement). To "grant" such a patent license to a
496 | party means to make such an agreement or commitment not to enforce a
497 | patent against the party.
498 |
499 | If you convey a covered work, knowingly relying on a patent license,
500 | and the Corresponding Source of the work is not available for anyone
501 | to copy, free of charge and under the terms of this License, through a
502 | publicly available network server or other readily accessible means,
503 | then you must either (1) cause the Corresponding Source to be so
504 | available, or (2) arrange to deprive yourself of the benefit of the
505 | patent license for this particular work, or (3) arrange, in a manner
506 | consistent with the requirements of this License, to extend the patent
507 | license to downstream recipients. "Knowingly relying" means you have
508 | actual knowledge that, but for the patent license, your conveying the
509 | covered work in a country, or your recipient's use of the covered work
510 | in a country, would infringe one or more identifiable patents in that
511 | country that you have reason to believe are valid.
512 |
513 | If, pursuant to or in connection with a single transaction or
514 | arrangement, you convey, or propagate by procuring conveyance of, a
515 | covered work, and grant a patent license to some of the parties
516 | receiving the covered work authorizing them to use, propagate, modify
517 | or convey a specific copy of the covered work, then the patent license
518 | you grant is automatically extended to all recipients of the covered
519 | work and works based on it.
520 |
521 | A patent license is "discriminatory" if it does not include within
522 | the scope of its coverage, prohibits the exercise of, or is
523 | conditioned on the non-exercise of one or more of the rights that are
524 | specifically granted under this License. You may not convey a covered
525 | work if you are a party to an arrangement with a third party that is
526 | in the business of distributing software, under which you make payment
527 | to the third party based on the extent of your activity of conveying
528 | the work, and under which the third party grants, to any of the
529 | parties who would receive the covered work from you, a discriminatory
530 | patent license (a) in connection with copies of the covered work
531 | conveyed by you (or copies made from those copies), or (b) primarily
532 | for and in connection with specific products or compilations that
533 | contain the covered work, unless you entered into that arrangement,
534 | or that patent license was granted, prior to 28 March 2007.
535 |
536 | Nothing in this License shall be construed as excluding or limiting
537 | any implied license or other defenses to infringement that may
538 | otherwise be available to you under applicable patent law.
539 |
540 | 12. No Surrender of Others' Freedom.
541 |
542 | If conditions are imposed on you (whether by court order, agreement or
543 | otherwise) that contradict the conditions of this License, they do not
544 | excuse you from the conditions of this License. If you cannot convey a
545 | covered work so as to satisfy simultaneously your obligations under this
546 | License and any other pertinent obligations, then as a consequence you may
547 | not convey it at all. For example, if you agree to terms that obligate you
548 | to collect a royalty for further conveying from those to whom you convey
549 | the Program, the only way you could satisfy both those terms and this
550 | License would be to refrain entirely from conveying the Program.
551 |
552 | 13. Use with the GNU Affero General Public License.
553 |
554 | Notwithstanding any other provision of this License, you have
555 | permission to link or combine any covered work with a work licensed
556 | under version 3 of the GNU Affero General Public License into a single
557 | combined work, and to convey the resulting work. The terms of this
558 | License will continue to apply to the part which is the covered work,
559 | but the special requirements of the GNU Affero General Public License,
560 | section 13, concerning interaction through a network will apply to the
561 | combination as such.
562 |
563 | 14. Revised Versions of this License.
564 |
565 | The Free Software Foundation may publish revised and/or new versions of
566 | the GNU General Public License from time to time. Such new versions will
567 | be similar in spirit to the present version, but may differ in detail to
568 | address new problems or concerns.
569 |
570 | Each version is given a distinguishing version number. If the
571 | Program specifies that a certain numbered version of the GNU General
572 | Public License "or any later version" applies to it, you have the
573 | option of following the terms and conditions either of that numbered
574 | version or of any later version published by the Free Software
575 | Foundation. If the Program does not specify a version number of the
576 | GNU General Public License, you may choose any version ever published
577 | by the Free Software Foundation.
578 |
579 | If the Program specifies that a proxy can decide which future
580 | versions of the GNU General Public License can be used, that proxy's
581 | public statement of acceptance of a version permanently authorizes you
582 | to choose that version for the Program.
583 |
584 | Later license versions may give you additional or different
585 | permissions. However, no additional obligations are imposed on any
586 | author or copyright holder as a result of your choosing to follow a
587 | later version.
588 |
589 | 15. Disclaimer of Warranty.
590 |
591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
599 |
600 | 16. Limitation of Liability.
601 |
602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
610 | SUCH DAMAGES.
611 |
612 | 17. Interpretation of Sections 15 and 16.
613 |
614 | If the disclaimer of warranty and limitation of liability provided
615 | above cannot be given local legal effect according to their terms,
616 | reviewing courts shall apply local law that most closely approximates
617 | an absolute waiver of all civil liability in connection with the
618 | Program, unless a warranty or assumption of liability accompanies a
619 | copy of the Program in return for a fee.
620 |
621 | END OF TERMS AND CONDITIONS
622 |
623 | How to Apply These Terms to Your New Programs
624 |
625 | If you develop a new program, and you want it to be of the greatest
626 | possible use to the public, the best way to achieve this is to make it
627 | free software which everyone can redistribute and change under these terms.
628 |
629 | To do so, attach the following notices to the program. It is safest
630 | to attach them to the start of each source file to most effectively
631 | state the exclusion of warranty; and each file should have at least
632 | the "copyright" line and a pointer to where the full notice is found.
633 |
634 | {one line to give the program's name and a brief idea of what it does.}
635 | Copyright (C) {year} {name of author}
636 |
637 | This program is free software: you can redistribute it and/or modify
638 | it under the terms of the GNU General Public License as published by
639 | the Free Software Foundation, either version 3 of the License, or
640 | (at your option) any later version.
641 |
642 | This program is distributed in the hope that it will be useful,
643 | but WITHOUT ANY WARRANTY; without even the implied warranty of
644 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
645 | GNU General Public License for more details.
646 |
647 | You should have received a copy of the GNU General Public License
648 | along with this program. If not, see {http://www.gnu.org/licenses/}.
649 |
650 | Also add information on how to contact you by electronic and paper mail.
651 |
652 | If the program does terminal interaction, make it output a short
653 | notice like this when it starts in an interactive mode:
654 |
655 | MathGR Copyright (C) 2013 Yi Wang
656 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
657 | This is free software, and you are welcome to redistribute it
658 | under certain conditions; type `show c' for details.
659 |
660 | The hypothetical commands `show w' and `show c' should show the appropriate
661 | parts of the General Public License. Of course, your program's commands
662 | might be different; for a GUI interface, you would use an "about box".
663 |
664 | You should also get your employer (if you work as a programmer) or school,
665 | if any, to sign a "copyright disclaimer" for the program, if necessary.
666 | For more information on this, and how to apply and follow the GNU GPL, see
667 | {http://www.gnu.org/licenses/}.
668 |
669 | The GNU General Public License does not permit incorporating your program
670 | into proprietary programs. If your program is a subroutine library, you
671 | may consider it more useful to permit linking proprietary applications with
672 | the library. If this is what you want to do, use the GNU Lesser General
673 | Public License instead of this License. But first, please read
674 | {http://www.gnu.org/philosophy/why-not-lgpl.html}.
675 |
--------------------------------------------------------------------------------
/resources/GRE/GRE.m:
--------------------------------------------------------------------------------
1 | (* ::Package:: *)
2 |
3 | (************************************************************************)
4 | (* This file was generated automatically by the Mathematica front end. *)
5 | (* It contains Initialization cells from a Notebook file, which *)
6 | (* typically will have the same name as this file except ending in *)
7 | (* ".nb" instead of ".m". *)
8 | (* *)
9 | (* This file is intended to be loaded into the Mathematica kernel using *)
10 | (* the package loading commands Get or Needs. Doing so is equivalent *)
11 | (* to using the Evaluate Initialization Cells menu command in the front *)
12 | (* end. *)
13 | (* *)
14 | (* DO NOT EDIT THIS FILE. This entire file is regenerated *)
15 | (* automatically each time the parent Notebook file is saved in the *)
16 | (* Mathematica front end. Any changes you make to this file will be *)
17 | (* overwritten. *)
18 | (************************************************************************)
19 |
20 |
21 |
22 | ClearAll[\[DoubleStruckD],GRETsr];
23 |
24 |
25 | SetAttributes[DefQ, HoldAll];
26 | DefQ[x_]:= {OwnValues[x],UpValues[x],DownValues[x]} =!= {{},{},{}};
27 |
28 |
29 | If[!DefQ[Col],Col={Unique[]}];
30 | If[!DefQ[Simp], Simp[e_] := Collect[e, Col, Simplify]];
31 |
32 |
33 | If[!DefQ[\[DoubleStruckX]], Print["Please define coordinate before running GRE. Aborting."];Abort[]];
34 | If[DefQ[\[DoubleStruckD]s2], \[DoubleStruckG]Mat = Simp[Map[Coefficient[\[DoubleStruckD]s2,#[[2]]]/If[#[[1]],1,2]&,Table[{i===j,\[DoubleStruckD][i]\[DoubleStruckD][j]},{i,\[DoubleStruckX]},{j,\[DoubleStruckX]}],{2}]],
35 | If[DefQ[\[DoubleStruckG]Mat], \[DoubleStruckD]s2 = (Table[\[DoubleStruckD][i],{i,\[DoubleStruckX]}] . \[DoubleStruckG]Mat . Table[{\[DoubleStruckD][i]},{i,\[DoubleStruckX]}])[[1]]//Simp,
36 | Print["Please define either \[DoubleStruckD]s2 or \[DoubleStruckG] before running GRE. Aborting."];Abort[]]];
37 |
38 |
39 | (* ::Input::Initialization:: *)
40 | If[!DefQ[SignConvention],SignConvention = "MTW"];
41 | If[!MemberQ[{"MTW","Weinberg"},SignConvention],Print["Unknown sign convention. Aborting.";Abort[]] ];
42 | R4Sign["MTW"]=+1;
43 | R4Sign["Weinberg"]=-1;
44 |
45 |
46 | PdBox[lst_]:= StyleBox[#, FontSize->10]&@ GridBox[#, Selectable->True, ColumnSpacings->0, RowSpacings->0]&@ Transpose@DeleteCases[Transpose[Map[ToBoxes,lst,{2}]]/.{"1",dn_}:>{"",dn},{"0",_}];
47 | MakeBoxes[Derivative[d__][f_][x__],StandardForm]:= TagBox[RowBox[{GridBox[{{"\[PartialD]", PdBox[{{d},{x}}],
48 | GridBox[{{ToBoxes@f@x}}, Selectable->True]}}, ColumnSpacings->0, RowSpacings->0],""}],"GRED", Selectable->False] /;Length[{x}]>1 && VectorQ[{d}, NumberQ] \
49 | && VectorQ[{x}, AtomQ] (* to avoid formatting D[f[x+y,z+w], x] *) \
50 | && Length@DeleteDuplicates@{x}===Length@{x} (* to avoid formatting D[f[x, x], x] *)
51 |
52 |
53 | MakeExpression[TagBox[GridBox[{{"\[PartialD]", StyleBox[GridBox[{n__,x__},___],___], GridBox[{{f_}},___]}}, ___],"GRED", ___], StandardForm]:=
54 | With[{h=ToExpression@f,ids=Sequence@@Transpose@Map[ToExpression,{x,n/.\!\(\*
55 | TagBox[
56 | StyleBox["\"\<\>\"",
57 | ShowSpecialCharacters->False,
58 | ShowStringCharacters->True,
59 | NumberMarks->True],
60 | FullForm]\)->"1"},{2}]},HoldComplete[D[h,ids]]]
61 |
62 |
63 | MakeBoxes[GRETsr[t_,i_List],StandardForm]:=With[{
64 | tBox=GridBox[{{ToBoxes@t}},Selectable->True],
65 | iBox=StyleBox[GridBox[Map[ToBoxes,i,{2}]/.{"\[Placeholder]"->"","Null"->""}, ColumnSpacings->0, RowSpacings->0, Selectable->True],FontSize->10]},
66 | TagBox[GridBox[{{tBox,iBox}}, ColumnSpacings->0, RowSpacings->0],"GRETsr", Selectable->False]];
67 |
68 | MakeExpression[TagBox[GridBox[{{GridBox[{{f_}},___],StyleBox[GridBox[i_List,___],___]}},___],"GRETsr",___],StandardForm]:=
69 | With[{fExpr=ToExpression@f,iExpr=Map[ToExpression,i/."\[Placeholder]"->"",{2}]}, HoldComplete@GRETsr[fExpr,iExpr]];
70 |
71 |
72 | nonSystemFunctionPattern = HoldPattern[f_ /; Head[f]=!=Symbol || (Head[f]==Symbol && Context[f]=!="System`")];
73 |
74 | With[{fx=(f:nonSystemFunctionPattern)@@\[DoubleStruckX]}, MakeBoxes[fx, StandardForm]:= TagBox[StyleBox[ToBoxes[f],Red],"GREFX",Selectable->False]];
75 | MakeExpression[TagBox[f_,"GREFX",___],StandardForm]:= With[{fx=ToExpression[f]@@\[DoubleStruckX]},HoldComplete@fx];
76 |
77 | With[{fx=(f:nonSystemFunctionPattern)[\[DoubleStruckX][[1]]]}, MakeBoxes[fx, StandardForm]:= TagBox[StyleBox[ToBoxes[f],Purple],"GREFX0",Selectable->False]];
78 | MakeExpression[TagBox[f_,"GREFX0",___],StandardForm]:= With[{fx=ToExpression[f][\[DoubleStruckX][[1]]]},HoldComplete@fx];
79 |
80 | With[{fx=(f:nonSystemFunctionPattern)[\[DoubleStruckX][[2]]]}, MakeBoxes[fx, StandardForm]:= TagBox[StyleBox[ToBoxes[f],Blue],"GREFX1",Selectable->False]];
81 | MakeExpression[TagBox[f_,"GREFX1",___],StandardForm]:= With[{fx=ToExpression[f][\[DoubleStruckX][[2]]]},HoldComplete@fx];
82 |
83 |
84 | addAlias[alias_]:=CurrentValue[$FrontEndSession,{InputAliases,alias[[1]]}]=alias[[2]];
85 | aliasList = {
86 | "eu"->ToBoxes[GRETsr[\[SelectionPlaceholder],{{0},{Null}}]],
87 | "ed"->ToBoxes[GRETsr[\[SelectionPlaceholder],{{Null},{0}}]],
88 | "euu"->ToBoxes[GRETsr[\[SelectionPlaceholder],{{0,0},{Null,Null}}]],
89 | "eud"->ToBoxes[GRETsr[\[SelectionPlaceholder],{{0,Null},{Null,0}}]],
90 | "edu"->ToBoxes[GRETsr[\[SelectionPlaceholder],{{Null,0},{0,Null}}]],
91 | "edd"->ToBoxes[GRETsr[\[SelectionPlaceholder],{{Null,Null},{0,0}}]],
92 | "eudd"->ToBoxes[GRETsr[\[SelectionPlaceholder],{{0,Null,Null},{Null,0,0}}]],
93 | "euddd"->ToBoxes[GRETsr[\[SelectionPlaceholder],{{0,Null,Null,Null},{Null,0,0,0}}]],
94 | "edddd"->ToBoxes[GRETsr[\[SelectionPlaceholder],{{Null,Null,Null,Null},{0,0,0,0}}]],
95 | "et"->ToBoxes[GRETsr[\[SelectionPlaceholder],{{0},{0}}]],
96 | "ex"->ToBoxes[\[SelectionPlaceholder]@@\[DoubleStruckX]],
97 | "e0"->ToBoxes[\[SelectionPlaceholder][\[DoubleStruckX][[1]]]],
98 | "ep"->ToBoxes[Unevaluated@D[\[Placeholder],\[SelectionPlaceholder]]]
99 | };
100 | addAlias/@(aliasList/."0"->"\[Placeholder]");
101 |
102 |
103 | Evaluate@Table[\!\(\*
104 | TagBox[GridBox[{
105 | {GridBox[{
106 | {"\[DoubleStruckG]"}
107 | },
108 | Selectable->True],
109 | StyleBox[GridBox[{
110 | {"", ""},
111 | {"\[Mu]", "\[Nu]"}
112 | },
113 | GridBoxSpacings->{"Columns" -> {Offset[0.27999999999999997`], {Offset[0.]}, Offset[0.27999999999999997`]}, "ColumnsIndexed" -> {}, "Rows" -> {Offset[0.2], {Offset[0.]}, Offset[0.2]}, "RowsIndexed" -> {}},
114 | Selectable->True],
115 | FontSize->10]}
116 | },
117 | GridBoxSpacings->{"Columns" -> {Offset[0.27999999999999997`], {Offset[0.]}, Offset[0.27999999999999997`]}, "ColumnsIndexed" -> {}, "Rows" -> {Offset[0.2], {Offset[0.]}, Offset[0.2]}, "RowsIndexed" -> {}}],
118 | "GRETsr",
119 | Selectable->False]\),{\[Mu],\[DoubleStruckX]},{\[Nu],\[DoubleStruckX]}] = \[DoubleStruckG]Mat;
120 | \[DoubleStruckG]uuMat = Inverse@\[DoubleStruckG]Mat//Simp;
121 | Evaluate@Table[\!\(\*
122 | TagBox[GridBox[{
123 | {GridBox[{
124 | {"\[DoubleStruckG]"}
125 | },
126 | Selectable->True],
127 | StyleBox[GridBox[{
128 | {"\[Mu]", "\[Nu]"},
129 | {"", ""}
130 | },
131 | GridBoxSpacings->{"Columns" -> {Offset[0.27999999999999997`], {Offset[0.]}, Offset[0.27999999999999997`]}, "ColumnsIndexed" -> {}, "Rows" -> {Offset[0.2], {Offset[0.]}, Offset[0.2]}, "RowsIndexed" -> {}},
132 | Selectable->True],
133 | FontSize->10]}
134 | },
135 | GridBoxSpacings->{"Columns" -> {Offset[0.27999999999999997`], {Offset[0.]}, Offset[0.27999999999999997`]}, "ColumnsIndexed" -> {}, "Rows" -> {Offset[0.2], {Offset[0.]}, Offset[0.2]}, "RowsIndexed" -> {}}],
136 | "GRETsr",
137 | Selectable->False]\),{\[Mu],\[DoubleStruckX]},{\[Nu],\[DoubleStruckX]}] = \[DoubleStruckG]uuMat;
138 | \[DoubleStruckG][] = Det[\[DoubleStruckG]Mat]//Simp;
139 |
140 |
141 | Module[{\[Sigma],\[Eta],\[Lambda],\[Mu],\[Alpha],\[Beta]}, (* Protect those variables in case the users give meaning to them. *)
142 | \!\(\*
143 | TagBox[GridBox[{
144 | {GridBox[{
145 | {"\[CapitalGamma]"}
146 | },
147 | Selectable->True],
148 | StyleBox[GridBox[{
149 | {"\[Lambda]_", "", ""},
150 | {"", "\[Mu]_", "\[Nu]_"}
151 | },
152 | GridBoxSpacings->{"Columns" -> {Offset[0.27999999999999997`], {Offset[0.]}, Offset[0.27999999999999997`]}, "ColumnsIndexed" -> {}, "Rows" -> {Offset[0.2], {Offset[0.]}, Offset[0.2]}, "RowsIndexed" -> {}},
153 | Selectable->True],
154 | FontSize->10]}
155 | },
156 | GridBoxSpacings->{"Columns" -> {Offset[0.27999999999999997`], {Offset[0.]}, Offset[0.27999999999999997`]}, "ColumnsIndexed" -> {}, "Rows" -> {Offset[0.2], {Offset[0.]}, Offset[0.2]}, "RowsIndexed" -> {}}],
157 | "GRETsr",
158 | Selectable->False]\) := \!\(\*
159 | TagBox[GridBox[{
160 | {GridBox[{
161 | {"\[CapitalGamma]"}
162 | },
163 | Selectable->True],
164 | StyleBox[GridBox[{
165 | {"\[Lambda]", "", ""},
166 | {"", "\[Mu]", "\[Nu]"}
167 | },
168 | GridBoxSpacings->{"Columns" -> {Offset[0.27999999999999997`], {Offset[0.]}, Offset[0.27999999999999997`]}, "ColumnsIndexed" -> {}, "Rows" -> {Offset[0.2], {Offset[0.]}, Offset[0.2]}, "RowsIndexed" -> {}},
169 | Selectable->True],
170 | FontSize->10]}
171 | },
172 | GridBoxSpacings->{"Columns" -> {Offset[0.27999999999999997`], {Offset[0.]}, Offset[0.27999999999999997`]}, "ColumnsIndexed" -> {}, "Rows" -> {Offset[0.2], {Offset[0.]}, Offset[0.2]}, "RowsIndexed" -> {}}],
173 | "GRETsr",
174 | Selectable->False]\) =\!\(\*
175 | TagBox[GridBox[{
176 | {GridBox[{
177 | {
178 | RowBox[{" ", "\[CapitalGamma]"}]}
179 | },
180 | Selectable->True],
181 | StyleBox[GridBox[{
182 | {"\[Lambda]", "", ""},
183 | {"", "\[Nu]", "\[Mu]"}
184 | },
185 | GridBoxSpacings->{"Columns" -> {Offset[0.27999999999999997`], {Offset[0.]}, Offset[0.27999999999999997`]}, "ColumnsIndexed" -> {}, "Rows" -> {Offset[0.2], {Offset[0.]}, Offset[0.2]}, "RowsIndexed" -> {}},
186 | Selectable->True],
187 | FontSize->10]}
188 | },
189 | GridBoxSpacings->{"Columns" -> {Offset[0.27999999999999997`], {Offset[0.]}, Offset[0.27999999999999997`]}, "ColumnsIndexed" -> {}, "Rows" -> {Offset[0.2], {Offset[0.]}, Offset[0.2]}, "RowsIndexed" -> {}}],
190 | "GRETsr",
191 | Selectable->False]\) = Simp[\!\(
192 | \*UnderoverscriptBox[\(\[Sum]\), \(\[Sigma]\), \(\[DoubleStruckX]\)]\ \(
193 | \*FractionBox[\(1\), \(2\)]\ \*
194 | TagBox[GridBox[{
195 | {GridBox[{
196 | {"\[DoubleStruckG]"}
197 | },
198 | Selectable->True],
199 | StyleBox[GridBox[{
200 | {"\[Lambda]", "\[Sigma]"},
201 | {"", ""}
202 | },
203 | GridBoxSpacings->{"Columns" -> {Offset[0.27999999999999997`], {Offset[0.]}, Offset[0.27999999999999997`]}, "ColumnsIndexed" -> {}, "Rows" -> {Offset[0.2], {Offset[0.]}, Offset[0.2]}, "RowsIndexed" -> {}},
204 | Selectable->True],
205 | FontSize->10]}
206 | },
207 | GridBoxSpacings->{"Columns" -> {Offset[0.27999999999999997`], {Offset[0.]}, Offset[0.27999999999999997`]}, "ColumnsIndexed" -> {}, "Rows" -> {Offset[0.2], {Offset[0.]}, Offset[0.2]}, "RowsIndexed" -> {}}],
208 | "GRETsr",
209 | Selectable->False]\ \((
210 | \*SubscriptBox[\(\[PartialD]\), \(\[Mu]\)]\*
211 | TagBox[GridBox[{
212 | {GridBox[{
213 | {"\[DoubleStruckG]"}
214 | },
215 | Selectable->True],
216 | StyleBox[GridBox[{
217 | {"", ""},
218 | {"\[Sigma]", "\[Nu]"}
219 | },
220 | GridBoxSpacings->{"Columns" -> {Offset[0.27999999999999997`], {Offset[0.]}, Offset[0.27999999999999997`]}, "ColumnsIndexed" -> {}, "Rows" -> {Offset[0.2], {Offset[0.]}, Offset[0.2]}, "RowsIndexed" -> {}},
221 | Selectable->True],
222 | FontSize->10]}
223 | },
224 | GridBoxSpacings->{"Columns" -> {Offset[0.27999999999999997`], {Offset[0.]}, Offset[0.27999999999999997`]}, "ColumnsIndexed" -> {}, "Rows" -> {Offset[0.2], {Offset[0.]}, Offset[0.2]}, "RowsIndexed" -> {}}],
225 | "GRETsr",
226 | Selectable->False]\ + \
227 | \*SubscriptBox[\(\[PartialD]\), \(\[Nu]\)]\*
228 | TagBox[GridBox[{
229 | {GridBox[{
230 | {"\[DoubleStruckG]"}
231 | },
232 | Selectable->True],
233 | StyleBox[GridBox[{
234 | {"", ""},
235 | {"\[Sigma]", "\[Mu]"}
236 | },
237 | GridBoxSpacings->{"Columns" -> {Offset[0.27999999999999997`], {Offset[0.]}, Offset[0.27999999999999997`]}, "ColumnsIndexed" -> {}, "Rows" -> {Offset[0.2], {Offset[0.]}, Offset[0.2]}, "RowsIndexed" -> {}},
238 | Selectable->True],
239 | FontSize->10]}
240 | },
241 | GridBoxSpacings->{"Columns" -> {Offset[0.27999999999999997`], {Offset[0.]}, Offset[0.27999999999999997`]}, "ColumnsIndexed" -> {}, "Rows" -> {Offset[0.2], {Offset[0.]}, Offset[0.2]}, "RowsIndexed" -> {}}],
242 | "GRETsr",
243 | Selectable->False]\ - \
244 | \*SubscriptBox[\(\[PartialD]\), \(\[Sigma]\)]\*
245 | TagBox[GridBox[{
246 | {GridBox[{
247 | {"\[DoubleStruckG]"}
248 | },
249 | Selectable->True],
250 | StyleBox[GridBox[{
251 | {"", ""},
252 | {"\[Mu]", "\[Nu]"}
253 | },
254 | GridBoxSpacings->{"Columns" -> {Offset[0.27999999999999997`], {Offset[0.]}, Offset[0.27999999999999997`]}, "ColumnsIndexed" -> {}, "Rows" -> {Offset[0.2], {Offset[0.]}, Offset[0.2]}, "RowsIndexed" -> {}},
255 | Selectable->True],
256 | FontSize->10]}
257 | },
258 | GridBoxSpacings->{"Columns" -> {Offset[0.27999999999999997`], {Offset[0.]}, Offset[0.27999999999999997`]}, "ColumnsIndexed" -> {}, "Rows" -> {Offset[0.2], {Offset[0.]}, Offset[0.2]}, "RowsIndexed" -> {}}],
259 | "GRETsr",
260 | Selectable->False])\)\)\)];
261 | \!\(\*
262 | TagBox[GridBox[{
263 | {GridBox[{
264 | {"\[DoubleStruckCapitalR]"}
265 | },
266 | Selectable->True],
267 | StyleBox[GridBox[{
268 | {"\[Lambda]_", "", "", ""},
269 | {"", "\[Mu]_", "\[Sigma]_", "\[Nu]_"}
270 | },
271 | GridBoxSpacings->{"Columns" -> {Offset[0.27999999999999997`], {Offset[0.]}, Offset[0.27999999999999997`]}, "ColumnsIndexed" -> {}, "Rows" -> {Offset[0.2], {Offset[0.]}, Offset[0.2]}, "RowsIndexed" -> {}},
272 | Selectable->True],
273 | FontSize->10]}
274 | },
275 | GridBoxSpacings->{"Columns" -> {Offset[0.27999999999999997`], {Offset[0.]}, Offset[0.27999999999999997`]}, "ColumnsIndexed" -> {}, "Rows" -> {Offset[0.2], {Offset[0.]}, Offset[0.2]}, "RowsIndexed" -> {}}],
276 | "GRETsr",
277 | Selectable->False]\):= \!\(\*
278 | TagBox[GridBox[{
279 | {GridBox[{
280 | {"\[DoubleStruckCapitalR]"}
281 | },
282 | Selectable->True],
283 | StyleBox[GridBox[{
284 | {"\[Lambda]", "", "", ""},
285 | {"", "\[Mu]", "\[Sigma]", "\[Nu]"}
286 | },
287 | GridBoxSpacings->{"Columns" -> {Offset[0.27999999999999997`], {Offset[0.]}, Offset[0.27999999999999997`]}, "ColumnsIndexed" -> {}, "Rows" -> {Offset[0.2], {Offset[0.]}, Offset[0.2]}, "RowsIndexed" -> {}},
288 | Selectable->True],
289 | FontSize->10]}
290 | },
291 | GridBoxSpacings->{"Columns" -> {Offset[0.27999999999999997`], {Offset[0.]}, Offset[0.27999999999999997`]}, "ColumnsIndexed" -> {}, "Rows" -> {Offset[0.2], {Offset[0.]}, Offset[0.2]}, "RowsIndexed" -> {}}],
292 | "GRETsr",
293 | Selectable->False]\) = -(\!\(\*
294 | TagBox[GridBox[{
295 | {GridBox[{
296 | {"\[DoubleStruckCapitalR]"}
297 | },
298 | Selectable->True],
299 | StyleBox[GridBox[{
300 | {"\[Lambda]", "", "", ""},
301 | {"", "\[Mu]", "\[Sigma]", "\[Nu]"}
302 | },
303 | GridBoxSpacings->{"Columns" -> {Offset[0.27999999999999997`], {Offset[0.]}, Offset[0.27999999999999997`]}, "ColumnsIndexed" -> {}, "Rows" -> {Offset[0.2], {Offset[0.]}, Offset[0.2]}, "RowsIndexed" -> {}},
304 | Selectable->True],
305 | FontSize->10]}
306 | },
307 | GridBoxSpacings->{"Columns" -> {Offset[0.27999999999999997`], {Offset[0.]}, Offset[0.27999999999999997`]}, "ColumnsIndexed" -> {}, "Rows" -> {Offset[0.2], {Offset[0.]}, Offset[0.2]}, "RowsIndexed" -> {}}],
308 | "GRETsr",
309 | Selectable->False]\) = R4Sign[SignConvention] * Simp[\!\(
310 | \*SubscriptBox[\(\[PartialD]\), \(\[Nu]\)]\*
311 | TagBox[GridBox[{
312 | {GridBox[{
313 | {"\[CapitalGamma]"}
314 | },
315 | Selectable->True],
316 | StyleBox[GridBox[{
317 | {"\[Lambda]", "", ""},
318 | {"", "\[Mu]", "\[Sigma]"}
319 | },
320 | GridBoxSpacings->{"Columns" -> {Offset[0.27999999999999997`], {Offset[0.]}, Offset[0.27999999999999997`]}, "ColumnsIndexed" -> {}, "Rows" -> {Offset[0.2], {Offset[0.]}, Offset[0.2]}, "RowsIndexed" -> {}},
321 | Selectable->True],
322 | FontSize->10]}
323 | },
324 | GridBoxSpacings->{"Columns" -> {Offset[0.27999999999999997`], {Offset[0.]}, Offset[0.27999999999999997`]}, "ColumnsIndexed" -> {}, "Rows" -> {Offset[0.2], {Offset[0.]}, Offset[0.2]}, "RowsIndexed" -> {}}],
325 | "GRETsr",
326 | Selectable->False]\) - \!\(
327 | \*SubscriptBox[\(\[PartialD]\), \(\[Sigma]\)]\*
328 | TagBox[GridBox[{
329 | {GridBox[{
330 | {"\[CapitalGamma]"}
331 | },
332 | Selectable->True],
333 | StyleBox[GridBox[{
334 | {"\[Lambda]", "", ""},
335 | {"", "\[Mu]", "\[Nu]"}
336 | },
337 | GridBoxSpacings->{"Columns" -> {Offset[0.27999999999999997`], {Offset[0.]}, Offset[0.27999999999999997`]}, "ColumnsIndexed" -> {}, "Rows" -> {Offset[0.2], {Offset[0.]}, Offset[0.2]}, "RowsIndexed" -> {}},
338 | Selectable->True],
339 | FontSize->10]}
340 | },
341 | GridBoxSpacings->{"Columns" -> {Offset[0.27999999999999997`], {Offset[0.]}, Offset[0.27999999999999997`]}, "ColumnsIndexed" -> {}, "Rows" -> {Offset[0.2], {Offset[0.]}, Offset[0.2]}, "RowsIndexed" -> {}}],
342 | "GRETsr",
343 | Selectable->False]\) + \!\(
344 | \*UnderoverscriptBox[\(\[Sum]\), \(\[Eta]\), \(\[DoubleStruckX]\)]\ \((\*
345 | TagBox[GridBox[{
346 | {GridBox[{
347 | {"\[CapitalGamma]"}
348 | },
349 | Selectable->True],
350 | StyleBox[GridBox[{
351 | {"\[Eta]", "", ""},
352 | {"", "\[Mu]", "\[Sigma]"}
353 | },
354 | GridBoxSpacings->{"Columns" -> {Offset[0.27999999999999997`], {Offset[0.]}, Offset[0.27999999999999997`]}, "ColumnsIndexed" -> {}, "Rows" -> {Offset[0.2], {Offset[0.]}, Offset[0.2]}, "RowsIndexed" -> {}},
355 | Selectable->True],
356 | FontSize->10]}
357 | },
358 | GridBoxSpacings->{"Columns" -> {Offset[0.27999999999999997`], {Offset[0.]}, Offset[0.27999999999999997`]}, "ColumnsIndexed" -> {}, "Rows" -> {Offset[0.2], {Offset[0.]}, Offset[0.2]}, "RowsIndexed" -> {}}],
359 | "GRETsr",
360 | Selectable->False] \*
361 | TagBox[GridBox[{
362 | {GridBox[{
363 | {"\[CapitalGamma]"}
364 | },
365 | Selectable->True],
366 | StyleBox[GridBox[{
367 | {"\[Lambda]", "", ""},
368 | {"", "\[Eta]", "\[Nu]"}
369 | },
370 | GridBoxSpacings->{"Columns" -> {Offset[0.27999999999999997`], {Offset[0.]}, Offset[0.27999999999999997`]}, "ColumnsIndexed" -> {}, "Rows" -> {Offset[0.2], {Offset[0.]}, Offset[0.2]}, "RowsIndexed" -> {}},
371 | Selectable->True],
372 | FontSize->10]}
373 | },
374 | GridBoxSpacings->{"Columns" -> {Offset[0.27999999999999997`], {Offset[0.]}, Offset[0.27999999999999997`]}, "ColumnsIndexed" -> {}, "Rows" -> {Offset[0.2], {Offset[0.]}, Offset[0.2]}, "RowsIndexed" -> {}}],
375 | "GRETsr",
376 | Selectable->False]\ - \ \*
377 | TagBox[GridBox[{
378 | {GridBox[{
379 | {"\[CapitalGamma]"}
380 | },
381 | Selectable->True],
382 | StyleBox[GridBox[{
383 | {"\[Eta]", "", ""},
384 | {"", "\[Mu]", "\[Nu]"}
385 | },
386 | GridBoxSpacings->{"Columns" -> {Offset[0.27999999999999997`], {Offset[0.]}, Offset[0.27999999999999997`]}, "ColumnsIndexed" -> {}, "Rows" -> {Offset[0.2], {Offset[0.]}, Offset[0.2]}, "RowsIndexed" -> {}},
387 | Selectable->True],
388 | FontSize->10]}
389 | },
390 | GridBoxSpacings->{"Columns" -> {Offset[0.27999999999999997`], {Offset[0.]}, Offset[0.27999999999999997`]}, "ColumnsIndexed" -> {}, "Rows" -> {Offset[0.2], {Offset[0.]}, Offset[0.2]}, "RowsIndexed" -> {}}],
391 | "GRETsr",
392 | Selectable->False] \*
393 | TagBox[GridBox[{
394 | {GridBox[{
395 | {"\[CapitalGamma]"}
396 | },
397 | Selectable->True],
398 | StyleBox[GridBox[{
399 | {"\[Lambda]", "", ""},
400 | {"", "\[Eta]", "\[Sigma]"}
401 | },
402 | GridBoxSpacings->{"Columns" -> {Offset[0.27999999999999997`], {Offset[0.]}, Offset[0.27999999999999997`]}, "ColumnsIndexed" -> {}, "Rows" -> {Offset[0.2], {Offset[0.]}, Offset[0.2]}, "RowsIndexed" -> {}},
403 | Selectable->True],
404 | FontSize->10]}
405 | },
406 | GridBoxSpacings->{"Columns" -> {Offset[0.27999999999999997`], {Offset[0.]}, Offset[0.27999999999999997`]}, "ColumnsIndexed" -> {}, "Rows" -> {Offset[0.2], {Offset[0.]}, Offset[0.2]}, "RowsIndexed" -> {}}],
407 | "GRETsr",
408 | Selectable->False])\)\)]);
409 | \!\(\*
410 | TagBox[GridBox[{
411 | {GridBox[{
412 | {"\[DoubleStruckCapitalR]"}
413 | },
414 | Selectable->True],
415 | StyleBox[GridBox[{
416 | {"", "", "", ""},
417 | {"\[Rho]_", "\[Mu]_", "\[Sigma]_", "\[Nu]_"}
418 | },
419 | GridBoxSpacings->{"Columns" -> {Offset[0.27999999999999997`], {Offset[0.]}, Offset[0.27999999999999997`]}, "ColumnsIndexed" -> {}, "Rows" -> {Offset[0.2], {Offset[0.]}, Offset[0.2]}, "RowsIndexed" -> {}},
420 | Selectable->True],
421 | FontSize->10]}
422 | },
423 | GridBoxSpacings->{"Columns" -> {Offset[0.27999999999999997`], {Offset[0.]}, Offset[0.27999999999999997`]}, "ColumnsIndexed" -> {}, "Rows" -> {Offset[0.2], {Offset[0.]}, Offset[0.2]}, "RowsIndexed" -> {}}],
424 | "GRETsr",
425 | Selectable->False]\):= \!\(\*
426 | TagBox[GridBox[{
427 | {GridBox[{
428 | {"\[DoubleStruckCapitalR]"}
429 | },
430 | Selectable->True],
431 | StyleBox[GridBox[{
432 | {"", "", "", ""},
433 | {"\[Rho]", "\[Mu]", "\[Sigma]", "\[Nu]"}
434 | },
435 | GridBoxSpacings->{"Columns" -> {Offset[0.27999999999999997`], {Offset[0.]}, Offset[0.27999999999999997`]}, "ColumnsIndexed" -> {}, "Rows" -> {Offset[0.2], {Offset[0.]}, Offset[0.2]}, "RowsIndexed" -> {}},
436 | Selectable->True],
437 | FontSize->10]}
438 | },
439 | GridBoxSpacings->{"Columns" -> {Offset[0.27999999999999997`], {Offset[0.]}, Offset[0.27999999999999997`]}, "ColumnsIndexed" -> {}, "Rows" -> {Offset[0.2], {Offset[0.]}, Offset[0.2]}, "RowsIndexed" -> {}}],
440 | "GRETsr",
441 | Selectable->False]\) = -(\!\(\*
442 | TagBox[GridBox[{
443 | {GridBox[{
444 | {"\[DoubleStruckCapitalR]"}
445 | },
446 | Selectable->True],
447 | StyleBox[GridBox[{
448 | {"", "", "", ""},
449 | {"\[Rho]", "\[Mu]", "\[Nu]", "\[Sigma]"}
450 | },
451 | GridBoxSpacings->{"Columns" -> {Offset[0.27999999999999997`], {Offset[0.]}, Offset[0.27999999999999997`]}, "ColumnsIndexed" -> {}, "Rows" -> {Offset[0.2], {Offset[0.]}, Offset[0.2]}, "RowsIndexed" -> {}},
452 | Selectable->True],
453 | FontSize->10]}
454 | },
455 | GridBoxSpacings->{"Columns" -> {Offset[0.27999999999999997`], {Offset[0.]}, Offset[0.27999999999999997`]}, "ColumnsIndexed" -> {}, "Rows" -> {Offset[0.2], {Offset[0.]}, Offset[0.2]}, "RowsIndexed" -> {}}],
456 | "GRETsr",
457 | Selectable->False]\) = Simp[\!\(
458 | \*UnderoverscriptBox[\(\[Sum]\), \(\[Lambda]\), \(\[DoubleStruckX]\)]\ \(\*
459 | TagBox[GridBox[{
460 | {GridBox[{
461 | {"\[DoubleStruckG]"}
462 | },
463 | Selectable->True],
464 | StyleBox[GridBox[{
465 | {"", ""},
466 | {"\[Rho]", "\[Lambda]"}
467 | },
468 | GridBoxSpacings->{"Columns" -> {Offset[0.27999999999999997`], {Offset[0.]}, Offset[0.27999999999999997`]}, "ColumnsIndexed" -> {}, "Rows" -> {Offset[0.2], {Offset[0.]}, Offset[0.2]}, "RowsIndexed" -> {}},
469 | Selectable->True],
470 | FontSize->10]}
471 | },
472 | GridBoxSpacings->{"Columns" -> {Offset[0.27999999999999997`], {Offset[0.]}, Offset[0.27999999999999997`]}, "ColumnsIndexed" -> {}, "Rows" -> {Offset[0.2], {Offset[0.]}, Offset[0.2]}, "RowsIndexed" -> {}}],
473 | "GRETsr",
474 | Selectable->False] \*
475 | TagBox[GridBox[{
476 | {GridBox[{
477 | {"\[DoubleStruckCapitalR]"}
478 | },
479 | Selectable->True],
480 | StyleBox[GridBox[{
481 | {"\[Lambda]", "", "", ""},
482 | {"", "\[Mu]", "\[Nu]", "\[Sigma]"}
483 | },
484 | GridBoxSpacings->{"Columns" -> {Offset[0.27999999999999997`], {Offset[0.]}, Offset[0.27999999999999997`]}, "ColumnsIndexed" -> {}, "Rows" -> {Offset[0.2], {Offset[0.]}, Offset[0.2]}, "RowsIndexed" -> {}},
485 | Selectable->True],
486 | FontSize->10]}
487 | },
488 | GridBoxSpacings->{"Columns" -> {Offset[0.27999999999999997`], {Offset[0.]}, Offset[0.27999999999999997`]}, "ColumnsIndexed" -> {}, "Rows" -> {Offset[0.2], {Offset[0.]}, Offset[0.2]}, "RowsIndexed" -> {}}],
489 | "GRETsr",
490 | Selectable->False]\)\)]);
491 | \!\(\*
492 | TagBox[GridBox[{
493 | {GridBox[{
494 | {"\[DoubleStruckCapitalR]"}
495 | },
496 | Selectable->True],
497 | StyleBox[GridBox[{
498 | {"", ""},
499 | {"\[Mu]_", "\[Nu]_"}
500 | },
501 | GridBoxSpacings->{"Columns" -> {Offset[0.27999999999999997`], {Offset[0.]}, Offset[0.27999999999999997`]}, "ColumnsIndexed" -> {}, "Rows" -> {Offset[0.2], {Offset[0.]}, Offset[0.2]}, "RowsIndexed" -> {}},
502 | Selectable->True],
503 | FontSize->10]}
504 | },
505 | GridBoxSpacings->{"Columns" -> {Offset[0.27999999999999997`], {Offset[0.]}, Offset[0.27999999999999997`]}, "ColumnsIndexed" -> {}, "Rows" -> {Offset[0.2], {Offset[0.]}, Offset[0.2]}, "RowsIndexed" -> {}}],
506 | "GRETsr",
507 | Selectable->False]\):= \!\(\*
508 | TagBox[GridBox[{
509 | {GridBox[{
510 | {"\[DoubleStruckCapitalR]"}
511 | },
512 | Selectable->True],
513 | StyleBox[GridBox[{
514 | {"", ""},
515 | {"\[Mu]", "\[Nu]"}
516 | },
517 | GridBoxSpacings->{"Columns" -> {Offset[0.27999999999999997`], {Offset[0.]}, Offset[0.27999999999999997`]}, "ColumnsIndexed" -> {}, "Rows" -> {Offset[0.2], {Offset[0.]}, Offset[0.2]}, "RowsIndexed" -> {}},
518 | Selectable->True],
519 | FontSize->10]}
520 | },
521 | GridBoxSpacings->{"Columns" -> {Offset[0.27999999999999997`], {Offset[0.]}, Offset[0.27999999999999997`]}, "ColumnsIndexed" -> {}, "Rows" -> {Offset[0.2], {Offset[0.]}, Offset[0.2]}, "RowsIndexed" -> {}}],
522 | "GRETsr",
523 | Selectable->False]\) = \!\(\*
524 | TagBox[GridBox[{
525 | {GridBox[{
526 | {"\[DoubleStruckCapitalR]"}
527 | },
528 | Selectable->True],
529 | StyleBox[GridBox[{
530 | {"", ""},
531 | {"\[Nu]", "\[Mu]"}
532 | },
533 | GridBoxSpacings->{"Columns" -> {Offset[0.27999999999999997`], {Offset[0.]}, Offset[0.27999999999999997`]}, "ColumnsIndexed" -> {}, "Rows" -> {Offset[0.2], {Offset[0.]}, Offset[0.2]}, "RowsIndexed" -> {}},
534 | Selectable->True],
535 | FontSize->10]}
536 | },
537 | GridBoxSpacings->{"Columns" -> {Offset[0.27999999999999997`], {Offset[0.]}, Offset[0.27999999999999997`]}, "ColumnsIndexed" -> {}, "Rows" -> {Offset[0.2], {Offset[0.]}, Offset[0.2]}, "RowsIndexed" -> {}}],
538 | "GRETsr",
539 | Selectable->False]\) = Simp[\!\(
540 | \*UnderoverscriptBox[\(\[Sum]\), \(\[Lambda]\), \(\[DoubleStruckX]\)]\*
541 | TagBox[GridBox[{
542 | {GridBox[{
543 | {
544 | RowBox[{" ", "\[DoubleStruckCapitalR]"}]}
545 | },
546 | Selectable->True],
547 | StyleBox[GridBox[{
548 | {"\[Lambda]", "", "", ""},
549 | {"", "\[Mu]", "\[Lambda]", "\[Nu]"}
550 | },
551 | GridBoxSpacings->{"Columns" -> {Offset[0.27999999999999997`], {Offset[0.]}, Offset[0.27999999999999997`]}, "ColumnsIndexed" -> {}, "Rows" -> {Offset[0.2], {Offset[0.]}, Offset[0.2]}, "RowsIndexed" -> {}},
552 | Selectable->True],
553 | FontSize->10]}
554 | },
555 | GridBoxSpacings->{"Columns" -> {Offset[0.27999999999999997`], {Offset[0.]}, Offset[0.27999999999999997`]}, "ColumnsIndexed" -> {}, "Rows" -> {Offset[0.2], {Offset[0.]}, Offset[0.2]}, "RowsIndexed" -> {}}],
556 | "GRETsr",
557 | Selectable->False]\)];
558 | \[DoubleStruckCapitalR][]:= Simp @ Sum[\!\(\*
559 | TagBox[GridBox[{
560 | {GridBox[{
561 | {"\[DoubleStruckG]"}
562 | },
563 | Selectable->True],
564 | StyleBox[GridBox[{
565 | {"\[Mu]", "\[Nu]"},
566 | {"", ""}
567 | },
568 | GridBoxSpacings->{"Columns" -> {Offset[0.27999999999999997`], {Offset[0.]}, Offset[0.27999999999999997`]}, "ColumnsIndexed" -> {}, "Rows" -> {Offset[0.2], {Offset[0.]}, Offset[0.2]}, "RowsIndexed" -> {}},
569 | Selectable->True],
570 | FontSize->10]}
571 | },
572 | GridBoxSpacings->{"Columns" -> {Offset[0.27999999999999997`], {Offset[0.]}, Offset[0.27999999999999997`]}, "ColumnsIndexed" -> {}, "Rows" -> {Offset[0.2], {Offset[0.]}, Offset[0.2]}, "RowsIndexed" -> {}}],
573 | "GRETsr",
574 | Selectable->False]\) \!\(\*
575 | TagBox[GridBox[{
576 | {GridBox[{
577 | {"\[DoubleStruckCapitalR]"}
578 | },
579 | Selectable->True],
580 | StyleBox[GridBox[{
581 | {"", ""},
582 | {"\[Mu]", "\[Nu]"}
583 | },
584 | GridBoxSpacings->{"Columns" -> {Offset[0.27999999999999997`], {Offset[0.]}, Offset[0.27999999999999997`]}, "ColumnsIndexed" -> {}, "Rows" -> {Offset[0.2], {Offset[0.]}, Offset[0.2]}, "RowsIndexed" -> {}},
585 | Selectable->True],
586 | FontSize->10]}
587 | },
588 | GridBoxSpacings->{"Columns" -> {Offset[0.27999999999999997`], {Offset[0.]}, Offset[0.27999999999999997`]}, "ColumnsIndexed" -> {}, "Rows" -> {Offset[0.2], {Offset[0.]}, Offset[0.2]}, "RowsIndexed" -> {}}],
589 | "GRETsr",
590 | Selectable->False]\), {\[Mu],\[DoubleStruckX]}, {\[Nu],\[DoubleStruckX]}];
591 | \!\(\*
592 | TagBox[GridBox[{
593 | {GridBox[{
594 | {"\[DoubleStruckCapitalG]"}
595 | },
596 | Selectable->True],
597 | StyleBox[GridBox[{
598 | {"", ""},
599 | {"\[Mu]_", "\[Nu]_"}
600 | },
601 | GridBoxSpacings->{"Columns" -> {Offset[0.27999999999999997`], {Offset[0.]}, Offset[0.27999999999999997`]}, "ColumnsIndexed" -> {}, "Rows" -> {Offset[0.2], {Offset[0.]}, Offset[0.2]}, "RowsIndexed" -> {}},
602 | Selectable->True],
603 | FontSize->10]}
604 | },
605 | GridBoxSpacings->{"Columns" -> {Offset[0.27999999999999997`], {Offset[0.]}, Offset[0.27999999999999997`]}, "ColumnsIndexed" -> {}, "Rows" -> {Offset[0.2], {Offset[0.]}, Offset[0.2]}, "RowsIndexed" -> {}}],
606 | "GRETsr",
607 | Selectable->False]\):= \!\(\*
608 | TagBox[GridBox[{
609 | {GridBox[{
610 | {"\[DoubleStruckCapitalG]"}
611 | },
612 | Selectable->True],
613 | StyleBox[GridBox[{
614 | {"", ""},
615 | {"\[Mu]", "\[Nu]"}
616 | },
617 | GridBoxSpacings->{"Columns" -> {Offset[0.27999999999999997`], {Offset[0.]}, Offset[0.27999999999999997`]}, "ColumnsIndexed" -> {}, "Rows" -> {Offset[0.2], {Offset[0.]}, Offset[0.2]}, "RowsIndexed" -> {}},
618 | Selectable->True],
619 | FontSize->10]}
620 | },
621 | GridBoxSpacings->{"Columns" -> {Offset[0.27999999999999997`], {Offset[0.]}, Offset[0.27999999999999997`]}, "ColumnsIndexed" -> {}, "Rows" -> {Offset[0.2], {Offset[0.]}, Offset[0.2]}, "RowsIndexed" -> {}}],
622 | "GRETsr",
623 | Selectable->False]\) = \!\(\*
624 | TagBox[GridBox[{
625 | {GridBox[{
626 | {"\[DoubleStruckCapitalR]"}
627 | },
628 | Selectable->True],
629 | StyleBox[GridBox[{
630 | {"", ""},
631 | {"\[Mu]", "\[Nu]"}
632 | },
633 | GridBoxSpacings->{"Columns" -> {Offset[0.27999999999999997`], {Offset[0.]}, Offset[0.27999999999999997`]}, "ColumnsIndexed" -> {}, "Rows" -> {Offset[0.2], {Offset[0.]}, Offset[0.2]}, "RowsIndexed" -> {}},
634 | Selectable->True],
635 | FontSize->10]}
636 | },
637 | GridBoxSpacings->{"Columns" -> {Offset[0.27999999999999997`], {Offset[0.]}, Offset[0.27999999999999997`]}, "ColumnsIndexed" -> {}, "Rows" -> {Offset[0.2], {Offset[0.]}, Offset[0.2]}, "RowsIndexed" -> {}}],
638 | "GRETsr",
639 | Selectable->False]\) - 1/2 \!\(\*
640 | TagBox[GridBox[{
641 | {GridBox[{
642 | {
643 | RowBox[{" ", "\[DoubleStruckG]"}]}
644 | },
645 | Selectable->True],
646 | StyleBox[GridBox[{
647 | {"", ""},
648 | {"\[Mu]", "\[Nu]"}
649 | },
650 | GridBoxSpacings->{"Columns" -> {Offset[0.27999999999999997`], {Offset[0.]}, Offset[0.27999999999999997`]}, "ColumnsIndexed" -> {}, "Rows" -> {Offset[0.2], {Offset[0.]}, Offset[0.2]}, "RowsIndexed" -> {}},
651 | Selectable->True],
652 | FontSize->10]}
653 | },
654 | GridBoxSpacings->{"Columns" -> {Offset[0.27999999999999997`], {Offset[0.]}, Offset[0.27999999999999997`]}, "ColumnsIndexed" -> {}, "Rows" -> {Offset[0.2], {Offset[0.]}, Offset[0.2]}, "RowsIndexed" -> {}}],
655 | "GRETsr",
656 | Selectable->False]\) \[DoubleStruckCapitalR][] // Simp;
657 | \!\(\*
658 | TagBox[GridBox[{
659 | {GridBox[{
660 | {"\[DoubleStruckCapitalG]"}
661 | },
662 | Selectable->True],
663 | StyleBox[GridBox[{
664 | {"\[Lambda]_", ""},
665 | {"", "\[Nu]_"}
666 | },
667 | GridBoxSpacings->{"Columns" -> {Offset[0.27999999999999997`], {Offset[0.]}, Offset[0.27999999999999997`]}, "ColumnsIndexed" -> {}, "Rows" -> {Offset[0.2], {Offset[0.]}, Offset[0.2]}, "RowsIndexed" -> {}},
668 | Selectable->True],
669 | FontSize->10]}
670 | },
671 | GridBoxSpacings->{"Columns" -> {Offset[0.27999999999999997`], {Offset[0.]}, Offset[0.27999999999999997`]}, "ColumnsIndexed" -> {}, "Rows" -> {Offset[0.2], {Offset[0.]}, Offset[0.2]}, "RowsIndexed" -> {}}],
672 | "GRETsr",
673 | Selectable->False]\):= \!\(\*
674 | TagBox[GridBox[{
675 | {GridBox[{
676 | {"\[DoubleStruckCapitalG]"}
677 | },
678 | Selectable->True],
679 | StyleBox[GridBox[{
680 | {"\[Lambda]", ""},
681 | {"", "\[Nu]"}
682 | },
683 | GridBoxSpacings->{"Columns" -> {Offset[0.27999999999999997`], {Offset[0.]}, Offset[0.27999999999999997`]}, "ColumnsIndexed" -> {}, "Rows" -> {Offset[0.2], {Offset[0.]}, Offset[0.2]}, "RowsIndexed" -> {}},
684 | Selectable->True],
685 | FontSize->10]}
686 | },
687 | GridBoxSpacings->{"Columns" -> {Offset[0.27999999999999997`], {Offset[0.]}, Offset[0.27999999999999997`]}, "ColumnsIndexed" -> {}, "Rows" -> {Offset[0.2], {Offset[0.]}, Offset[0.2]}, "RowsIndexed" -> {}}],
688 | "GRETsr",
689 | Selectable->False]\) = Simp[\!\(
690 | \*UnderoverscriptBox[\(\[Sum]\), \(\[Mu]\), \(\[DoubleStruckX]\)]\ \(\*
691 | TagBox[GridBox[{
692 | {GridBox[{
693 | {"\[DoubleStruckG]"}
694 | },
695 | Selectable->True],
696 | StyleBox[GridBox[{
697 | {"\[Lambda]", "\[Mu]"},
698 | {"", ""}
699 | },
700 | GridBoxSpacings->{"Columns" -> {Offset[0.27999999999999997`], {Offset[0.]}, Offset[0.27999999999999997`]}, "ColumnsIndexed" -> {}, "Rows" -> {Offset[0.2], {Offset[0.]}, Offset[0.2]}, "RowsIndexed" -> {}},
701 | Selectable->True],
702 | FontSize->10]}
703 | },
704 | GridBoxSpacings->{"Columns" -> {Offset[0.27999999999999997`], {Offset[0.]}, Offset[0.27999999999999997`]}, "ColumnsIndexed" -> {}, "Rows" -> {Offset[0.2], {Offset[0.]}, Offset[0.2]}, "RowsIndexed" -> {}}],
705 | "GRETsr",
706 | Selectable->False]\ \*
707 | TagBox[GridBox[{
708 | {GridBox[{
709 | {"\[DoubleStruckCapitalG]"}
710 | },
711 | Selectable->True],
712 | StyleBox[GridBox[{
713 | {"", ""},
714 | {"\[Mu]", "\[Nu]"}
715 | },
716 | GridBoxSpacings->{"Columns" -> {Offset[0.27999999999999997`], {Offset[0.]}, Offset[0.27999999999999997`]}, "ColumnsIndexed" -> {}, "Rows" -> {Offset[0.2], {Offset[0.]}, Offset[0.2]}, "RowsIndexed" -> {}},
717 | Selectable->True],
718 | FontSize->10]}
719 | },
720 | GridBoxSpacings->{"Columns" -> {Offset[0.27999999999999997`], {Offset[0.]}, Offset[0.27999999999999997`]}, "ColumnsIndexed" -> {}, "Rows" -> {Offset[0.2], {Offset[0.]}, Offset[0.2]}, "RowsIndexed" -> {}}],
721 | "GRETsr",
722 | Selectable->False]\)\)];
723 | \!\(\*
724 | TagBox[GridBox[{
725 | {GridBox[{
726 | {"\[DoubleStruckCapitalG]"}
727 | },
728 | Selectable->True],
729 | StyleBox[GridBox[{
730 | {"\[Lambda]_", "\[Nu]_"},
731 | {"", ""}
732 | },
733 | GridBoxSpacings->{"Columns" -> {Offset[0.27999999999999997`], {Offset[0.]}, Offset[0.27999999999999997`]}, "ColumnsIndexed" -> {}, "Rows" -> {Offset[0.2], {Offset[0.]}, Offset[0.2]}, "RowsIndexed" -> {}},
734 | Selectable->True],
735 | FontSize->10]}
736 | },
737 | GridBoxSpacings->{"Columns" -> {Offset[0.27999999999999997`], {Offset[0.]}, Offset[0.27999999999999997`]}, "ColumnsIndexed" -> {}, "Rows" -> {Offset[0.2], {Offset[0.]}, Offset[0.2]}, "RowsIndexed" -> {}}],
738 | "GRETsr",
739 | Selectable->False]\):=\!\(\*
740 | TagBox[GridBox[{
741 | {GridBox[{
742 | {
743 | RowBox[{" ", "\[DoubleStruckCapitalG]"}]}
744 | },
745 | Selectable->True],
746 | StyleBox[GridBox[{
747 | {"\[Lambda]", "\[Nu]"},
748 | {"", ""}
749 | },
750 | GridBoxSpacings->{"Columns" -> {Offset[0.27999999999999997`], {Offset[0.]}, Offset[0.27999999999999997`]}, "ColumnsIndexed" -> {}, "Rows" -> {Offset[0.2], {Offset[0.]}, Offset[0.2]}, "RowsIndexed" -> {}},
751 | Selectable->True],
752 | FontSize->10]}
753 | },
754 | GridBoxSpacings->{"Columns" -> {Offset[0.27999999999999997`], {Offset[0.]}, Offset[0.27999999999999997`]}, "ColumnsIndexed" -> {}, "Rows" -> {Offset[0.2], {Offset[0.]}, Offset[0.2]}, "RowsIndexed" -> {}}],
755 | "GRETsr",
756 | Selectable->False]\) = Simp[\!\(
757 | \*UnderoverscriptBox[\(\[Sum]\), \(\[Mu]\), \(\[DoubleStruckX]\)]\ \(\*
758 | TagBox[GridBox[{
759 | {GridBox[{
760 | {"\[DoubleStruckG]"}
761 | },
762 | Selectable->True],
763 | StyleBox[GridBox[{
764 | {"\[Nu]", "\[Mu]"},
765 | {"", ""}
766 | },
767 | GridBoxSpacings->{"Columns" -> {Offset[0.27999999999999997`], {Offset[0.]}, Offset[0.27999999999999997`]}, "ColumnsIndexed" -> {}, "Rows" -> {Offset[0.2], {Offset[0.]}, Offset[0.2]}, "RowsIndexed" -> {}},
768 | Selectable->True],
769 | FontSize->10]}
770 | },
771 | GridBoxSpacings->{"Columns" -> {Offset[0.27999999999999997`], {Offset[0.]}, Offset[0.27999999999999997`]}, "ColumnsIndexed" -> {}, "Rows" -> {Offset[0.2], {Offset[0.]}, Offset[0.2]}, "RowsIndexed" -> {}}],
772 | "GRETsr",
773 | Selectable->False]\ \*
774 | TagBox[GridBox[{
775 | {GridBox[{
776 | {"\[DoubleStruckCapitalG]"}
777 | },
778 | Selectable->True],
779 | StyleBox[GridBox[{
780 | {"\[Lambda]", ""},
781 | {"", "\[Mu]"}
782 | },
783 | GridBoxSpacings->{"Columns" -> {Offset[0.27999999999999997`], {Offset[0.]}, Offset[0.27999999999999997`]}, "ColumnsIndexed" -> {}, "Rows" -> {Offset[0.2], {Offset[0.]}, Offset[0.2]}, "RowsIndexed" -> {}},
784 | Selectable->True],
785 | FontSize->10]}
786 | },
787 | GridBoxSpacings->{"Columns" -> {Offset[0.27999999999999997`], {Offset[0.]}, Offset[0.27999999999999997`]}, "ColumnsIndexed" -> {}, "Rows" -> {Offset[0.2], {Offset[0.]}, Offset[0.2]}, "RowsIndexed" -> {}}],
788 | "GRETsr",
789 | Selectable->False]\)\)];
790 | \[DoubleStruckCapitalX][\[Phi]_]:= (Col=Col~Union~{\[Phi],Derivative[__][\[Phi][[0]]][Sequence@@\[Phi]]}; -Sum[\!\(\*
791 | TagBox[GridBox[{
792 | {GridBox[{
793 | {"\[DoubleStruckG]"}
794 | },
795 | Selectable->True],
796 | StyleBox[GridBox[{
797 | {"\[Mu]", "\[Nu]"},
798 | {"", ""}
799 | },
800 | GridBoxSpacings->{"Columns" -> {Offset[0.27999999999999997`], {Offset[0.]}, Offset[0.27999999999999997`]}, "ColumnsIndexed" -> {}, "Rows" -> {Offset[0.2], {Offset[0.]}, Offset[0.2]}, "RowsIndexed" -> {}},
801 | Selectable->True],
802 | FontSize->10]}
803 | },
804 | GridBoxSpacings->{"Columns" -> {Offset[0.27999999999999997`], {Offset[0.]}, Offset[0.27999999999999997`]}, "ColumnsIndexed" -> {}, "Rows" -> {Offset[0.2], {Offset[0.]}, Offset[0.2]}, "RowsIndexed" -> {}}],
805 | "GRETsr",
806 | Selectable->False]\) \!\(
807 | \*SubscriptBox[\(\[PartialD]\), \(\[Mu]\)]\[Phi]\) \!\(
808 | \*SubscriptBox[\(\[PartialD]\), \(\[Nu]\)]\[Phi]\),{\[Mu],\[DoubleStruckX]},{\[Nu],\[DoubleStruckX]}]/2//Simp);
809 | \!\(\*
810 | TagBox[GridBox[{
811 | {GridBox[{
812 | {
813 | RowBox[{"\[DoubleStruckCapitalT]", "[", "\[Phi]_", "]"}]}
814 | },
815 | Selectable->True],
816 | StyleBox[GridBox[{
817 | {"", ""},
818 | {"\[Mu]_", "\[Nu]_"}
819 | },
820 | GridBoxSpacings->{"Columns" -> {Offset[0.27999999999999997`], {Offset[0.]}, Offset[0.27999999999999997`]}, "ColumnsIndexed" -> {}, "Rows" -> {Offset[0.2], {Offset[0.]}, Offset[0.2]}, "RowsIndexed" -> {}},
821 | Selectable->True],
822 | FontSize->10]}
823 | },
824 | GridBoxSpacings->{"Columns" -> {Offset[0.27999999999999997`], {Offset[0.]}, Offset[0.27999999999999997`]}, "ColumnsIndexed" -> {}, "Rows" -> {Offset[0.2], {Offset[0.]}, Offset[0.2]}, "RowsIndexed" -> {}}],
825 | "GRETsr",
826 | Selectable->False]\):=\!\(\*
827 | TagBox[GridBox[{
828 | {GridBox[{
829 | {
830 | RowBox[{"\[DoubleStruckCapitalT]", "[", "\[Phi]", "]"}]}
831 | },
832 | Selectable->True],
833 | StyleBox[GridBox[{
834 | {"", ""},
835 | {"\[Mu]", "\[Nu]"}
836 | },
837 | GridBoxSpacings->{"Columns" -> {Offset[0.27999999999999997`], {Offset[0.]}, Offset[0.27999999999999997`]}, "ColumnsIndexed" -> {}, "Rows" -> {Offset[0.2], {Offset[0.]}, Offset[0.2]}, "RowsIndexed" -> {}},
838 | Selectable->True],
839 | FontSize->10]}
840 | },
841 | GridBoxSpacings->{"Columns" -> {Offset[0.27999999999999997`], {Offset[0.]}, Offset[0.27999999999999997`]}, "ColumnsIndexed" -> {}, "Rows" -> {Offset[0.2], {Offset[0.]}, Offset[0.2]}, "RowsIndexed" -> {}}],
842 | "GRETsr",
843 | Selectable->False]\)= -\!\(\*
844 | TagBox[GridBox[{
845 | {GridBox[{
846 | {"\[DoubleStruckG]"}
847 | },
848 | Selectable->True],
849 | StyleBox[GridBox[{
850 | {"", ""},
851 | {"\[Mu]", "\[Nu]"}
852 | },
853 | GridBoxSpacings->{"Columns" -> {Offset[0.27999999999999997`], {Offset[0.]}, Offset[0.27999999999999997`]}, "ColumnsIndexed" -> {}, "Rows" -> {Offset[0.2], {Offset[0.]}, Offset[0.2]}, "RowsIndexed" -> {}},
854 | Selectable->True],
855 | FontSize->10]}
856 | },
857 | GridBoxSpacings->{"Columns" -> {Offset[0.27999999999999997`], {Offset[0.]}, Offset[0.27999999999999997`]}, "ColumnsIndexed" -> {}, "Rows" -> {Offset[0.2], {Offset[0.]}, Offset[0.2]}, "RowsIndexed" -> {}}],
858 | "GRETsr",
859 | Selectable->False]\)Sum[\!\(\*
860 | TagBox[GridBox[{
861 | {GridBox[{
862 | {"\[DoubleStruckG]"}
863 | },
864 | Selectable->True],
865 | StyleBox[GridBox[{
866 | {"\[Alpha]", "\[Beta]"},
867 | {"", ""}
868 | },
869 | GridBoxSpacings->{"Columns" -> {Offset[0.27999999999999997`], {Offset[0.]}, Offset[0.27999999999999997`]}, "ColumnsIndexed" -> {}, "Rows" -> {Offset[0.2], {Offset[0.]}, Offset[0.2]}, "RowsIndexed" -> {}},
870 | Selectable->True],
871 | FontSize->10]}
872 | },
873 | GridBoxSpacings->{"Columns" -> {Offset[0.27999999999999997`], {Offset[0.]}, Offset[0.27999999999999997`]}, "ColumnsIndexed" -> {}, "Rows" -> {Offset[0.2], {Offset[0.]}, Offset[0.2]}, "RowsIndexed" -> {}}],
874 | "GRETsr",
875 | Selectable->False]\)\!\(
876 | \*SubscriptBox[\(\[PartialD]\), \(\[Alpha]\)]\[Phi]\) \!\(
877 | \*SubscriptBox[\(\[PartialD]\), \(\[Beta]\)]\[Phi]\),{\[Alpha],\[DoubleStruckX]},{\[Beta],\[DoubleStruckX]}]/2 - \!\(\*
878 | TagBox[GridBox[{
879 | {GridBox[{
880 | {"\[DoubleStruckG]"}
881 | },
882 | Selectable->True],
883 | StyleBox[GridBox[{
884 | {"", ""},
885 | {"\[Mu]", "\[Nu]"}
886 | },
887 | GridBoxSpacings->{"Columns" -> {Offset[0.27999999999999997`], {Offset[0.]}, Offset[0.27999999999999997`]}, "ColumnsIndexed" -> {}, "Rows" -> {Offset[0.2], {Offset[0.]}, Offset[0.2]}, "RowsIndexed" -> {}},
888 | Selectable->True],
889 | FontSize->10]}
890 | },
891 | GridBoxSpacings->{"Columns" -> {Offset[0.27999999999999997`], {Offset[0.]}, Offset[0.27999999999999997`]}, "ColumnsIndexed" -> {}, "Rows" -> {Offset[0.2], {Offset[0.]}, Offset[0.2]}, "RowsIndexed" -> {}}],
892 | "GRETsr",
893 | Selectable->False]\)V[\[Phi]] + \!\(
894 | \*SubscriptBox[\(\[PartialD]\), \(\[Mu]\)]\[Phi]\) \!\(
895 | \*SubscriptBox[\(\[PartialD]\), \(\[Nu]\)]\[Phi]\);
896 | \!\(\*
897 | TagBox[GridBox[{
898 | {GridBox[{
899 | {
900 | RowBox[{"\[DoubleStruckCapitalT]", "[", "\[Phi]_", "]"}]}
901 | },
902 | Selectable->True],
903 | StyleBox[GridBox[{
904 | {"\[Lambda]_", ""},
905 | {"", "\[Nu]_"}
906 | },
907 | GridBoxSpacings->{"Columns" -> {Offset[0.27999999999999997`], {Offset[0.]}, Offset[0.27999999999999997`]}, "ColumnsIndexed" -> {}, "Rows" -> {Offset[0.2], {Offset[0.]}, Offset[0.2]}, "RowsIndexed" -> {}},
908 | Selectable->True],
909 | FontSize->10]}
910 | },
911 | GridBoxSpacings->{"Columns" -> {Offset[0.27999999999999997`], {Offset[0.]}, Offset[0.27999999999999997`]}, "ColumnsIndexed" -> {}, "Rows" -> {Offset[0.2], {Offset[0.]}, Offset[0.2]}, "RowsIndexed" -> {}}],
912 | "GRETsr",
913 | Selectable->False]\):= \!\(\*
914 | TagBox[GridBox[{
915 | {GridBox[{
916 | {
917 | RowBox[{"\[DoubleStruckCapitalT]", "[", "\[Phi]", "]"}]}
918 | },
919 | Selectable->True],
920 | StyleBox[GridBox[{
921 | {"\[Lambda]", ""},
922 | {"", "\[Nu]"}
923 | },
924 | GridBoxSpacings->{"Columns" -> {Offset[0.27999999999999997`], {Offset[0.]}, Offset[0.27999999999999997`]}, "ColumnsIndexed" -> {}, "Rows" -> {Offset[0.2], {Offset[0.]}, Offset[0.2]}, "RowsIndexed" -> {}},
925 | Selectable->True],
926 | FontSize->10]}
927 | },
928 | GridBoxSpacings->{"Columns" -> {Offset[0.27999999999999997`], {Offset[0.]}, Offset[0.27999999999999997`]}, "ColumnsIndexed" -> {}, "Rows" -> {Offset[0.2], {Offset[0.]}, Offset[0.2]}, "RowsIndexed" -> {}}],
929 | "GRETsr",
930 | Selectable->False]\) = Simp[\!\(
931 | \*UnderoverscriptBox[\(\[Sum]\), \(\[Mu]\), \(\[DoubleStruckX]\)]\ \(\*
932 | TagBox[GridBox[{
933 | {GridBox[{
934 | {"\[DoubleStruckG]"}
935 | },
936 | Selectable->True],
937 | StyleBox[GridBox[{
938 | {"\[Lambda]", "\[Mu]"},
939 | {"", ""}
940 | },
941 | GridBoxSpacings->{"Columns" -> {Offset[0.27999999999999997`], {Offset[0.]}, Offset[0.27999999999999997`]}, "ColumnsIndexed" -> {}, "Rows" -> {Offset[0.2], {Offset[0.]}, Offset[0.2]}, "RowsIndexed" -> {}},
942 | Selectable->True],
943 | FontSize->10]}
944 | },
945 | GridBoxSpacings->{"Columns" -> {Offset[0.27999999999999997`], {Offset[0.]}, Offset[0.27999999999999997`]}, "ColumnsIndexed" -> {}, "Rows" -> {Offset[0.2], {Offset[0.]}, Offset[0.2]}, "RowsIndexed" -> {}}],
946 | "GRETsr",
947 | Selectable->False]\ \*
948 | TagBox[GridBox[{
949 | {GridBox[{
950 | {
951 | RowBox[{"\[DoubleStruckCapitalT]", "[", "\[Phi]", "]"}]}
952 | },
953 | Selectable->True],
954 | StyleBox[GridBox[{
955 | {"", ""},
956 | {"\[Mu]", "\[Nu]"}
957 | },
958 | GridBoxSpacings->{"Columns" -> {Offset[0.27999999999999997`], {Offset[0.]}, Offset[0.27999999999999997`]}, "ColumnsIndexed" -> {}, "Rows" -> {Offset[0.2], {Offset[0.]}, Offset[0.2]}, "RowsIndexed" -> {}},
959 | Selectable->True],
960 | FontSize->10]}
961 | },
962 | GridBoxSpacings->{"Columns" -> {Offset[0.27999999999999997`], {Offset[0.]}, Offset[0.27999999999999997`]}, "ColumnsIndexed" -> {}, "Rows" -> {Offset[0.2], {Offset[0.]}, Offset[0.2]}, "RowsIndexed" -> {}}],
963 | "GRETsr",
964 | Selectable->False]\)\)];
965 | \!\(\*
966 | TagBox[GridBox[{
967 | {GridBox[{
968 | {
969 | RowBox[{"\[DoubleStruckCapitalT]", "[", "\[Phi]_", "]"}]}
970 | },
971 | Selectable->True],
972 | StyleBox[GridBox[{
973 | {"\[Lambda]_", "\[Nu]_"},
974 | {"", ""}
975 | },
976 | GridBoxSpacings->{"Columns" -> {Offset[0.27999999999999997`], {Offset[0.]}, Offset[0.27999999999999997`]}, "ColumnsIndexed" -> {}, "Rows" -> {Offset[0.2], {Offset[0.]}, Offset[0.2]}, "RowsIndexed" -> {}},
977 | Selectable->True],
978 | FontSize->10]}
979 | },
980 | GridBoxSpacings->{"Columns" -> {Offset[0.27999999999999997`], {Offset[0.]}, Offset[0.27999999999999997`]}, "ColumnsIndexed" -> {}, "Rows" -> {Offset[0.2], {Offset[0.]}, Offset[0.2]}, "RowsIndexed" -> {}}],
981 | "GRETsr",
982 | Selectable->False]\):=\!\(\*
983 | TagBox[GridBox[{
984 | {GridBox[{
985 | {
986 | RowBox[{" ",
987 | RowBox[{"\[DoubleStruckCapitalT]", "[", "\[Phi]", "]"}]}]}
988 | },
989 | Selectable->True],
990 | StyleBox[GridBox[{
991 | {"\[Lambda]", "\[Nu]"},
992 | {"", ""}
993 | },
994 | GridBoxSpacings->{"Columns" -> {Offset[0.27999999999999997`], {Offset[0.]}, Offset[0.27999999999999997`]}, "ColumnsIndexed" -> {}, "Rows" -> {Offset[0.2], {Offset[0.]}, Offset[0.2]}, "RowsIndexed" -> {}},
995 | Selectable->True],
996 | FontSize->10]}
997 | },
998 | GridBoxSpacings->{"Columns" -> {Offset[0.27999999999999997`], {Offset[0.]}, Offset[0.27999999999999997`]}, "ColumnsIndexed" -> {}, "Rows" -> {Offset[0.2], {Offset[0.]}, Offset[0.2]}, "RowsIndexed" -> {}}],
999 | "GRETsr",
1000 | Selectable->False]\) = Simp[\!\(
1001 | \*UnderoverscriptBox[\(\[Sum]\), \(\[Mu]\), \(\[DoubleStruckX]\)]\ \(\*
1002 | TagBox[GridBox[{
1003 | {GridBox[{
1004 | {"\[DoubleStruckG]"}
1005 | },
1006 | Selectable->True],
1007 | StyleBox[GridBox[{
1008 | {"\[Nu]", "\[Mu]"},
1009 | {"", ""}
1010 | },
1011 | GridBoxSpacings->{"Columns" -> {Offset[0.27999999999999997`], {Offset[0.]}, Offset[0.27999999999999997`]}, "ColumnsIndexed" -> {}, "Rows" -> {Offset[0.2], {Offset[0.]}, Offset[0.2]}, "RowsIndexed" -> {}},
1012 | Selectable->True],
1013 | FontSize->10]}
1014 | },
1015 | GridBoxSpacings->{"Columns" -> {Offset[0.27999999999999997`], {Offset[0.]}, Offset[0.27999999999999997`]}, "ColumnsIndexed" -> {}, "Rows" -> {Offset[0.2], {Offset[0.]}, Offset[0.2]}, "RowsIndexed" -> {}}],
1016 | "GRETsr",
1017 | Selectable->False]\ \*
1018 | TagBox[GridBox[{
1019 | {GridBox[{
1020 | {
1021 | RowBox[{"\[DoubleStruckCapitalT]", "[", "\[Phi]", "]"}]}
1022 | },
1023 | Selectable->True],
1024 | StyleBox[GridBox[{
1025 | {"\[Lambda]", ""},
1026 | {"", "\[Mu]"}
1027 | },
1028 | GridBoxSpacings->{"Columns" -> {Offset[0.27999999999999997`], {Offset[0.]}, Offset[0.27999999999999997`]}, "ColumnsIndexed" -> {}, "Rows" -> {Offset[0.2], {Offset[0.]}, Offset[0.2]}, "RowsIndexed" -> {}},
1029 | Selectable->True],
1030 | FontSize->10]}
1031 | },
1032 | GridBoxSpacings->{"Columns" -> {Offset[0.27999999999999997`], {Offset[0.]}, Offset[0.27999999999999997`]}, "ColumnsIndexed" -> {}, "Rows" -> {Offset[0.2], {Offset[0.]}, Offset[0.2]}, "RowsIndexed" -> {}}],
1033 | "GRETsr",
1034 | Selectable->False]\)\)];
1035 | (* Box operator actting on scalar only. (Note GRE doesn't know if a quantity is a scalar.) *)
1036 | SBox[\[Phi]_]:= Sum[\!\(\*
1037 | TagBox[GridBox[{
1038 | {GridBox[{
1039 | {"\[DoubleStruckG]"}
1040 | },
1041 | Selectable->True],
1042 | StyleBox[GridBox[{
1043 | {"\[Mu]", "\[Nu]"},
1044 | {"", ""}
1045 | },
1046 | GridBoxSpacings->{"Columns" -> {Offset[0.27999999999999997`], {Offset[0.]}, Offset[0.27999999999999997`]}, "ColumnsIndexed" -> {}, "Rows" -> {Offset[0.2], {Offset[0.]}, Offset[0.2]}, "RowsIndexed" -> {}},
1047 | Selectable->True],
1048 | FontSize->10]}
1049 | },
1050 | GridBoxSpacings->{"Columns" -> {Offset[0.27999999999999997`], {Offset[0.]}, Offset[0.27999999999999997`]}, "ColumnsIndexed" -> {}, "Rows" -> {Offset[0.2], {Offset[0.]}, Offset[0.2]}, "RowsIndexed" -> {}}],
1051 | "GRETsr",
1052 | Selectable->False]\) (\!\(\*
1053 | TagBox[GridBox[{
1054 | {"\[PartialD]",
1055 | StyleBox[GridBox[{
1056 | {"", ""},
1057 | {"\[Mu]", "\[Nu]"}
1058 | },
1059 | GridBoxSpacings->{"Columns" -> {Offset[0.27999999999999997`], {Offset[0.]}, Offset[0.27999999999999997`]}, "ColumnsIndexed" -> {}, "Rows" -> {Offset[0.2], {Offset[0.]}, Offset[0.2]}, "RowsIndexed" -> {}},
1060 | Selectable->True],
1061 | FontSize->10], GridBox[{
1062 | {"\[Phi]"}
1063 | },
1064 | Selectable->True]}
1065 | },
1066 | GridBoxSpacings->{"Columns" -> {Offset[0.27999999999999997`], {Offset[0.]}, Offset[0.27999999999999997`]}, "ColumnsIndexed" -> {}, "Rows" -> {Offset[0.2], {Offset[0.]}, Offset[0.2]}, "RowsIndexed" -> {}}],
1067 | "GRED",
1068 | Selectable->False]\) - Sum[\!\(\*
1069 | TagBox[GridBox[{
1070 | {GridBox[{
1071 | {"\[CapitalGamma]"}
1072 | },
1073 | Selectable->True],
1074 | StyleBox[GridBox[{
1075 | {"\[Lambda]", "", ""},
1076 | {"", "\[Mu]", "\[Nu]"}
1077 | },
1078 | GridBoxSpacings->{"Columns" -> {Offset[0.27999999999999997`], {Offset[0.]}, Offset[0.27999999999999997`]}, "ColumnsIndexed" -> {}, "Rows" -> {Offset[0.2], {Offset[0.]}, Offset[0.2]}, "RowsIndexed" -> {}},
1079 | Selectable->True],
1080 | FontSize->10]}
1081 | },
1082 | GridBoxSpacings->{"Columns" -> {Offset[0.27999999999999997`], {Offset[0.]}, Offset[0.27999999999999997`]}, "ColumnsIndexed" -> {}, "Rows" -> {Offset[0.2], {Offset[0.]}, Offset[0.2]}, "RowsIndexed" -> {}}],
1083 | "GRETsr",
1084 | Selectable->False]\) \!\(
1085 | \*SubscriptBox[\(\[PartialD]\), \(\[Lambda]\)]\[Phi]\),{\[Lambda],\[DoubleStruckX]}]), {\[Mu],\[DoubleStruckX]},{\[Nu],\[DoubleStruckX]}];]
1086 |
1087 |
1088 | Print\[CapitalGamma][]:= Do[If[Order[\[Mu],\[Nu]]>=0 && \!\(\*
1089 | TagBox[GridBox[{
1090 | {GridBox[{
1091 | {"\[CapitalGamma]"}
1092 | },
1093 | Selectable->True],
1094 | StyleBox[GridBox[{
1095 | {"\[Lambda]", "", ""},
1096 | {"", "\[Mu]", "\[Nu]"}
1097 | },
1098 | GridBoxSpacings->{"Columns" -> {Offset[0.27999999999999997`], {Offset[0.]}, Offset[0.27999999999999997`]}, "ColumnsIndexed" -> {}, "Rows" -> {Offset[0.2], {Offset[0.]}, Offset[0.2]}, "RowsIndexed" -> {}},
1099 | Selectable->True],
1100 | FontSize->10]}
1101 | },
1102 | GridBoxSpacings->{"Columns" -> {Offset[0.27999999999999997`], {Offset[0.]}, Offset[0.27999999999999997`]}, "ColumnsIndexed" -> {}, "Rows" -> {Offset[0.2], {Offset[0.]}, Offset[0.2]}, "RowsIndexed" -> {}}],
1103 | "GRETsr",
1104 | Selectable->False]\)=!=0, Print[HoldForm[\!\(\*
1105 | TagBox[GridBox[{
1106 | {GridBox[{
1107 | {"\[CapitalGamma]"}
1108 | },
1109 | Selectable->True],
1110 | StyleBox[GridBox[{
1111 | {"\[Lambda]", "", ""},
1112 | {"", "\[Mu]", "\[Nu]"}
1113 | },
1114 | GridBoxSpacings->{"Columns" -> {Offset[0.27999999999999997`], {Offset[0.]}, Offset[0.27999999999999997`]}, "ColumnsIndexed" -> {}, "Rows" -> {Offset[0.2], {Offset[0.]}, Offset[0.2]}, "RowsIndexed" -> {}},
1115 | Selectable->True],
1116 | FontSize->10]}
1117 | },
1118 | GridBoxSpacings->{"Columns" -> {Offset[0.27999999999999997`], {Offset[0.]}, Offset[0.27999999999999997`]}, "ColumnsIndexed" -> {}, "Rows" -> {Offset[0.2], {Offset[0.]}, Offset[0.2]}, "RowsIndexed" -> {}}],
1119 | "GRETsr",
1120 | Selectable->False]\)]," = ", \!\(\*
1121 | TagBox[GridBox[{
1122 | {GridBox[{
1123 | {"\[CapitalGamma]"}
1124 | },
1125 | Selectable->True],
1126 | StyleBox[GridBox[{
1127 | {"\[Lambda]", "", ""},
1128 | {"", "\[Mu]", "\[Nu]"}
1129 | },
1130 | GridBoxSpacings->{"Columns" -> {Offset[0.27999999999999997`], {Offset[0.]}, Offset[0.27999999999999997`]}, "ColumnsIndexed" -> {}, "Rows" -> {Offset[0.2], {Offset[0.]}, Offset[0.2]}, "RowsIndexed" -> {}},
1131 | Selectable->True],
1132 | FontSize->10]}
1133 | },
1134 | GridBoxSpacings->{"Columns" -> {Offset[0.27999999999999997`], {Offset[0.]}, Offset[0.27999999999999997`]}, "ColumnsIndexed" -> {}, "Rows" -> {Offset[0.2], {Offset[0.]}, Offset[0.2]}, "RowsIndexed" -> {}}],
1135 | "GRETsr",
1136 | Selectable->False]\)]], {\[Lambda],\[DoubleStruckX]},{\[Mu],\[DoubleStruckX]},{\[Nu],\[DoubleStruckX]}];
1137 | Print\[DoubleStruckCapitalR]4[]:= Do[If[Order[\[Lambda],\[Mu]]>0 && Order[\[Nu],\[Rho]]>0 && Order[\[Lambda],\[Nu]]>=0 && \!\(\*
1138 | TagBox[GridBox[{
1139 | {GridBox[{
1140 | {"\[DoubleStruckCapitalR]"}
1141 | },
1142 | Selectable->True],
1143 | StyleBox[GridBox[{
1144 | {"", "", "", ""},
1145 | {"\[Lambda]", "\[Mu]", "\[Nu]", "\[Rho]"}
1146 | },
1147 | GridBoxSpacings->{"Columns" -> {Offset[0.27999999999999997`], {Offset[0.]}, Offset[0.27999999999999997`]}, "ColumnsIndexed" -> {}, "Rows" -> {Offset[0.2], {Offset[0.]}, Offset[0.2]}, "RowsIndexed" -> {}},
1148 | Selectable->True],
1149 | FontSize->10]}
1150 | },
1151 | GridBoxSpacings->{"Columns" -> {Offset[0.27999999999999997`], {Offset[0.]}, Offset[0.27999999999999997`]}, "ColumnsIndexed" -> {}, "Rows" -> {Offset[0.2], {Offset[0.]}, Offset[0.2]}, "RowsIndexed" -> {}}],
1152 | "GRETsr",
1153 | Selectable->False]\)=!=0, Print[HoldForm[\!\(\*
1154 | TagBox[GridBox[{
1155 | {GridBox[{
1156 | {"\[DoubleStruckCapitalR]"}
1157 | },
1158 | Selectable->True],
1159 | StyleBox[GridBox[{
1160 | {"", "", "", ""},
1161 | {"\[Lambda]", "\[Mu]", "\[Nu]", "\[Rho]"}
1162 | },
1163 | GridBoxSpacings->{"Columns" -> {Offset[0.27999999999999997`], {Offset[0.]}, Offset[0.27999999999999997`]}, "ColumnsIndexed" -> {}, "Rows" -> {Offset[0.2], {Offset[0.]}, Offset[0.2]}, "RowsIndexed" -> {}},
1164 | Selectable->True],
1165 | FontSize->10]}
1166 | },
1167 | GridBoxSpacings->{"Columns" -> {Offset[0.27999999999999997`], {Offset[0.]}, Offset[0.27999999999999997`]}, "ColumnsIndexed" -> {}, "Rows" -> {Offset[0.2], {Offset[0.]}, Offset[0.2]}, "RowsIndexed" -> {}}],
1168 | "GRETsr",
1169 | Selectable->False]\)], " = ", \!\(\*
1170 | TagBox[GridBox[{
1171 | {GridBox[{
1172 | {"\[DoubleStruckCapitalR]"}
1173 | },
1174 | Selectable->True],
1175 | StyleBox[GridBox[{
1176 | {"", "", "", ""},
1177 | {"\[Lambda]", "\[Mu]", "\[Nu]", "\[Rho]"}
1178 | },
1179 | GridBoxSpacings->{"Columns" -> {Offset[0.27999999999999997`], {Offset[0.]}, Offset[0.27999999999999997`]}, "ColumnsIndexed" -> {}, "Rows" -> {Offset[0.2], {Offset[0.]}, Offset[0.2]}, "RowsIndexed" -> {}},
1180 | Selectable->True],
1181 | FontSize->10]}
1182 | },
1183 | GridBoxSpacings->{"Columns" -> {Offset[0.27999999999999997`], {Offset[0.]}, Offset[0.27999999999999997`]}, "ColumnsIndexed" -> {}, "Rows" -> {Offset[0.2], {Offset[0.]}, Offset[0.2]}, "RowsIndexed" -> {}}],
1184 | "GRETsr",
1185 | Selectable->False]\)]], {\[Lambda],\[DoubleStruckX]},{\[Mu],\[DoubleStruckX]},{\[Nu],\[DoubleStruckX]},{\[Rho],\[DoubleStruckX]}];
1186 | Print\[DoubleStruckCapitalR]2[]:= Do[If[Order[\[Mu],\[Nu]]>=0 && \!\(\*
1187 | TagBox[GridBox[{
1188 | {GridBox[{
1189 | {"\[DoubleStruckCapitalR]"}
1190 | },
1191 | Selectable->True],
1192 | StyleBox[GridBox[{
1193 | {"", ""},
1194 | {"\[Mu]", "\[Nu]"}
1195 | },
1196 | GridBoxSpacings->{"Columns" -> {Offset[0.27999999999999997`], {Offset[0.]}, Offset[0.27999999999999997`]}, "ColumnsIndexed" -> {}, "Rows" -> {Offset[0.2], {Offset[0.]}, Offset[0.2]}, "RowsIndexed" -> {}},
1197 | Selectable->True],
1198 | FontSize->10]}
1199 | },
1200 | GridBoxSpacings->{"Columns" -> {Offset[0.27999999999999997`], {Offset[0.]}, Offset[0.27999999999999997`]}, "ColumnsIndexed" -> {}, "Rows" -> {Offset[0.2], {Offset[0.]}, Offset[0.2]}, "RowsIndexed" -> {}}],
1201 | "GRETsr",
1202 | Selectable->False]\)=!=0, Print[HoldForm[\!\(\*
1203 | TagBox[GridBox[{
1204 | {GridBox[{
1205 | {"\[DoubleStruckCapitalR]"}
1206 | },
1207 | Selectable->True],
1208 | StyleBox[GridBox[{
1209 | {"", ""},
1210 | {"\[Mu]", "\[Nu]"}
1211 | },
1212 | GridBoxSpacings->{"Columns" -> {Offset[0.27999999999999997`], {Offset[0.]}, Offset[0.27999999999999997`]}, "ColumnsIndexed" -> {}, "Rows" -> {Offset[0.2], {Offset[0.]}, Offset[0.2]}, "RowsIndexed" -> {}},
1213 | Selectable->True],
1214 | FontSize->10]}
1215 | },
1216 | GridBoxSpacings->{"Columns" -> {Offset[0.27999999999999997`], {Offset[0.]}, Offset[0.27999999999999997`]}, "ColumnsIndexed" -> {}, "Rows" -> {Offset[0.2], {Offset[0.]}, Offset[0.2]}, "RowsIndexed" -> {}}],
1217 | "GRETsr",
1218 | Selectable->False]\)], " = ", \!\(\*
1219 | TagBox[GridBox[{
1220 | {GridBox[{
1221 | {"\[DoubleStruckCapitalR]"}
1222 | },
1223 | Selectable->True],
1224 | StyleBox[GridBox[{
1225 | {"", ""},
1226 | {"\[Mu]", "\[Nu]"}
1227 | },
1228 | GridBoxSpacings->{"Columns" -> {Offset[0.27999999999999997`], {Offset[0.]}, Offset[0.27999999999999997`]}, "ColumnsIndexed" -> {}, "Rows" -> {Offset[0.2], {Offset[0.]}, Offset[0.2]}, "RowsIndexed" -> {}},
1229 | Selectable->True],
1230 | FontSize->10]}
1231 | },
1232 | GridBoxSpacings->{"Columns" -> {Offset[0.27999999999999997`], {Offset[0.]}, Offset[0.27999999999999997`]}, "ColumnsIndexed" -> {}, "Rows" -> {Offset[0.2], {Offset[0.]}, Offset[0.2]}, "RowsIndexed" -> {}}],
1233 | "GRETsr",
1234 | Selectable->False]\)]], {\[Mu],\[DoubleStruckX]},{\[Nu],\[DoubleStruckX]}];
1235 | Print\[DoubleStruckCapitalG][]:= Do[If[Order[\[Mu],\[Nu]]>=0 &&\!\(\*
1236 | TagBox[GridBox[{
1237 | {GridBox[{
1238 | {
1239 | RowBox[{" ", "\[DoubleStruckCapitalG]"}]}
1240 | },
1241 | Selectable->True],
1242 | StyleBox[GridBox[{
1243 | {"", ""},
1244 | {"\[Mu]", "\[Nu]"}
1245 | },
1246 | GridBoxSpacings->{"Columns" -> {Offset[0.27999999999999997`], {Offset[0.]}, Offset[0.27999999999999997`]}, "ColumnsIndexed" -> {}, "Rows" -> {Offset[0.2], {Offset[0.]}, Offset[0.2]}, "RowsIndexed" -> {}},
1247 | Selectable->True],
1248 | FontSize->10]}
1249 | },
1250 | GridBoxSpacings->{"Columns" -> {Offset[0.27999999999999997`], {Offset[0.]}, Offset[0.27999999999999997`]}, "ColumnsIndexed" -> {}, "Rows" -> {Offset[0.2], {Offset[0.]}, Offset[0.2]}, "RowsIndexed" -> {}}],
1251 | "GRETsr",
1252 | Selectable->False]\)=!=0, Print[HoldForm[\!\(\*
1253 | TagBox[GridBox[{
1254 | {GridBox[{
1255 | {"\[DoubleStruckCapitalG]"}
1256 | },
1257 | Selectable->True],
1258 | StyleBox[GridBox[{
1259 | {"", ""},
1260 | {"\[Mu]", "\[Nu]"}
1261 | },
1262 | GridBoxSpacings->{"Columns" -> {Offset[0.27999999999999997`], {Offset[0.]}, Offset[0.27999999999999997`]}, "ColumnsIndexed" -> {}, "Rows" -> {Offset[0.2], {Offset[0.]}, Offset[0.2]}, "RowsIndexed" -> {}},
1263 | Selectable->True],
1264 | FontSize->10]}
1265 | },
1266 | GridBoxSpacings->{"Columns" -> {Offset[0.27999999999999997`], {Offset[0.]}, Offset[0.27999999999999997`]}, "ColumnsIndexed" -> {}, "Rows" -> {Offset[0.2], {Offset[0.]}, Offset[0.2]}, "RowsIndexed" -> {}}],
1267 | "GRETsr",
1268 | Selectable->False]\)], " = ", \!\(\*
1269 | TagBox[GridBox[{
1270 | {GridBox[{
1271 | {"\[DoubleStruckCapitalG]"}
1272 | },
1273 | Selectable->True],
1274 | StyleBox[GridBox[{
1275 | {"", ""},
1276 | {"\[Mu]", "\[Nu]"}
1277 | },
1278 | GridBoxSpacings->{"Columns" -> {Offset[0.27999999999999997`], {Offset[0.]}, Offset[0.27999999999999997`]}, "ColumnsIndexed" -> {}, "Rows" -> {Offset[0.2], {Offset[0.]}, Offset[0.2]}, "RowsIndexed" -> {}},
1279 | Selectable->True],
1280 | FontSize->10]}
1281 | },
1282 | GridBoxSpacings->{"Columns" -> {Offset[0.27999999999999997`], {Offset[0.]}, Offset[0.27999999999999997`]}, "ColumnsIndexed" -> {}, "Rows" -> {Offset[0.2], {Offset[0.]}, Offset[0.2]}, "RowsIndexed" -> {}}],
1283 | "GRETsr",
1284 | Selectable->False]\)]], {\[Mu],\[DoubleStruckX]},{\[Nu],\[DoubleStruckX]}];
1285 | Print\[DoubleStruckCapitalG]ud[]:=Do[If[\!\(\*
1286 | TagBox[GridBox[{
1287 | {GridBox[{
1288 | {"\[DoubleStruckCapitalG]"}
1289 | },
1290 | Selectable->True],
1291 | StyleBox[GridBox[{
1292 | {"\[Lambda]", ""},
1293 | {"", "\[Nu]"}
1294 | },
1295 | GridBoxSpacings->{"Columns" -> {Offset[0.27999999999999997`], {Offset[0.]}, Offset[0.27999999999999997`]}, "ColumnsIndexed" -> {}, "Rows" -> {Offset[0.2], {Offset[0.]}, Offset[0.2]}, "RowsIndexed" -> {}},
1296 | Selectable->True],
1297 | FontSize->10]}
1298 | },
1299 | GridBoxSpacings->{"Columns" -> {Offset[0.27999999999999997`], {Offset[0.]}, Offset[0.27999999999999997`]}, "ColumnsIndexed" -> {}, "Rows" -> {Offset[0.2], {Offset[0.]}, Offset[0.2]}, "RowsIndexed" -> {}}],
1300 | "GRETsr",
1301 | Selectable->False]\)=!=0, Print[HoldForm[\!\(\*
1302 | TagBox[GridBox[{
1303 | {GridBox[{
1304 | {"\[DoubleStruckCapitalG]"}
1305 | },
1306 | Selectable->True],
1307 | StyleBox[GridBox[{
1308 | {"\[Lambda]", ""},
1309 | {"", "\[Nu]"}
1310 | },
1311 | GridBoxSpacings->{"Columns" -> {Offset[0.27999999999999997`], {Offset[0.]}, Offset[0.27999999999999997`]}, "ColumnsIndexed" -> {}, "Rows" -> {Offset[0.2], {Offset[0.]}, Offset[0.2]}, "RowsIndexed" -> {}},
1312 | Selectable->True],
1313 | FontSize->10]}
1314 | },
1315 | GridBoxSpacings->{"Columns" -> {Offset[0.27999999999999997`], {Offset[0.]}, Offset[0.27999999999999997`]}, "ColumnsIndexed" -> {}, "Rows" -> {Offset[0.2], {Offset[0.]}, Offset[0.2]}, "RowsIndexed" -> {}}],
1316 | "GRETsr",
1317 | Selectable->False]\)], " = ", \!\(\*
1318 | TagBox[GridBox[{
1319 | {GridBox[{
1320 | {"\[DoubleStruckCapitalG]"}
1321 | },
1322 | Selectable->True],
1323 | StyleBox[GridBox[{
1324 | {"\[Lambda]", ""},
1325 | {"", "\[Nu]"}
1326 | },
1327 | GridBoxSpacings->{"Columns" -> {Offset[0.27999999999999997`], {Offset[0.]}, Offset[0.27999999999999997`]}, "ColumnsIndexed" -> {}, "Rows" -> {Offset[0.2], {Offset[0.]}, Offset[0.2]}, "RowsIndexed" -> {}},
1328 | Selectable->True],
1329 | FontSize->10]}
1330 | },
1331 | GridBoxSpacings->{"Columns" -> {Offset[0.27999999999999997`], {Offset[0.]}, Offset[0.27999999999999997`]}, "ColumnsIndexed" -> {}, "Rows" -> {Offset[0.2], {Offset[0.]}, Offset[0.2]}, "RowsIndexed" -> {}}],
1332 | "GRETsr",
1333 | Selectable->False]\)]], {\[Lambda],\[DoubleStruckX]},{\[Nu],\[DoubleStruckX]}];
1334 | Print\[DoubleStruckCapitalG]uu[]:=Do[If[\!\(\*
1335 | TagBox[GridBox[{
1336 | {GridBox[{
1337 | {"\[DoubleStruckCapitalG]"}
1338 | },
1339 | Selectable->True],
1340 | StyleBox[GridBox[{
1341 | {"\[Lambda]", "\[Nu]"},
1342 | {"", ""}
1343 | },
1344 | GridBoxSpacings->{"Columns" -> {Offset[0.27999999999999997`], {Offset[0.]}, Offset[0.27999999999999997`]}, "ColumnsIndexed" -> {}, "Rows" -> {Offset[0.2], {Offset[0.]}, Offset[0.2]}, "RowsIndexed" -> {}},
1345 | Selectable->True],
1346 | FontSize->10]}
1347 | },
1348 | GridBoxSpacings->{"Columns" -> {Offset[0.27999999999999997`], {Offset[0.]}, Offset[0.27999999999999997`]}, "ColumnsIndexed" -> {}, "Rows" -> {Offset[0.2], {Offset[0.]}, Offset[0.2]}, "RowsIndexed" -> {}}],
1349 | "GRETsr",
1350 | Selectable->False]\)=!=0, Print[HoldForm[\!\(\*
1351 | TagBox[GridBox[{
1352 | {GridBox[{
1353 | {"\[DoubleStruckCapitalG]"}
1354 | },
1355 | Selectable->True],
1356 | StyleBox[GridBox[{
1357 | {"\[Lambda]", "\[Nu]"},
1358 | {"", ""}
1359 | },
1360 | GridBoxSpacings->{"Columns" -> {Offset[0.27999999999999997`], {Offset[0.]}, Offset[0.27999999999999997`]}, "ColumnsIndexed" -> {}, "Rows" -> {Offset[0.2], {Offset[0.]}, Offset[0.2]}, "RowsIndexed" -> {}},
1361 | Selectable->True],
1362 | FontSize->10]}
1363 | },
1364 | GridBoxSpacings->{"Columns" -> {Offset[0.27999999999999997`], {Offset[0.]}, Offset[0.27999999999999997`]}, "ColumnsIndexed" -> {}, "Rows" -> {Offset[0.2], {Offset[0.]}, Offset[0.2]}, "RowsIndexed" -> {}}],
1365 | "GRETsr",
1366 | Selectable->False]\)], " = ", \!\(\*
1367 | TagBox[GridBox[{
1368 | {GridBox[{
1369 | {"\[DoubleStruckCapitalG]"}
1370 | },
1371 | Selectable->True],
1372 | StyleBox[GridBox[{
1373 | {"\[Lambda]", "\[Nu]"},
1374 | {"", ""}
1375 | },
1376 | GridBoxSpacings->{"Columns" -> {Offset[0.27999999999999997`], {Offset[0.]}, Offset[0.27999999999999997`]}, "ColumnsIndexed" -> {}, "Rows" -> {Offset[0.2], {Offset[0.]}, Offset[0.2]}, "RowsIndexed" -> {}},
1377 | Selectable->True],
1378 | FontSize->10]}
1379 | },
1380 | GridBoxSpacings->{"Columns" -> {Offset[0.27999999999999997`], {Offset[0.]}, Offset[0.27999999999999997`]}, "ColumnsIndexed" -> {}, "Rows" -> {Offset[0.2], {Offset[0.]}, Offset[0.2]}, "RowsIndexed" -> {}}],
1381 | "GRETsr",
1382 | Selectable->False]\)]], {\[Lambda],\[DoubleStruckX]},{\[Nu],\[DoubleStruckX]}];
1383 |
1384 |
1385 | CalcEom::usage:="calcEom[lag,v] calcualtes the variatioin principle for Lagrangian lag, wrt variable v."
1386 | CalcEom[lag_,v_]:=Module[{d,ep,l1,l1ibp},
1387 | l1=Expand@Coefficient[#,ep,1]&@Series[lag/.{Derivative[n__][v][x__]:>Derivative[n][v][x]+ep*Derivative[n][d][x],v[x__]:>v[x]+ep*d[x],v:>v+ep*d},{ep,0,1}];
1388 | l1ibp=l1 /. { f_*Derivative[n__][g_][x__]/;FreeQ[f,d]&&!FreeQ[g,d] :> (-1)^Total@{n}*D[f, Sequence@@Transpose@{{x},{n}}]*g[x] };
1389 | -l1ibp/.{d[x__]->1,d->1}//Simp]
1390 |
1391 |
1392 | CollectD::usage:="CollectD[expr] collects derivatives using the rules defined in cond."
1393 | CollectD[expr_]:= Module[{f, cond, vars, ass},
1394 | cond = {
1395 | Derivative[0,2,0,0][f]@@\[DoubleStruckX] + Derivative[0,0,2,0][f]@@\[DoubleStruckX] + Derivative[0,0,0,2][f]@@ \[DoubleStruckX] == \[CapitalSampi]["ii"][f]@@\[DoubleStruckX]};
1396 | vars = Union@Cases[expr, Derivative[__][e_][__] :> e, {0,Infinity}];
1397 | ass = And @@ Flatten[cond /. (f -> # & /@ vars)];
1398 | Simplify[expr, ass]]
1399 |
--------------------------------------------------------------------------------