Programa complet

Clear["Global`*"];

SetDirectory["\\Users\\planelle\\josep\\planelles\\Docencia\\T_fi_Grau\\symmetry\\Potencies_SO3"];

(* Definim els caràcters de (Subscript[C, ∞]^ϕ) de les irreps (Subscript[D, 0]) fins a (Subscript[D, 50]) (dlim=50) en notació complexa*)
dlim=50;
caracter[0]=1;(Subscript[R, 0])=caracter[0];
For[i=(1/2),i≤dlim,i+=(1/2),
caracter[i]=(∑_(m=-i)^i)Exp[I m ϕ];
(Subscript[R, i])=caracter[i];
];
(*  xx = (Subscript[R, 1/2]); *)
<<input1.txt
xx=(Subscript[R, j0]);

(*rep és el caràcter de la representació reductible *)
(*********** S2 *************)
rep2=(1/2)(Expand[(xx^2)]+Expand[(xx/.ϕ->2 ϕ)])//Expand;  a1=ExpToTrig[Expand[rep2]];
rep12=(1/2)(Expand[(xx^2)]-Expand[(xx/.ϕ->2 ϕ)])//Expand;  a2=ExpToTrig[Expand[rep12]];
S2={a1,a2};  S2Sym={"[2]","[(1^2)]"};  S2dim={1,1};
(*********** S3 *************)
rep3=(1/6)(Expand[(xx^3)]+3Expand[xx/.ϕ->2 ϕ]xx+2Expand[xx/.ϕ-> 3 ϕ]);  a1=ExpToTrig[Expand[rep3]];
rep21=(2/3)(Expand[(xx^3)]-Expand[xx/.ϕ-> 3 ϕ]);   e=ExpToTrig[Expand[rep21]];  
rep13=(1/6)(Expand[(xx^3)]-3Expand[xx/.ϕ->2 ϕ]xx+2Expand[xx/.ϕ-> 3 ϕ]);  a2=ExpToTrig[Expand[rep13]];  
S3={a1,e,a2};  S3Sym={"[3]","[2 1]","[(1^3)]"};    S3dim={1,2,1};
(*********** S4 *************)
rep4=(1/24)(Expand[(xx^4)]+8Expand[xx/.ϕ->3 ϕ]xx+3Expand[(((xx/.ϕ-> 2 ϕ))^2)]+6Expand[xx/.ϕ->4 ϕ]+6Expand[Expand[(xx^2)]*Expand[xx/.ϕ->2 ϕ]])//Expand;  a1=ExpToTrig[Expand[rep4]];
rep31=(3/24)(3Expand[(xx^4)]-3Expand[(((xx/.ϕ-> 2 ϕ))^2)]-6Expand[xx/.ϕ->4 ϕ]+6Expand[Expand[(xx^2)]*Expand[xx/.ϕ->2 ϕ]])//Expand;    f2=ExpToTrig[Expand[rep31]]; 
rep22=(2/24)(2Expand[(xx^4)]-8Expand[xx/.ϕ->3 ϕ]xx+6Expand[(((xx/.ϕ-> 2 ϕ))^2)])//Expand;      e=ExpToTrig[Expand[rep22]];
rep212=(3/24)(3Expand[(xx^4)]-3Expand[(((xx/.ϕ-> 2 ϕ))^2)]+6Expand[xx/.ϕ->4 ϕ]-6Expand[Expand[(xx^2)]*Expand[xx/.ϕ->2 ϕ]])//Expand;    f1=ExpToTrig[Expand[rep212]]; 
rep14=(1/24)(Expand[(xx^4)]+8Expand[xx/.ϕ->3 ϕ]xx+3Expand[(((xx/.ϕ-> 2 ϕ))^2)]-6Expand[xx/.ϕ->4 ϕ]-6Expand[Expand[(xx^2)]*Expand[xx/.ϕ->2 ϕ]])//Expand;    a2=ExpToTrig[Expand[rep14]];  



S4={a1,f2,e,f1,a2};  S4Sym={"[4]","[3 1]","[(2^2)]","[2 (1^2)]","[(1^4)]"};    S4dim={1,3,2,3,1};
(*********** S5 *************)
rep5=(1/120)(Expand[(xx^5)]+15Expand[(((xx/.ϕ->2 ϕ))^2)]xx+30Expand[(xx/.ϕ-> 4 ϕ)]xx+20Expand[(xx^2)]Expand[xx/.ϕ->3 ϕ]+24Expand[xx/.ϕ->5 ϕ]+20Expand[(xx/.ϕ-> 2 ϕ)] Expand[(xx/.ϕ-> 3ϕ)]+10 Expand[(xx/.ϕ-> 2 ϕ)] Expand[(xx^3)])//Expand;  a1=ExpToTrig[Expand[rep5]];
rep41=(4/120)(4Expand[(xx^5)]+20Expand[(xx^2)]Expand[xx/.ϕ->3 ϕ]-24Expand[xx/.ϕ->5 ϕ]-20Expand[(xx/.ϕ-> 2 ϕ)] Expand[(xx/.ϕ-> 3ϕ)]+20 Expand[(xx/.ϕ-> 2 ϕ)] Expand[(xx^3)])//Expand;  g1=ExpToTrig[Expand[rep41]];
rep32=(5/120)(5Expand[(xx^5)]+15Expand[(((xx/.ϕ->2 ϕ))^2)]xx-30Expand[(xx/.ϕ-> 4 ϕ)]xx-20Expand[(xx^2)]Expand[xx/.ϕ->3 ϕ]+20Expand[(xx/.ϕ-> 2 ϕ)] Expand[(xx/.ϕ-> 3ϕ)]+10 Expand[(xx/.ϕ-> 2 ϕ)] Expand[(xx^3)])//Expand;  h1=ExpToTrig[Expand[rep32]];
rep312=(6/120)(6Expand[(xx^5)]-30Expand[(((xx/.ϕ->2 ϕ))^2)]xx+24Expand[xx/.ϕ->5 ϕ])//Expand;  j=ExpToTrig[Expand[rep312]];
rep221=(5/120)(5Expand[(xx^5)]+15Expand[(((xx/.ϕ->2 ϕ))^2)]xx+30Expand[(xx/.ϕ-> 4 ϕ)]xx-20Expand[(xx^2)]Expand[xx/.ϕ->3 ϕ]-20Expand[(xx/.ϕ-> 2 ϕ)] Expand[(xx/.ϕ-> 3ϕ)]-10 Expand[(xx/.ϕ-> 2 ϕ)] Expand[(xx^3)])//Expand;  h2=ExpToTrig[Expand[rep221]];
rep213=(4/120)(4Expand[(xx^5)]+20Expand[(xx^2)]Expand[xx/.ϕ->3 ϕ]-24Expand[xx/.ϕ->5 ϕ]+20Expand[(xx/.ϕ-> 2 ϕ)] Expand[(xx/.ϕ-> 3ϕ)]-20 Expand[(xx/.ϕ-> 2 ϕ)] Expand[(xx^3)])//Expand;  g2=ExpToTrig[Expand[rep213]];
rep15=(1/120)(Expand[(xx^5)]+15Expand[(((xx/.ϕ->2 ϕ))^2)]xx-30Expand[(xx/.ϕ-> 4 ϕ)]xx+20Expand[(xx^2)]Expand[xx/.ϕ->3 ϕ]+24Expand[xx/.ϕ->5 ϕ]-20Expand[(xx/.ϕ-> 2 ϕ)] Expand[(xx/.ϕ-> 3ϕ)]-10 Expand[(xx/.ϕ-> 2 ϕ)] Expand[(xx^3)])//Expand;  a2=Exp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))^2) (xx/.ϕ->3ϕ)+1 420  (xx/.ϕ->3ϕ) (xx/.ϕ->4ϕ)+(-1) 720 (xx/.ϕ->7ϕ))//Expand; a215=ExpToTrig[Expand[rep215]];
rep17=(1/5040)((xx^7)+(-1)21(xx^5)Expand[(xx/.ϕ->2 ϕ)] +70 (xx^4)(xx/.ϕ-> 3 ϕ)+(-1)210(xx^3)(xx/.ϕ->4ϕ)+105 (xx^3)(((xx/.ϕ->2 ϕ))^2)+(-1)420 (xx^2)(xx/.ϕ-> 2 ϕ)(xx/.ϕ-> 3ϕ)+504(xx^2)  (xx/.ϕ-> 5 ϕ)+(-1)840 xx (xx/.ϕ-> 6ϕ)+630 xx (xx/.ϕ->2 ϕ)(xx/.ϕ->4ϕ)+(-1)105 xx (((xx/.ϕ->2 ϕ))^3)+280 xx (((xx/.ϕ->3 ϕ))^2)+(-1)504 (xx/.ϕ->2ϕ) (xx/.ϕ->5ϕ)+210 (((xx/.ϕ->2 ϕ))^2) (xx/.ϕ->3ϕ)+(-1)420  (xx/.ϕ->3ϕ) (xx/.ϕ->4ϕ)+720 (xx/.ϕ->7ϕ))//Expand; a17=ExpToTrig[Expand[rep17]];
S7={a7,a61,a52,a512,a43,a421,a321b,a413,a322,a3212,a231,a314,a2213,a215,a17};  S7Sym={"[7]","[6 1]","[5 2]","[5 (1^2)]","[4 3]","[4 2 1]","[(3^2) 1]","[4 (1^3)]","[3 (2^2)]","[3 2 (1^2)]","[(2^3) 1]","[3 (1^4)]","[(2^2) (1^3)]","[2 (1^5)]","[(1^7)]"};  S7dim={1,6,14,15,14,35,21,20,21,35,14,15,14,6,1};

(* Redefinim els caràcters de (Subscript[C, ∞]^ϕ) de les irreps (Subscript[D, 0]) fins a (Subscript[D, 50]) dlim=50 en notació trigonometrica*)
For[i=0,i≤dlim,i+=(1/2),
(Subscript[R, i])=ExpToTrig[caracter[i]];
];

(* triem potència *)
(* Sn=S5;SnSym=S5Sym;*)
<<input2.txt

(* comença el procés *)
output={};
For[ k=1,k≤Length[Sn],k++,
reptrig=Sn[[k]];
Print["representació reductible inicial Γ = ",reptrig];
(* J maxima -> Ficar un valor per excés *) 
J=25;
Γ=0;
For[i=0,i≤J,i++,
If[Length[reptrig]==0,Γ=Γ+reptrig (Subscript[D, 0]);Break[]];
If[reptrig[[2]]==Cos[(ϕ/2)],Γ=Γ+((reptrig[[1]])/2) (Subscript[D, 1/2]);Break[]];
(*******If[reptrig[[2]]==Cos[(ϕ/2)],Γ=Γ+((reptrig[[1]])/2) (Subscript[D, 1/2]);Break[]];  no pot donar-se *****)
(*Característiques de la rep reductible*)
cont=0;
(* nombre de termes que van sumats en la la rep reductible inicial reptrig*)
lon=Length[reptrig];
(*factor davant del Cos[n ϕ] amb el n major, que és el últim element de reptrig *)
fact=reptrig[[lon,1]];
(******* Print["nombre de vegades que apareix la irrep: ",fact/2];  *****)
(* La longitud del terme amb el n major Cos[n ϕ] sempre serà 2 (2k Cos[n ϕ]) *)
(* func -> funció coseno del terme de major n *)
func=reptrig[[lon,2]];
(* determinació del valor de n  *)
If[func== Cos[ϕ],n=1;cont=1];
If[cont==0,n=func[[1,1]]];
(******* Print["valor de de argument del coseno n = ",n];  *****)
Γ=Γ+(fact/2)(Subscript[D, n]);
(*******   Print["Γ intermedia ", Γ];  *****)
(* restem a la rep inicial la meitat de fact (perquè el terme és "k 2 Cos[n ϕ]") multiplicada pel caracter de la 
   representacio irreductible  corresponent al valor n (atenció: que és la irrep 'n+1')*)
reptrig=reptrig-(fact/2)(Subscript[R, n])//Expand;
(*******      Print["despres de restar ", reptrig];   *****) 
If[reptrig==0,Break[]];
If[n==1,Γ=Γ+reptrig (Subscript[D, 0]);Break[]];
];
Print["{Γ|",SnSym[[k]],"(dim = ",Sndim[[k]],")} = ",Framed[Γ/Sndim[[k]]//Expand]];
aux={SnSym[[k]],Sndim[[k]]};
output=AppendTo[output,{aux,Γ/Sndim[[k]]//Expand}];
];
output>>output.txt;
output//TeXForm>>output.tex;
Export["output.pdf",output];