Notes/1_math

tu 1_math 2_all 3_charts 4_i3 5_bash 6_avia 7_js 8_Dia23 9_prog_short Archive Barahlo Life nu

Data File


Clear["`*"]; a=2 2; Remove["Global`*"];
dontclear=1;
Unprotect[C];Clear[C];
dataFileName=$Input;	(* it saves data file name, 29.02.2024 *)

var=x/@{0,1,2,3};	(* an alternative form at 31.01.2024 *)

ddelt=1;


(* 30 *) VG={{0,1,0,0},{1,0,0,0},{0,0,G[2,2]'[x[0]],G[2,3]'[x[0]]},{0,0,G[2,3]'[x[0]],G[3,3]'[x[0]]}}/ddelt;
(*
Print[" ATTENTION !!! solution F_01=F_12=F_13=F_23=J^0=La=0 used ! see the datafile "];

La=0;F/:F[0,1]@@var=0;F/:F[1,2]@@var=0;F/:F[1,3]@@var=0;F/:F[2,3]@@var=0;J/:J[0]@@var=0;
*)


(* ======================= SIM-S =========================== *)


Print[" ATTENTION !!! G = G22 G33 - G23^2  -  it is not the det of the metric ! "];

sim={

	G[2,3]'[xx_]^(nn_Integer /; Positive[nn])->(1/g[xx]+G[2,2]'[xx]G[3,3]'[xx]) G[2,3]'[xx]^(nn-2), 			(* a new form of the 'sim' at 01.02.2024 --- xx needs the '//.' method *)

	G[2,3][xx_]^(nn_Integer /; Positive[nn])->(-GG[xx]+G[2,2][xx]G[3,3][xx]) G[2,3][xx]^(nn-2)

};

antisim={GG[xx_]->-G[2,3][xx]^2+G[2,2][xx]G[3,3][xx]};

sim2derivs = {

	G[2, 2]'[xx_]G[3, 3]''[xx_] ->  g'[xx]/g[xx]^2 + 2G[2, 3]'[xx]G[2, 3]''[xx] - G[3, 3]'[xx]G[2, 2]''[xx],

    (G[2, 2]'[xx_]G[3, 3]''[xx_])^2 -> (g'[xx]/g[xx]^2 + 2G[2, 3]'[xx]G[2, 3]''[xx] - G[3, 3]'[xx]G[2, 2]''[xx])^2

};

simOptForGij={

	G[3, 3][xx__] G[2, 2]'@xx__  -> GG'[xx]+ 2 G[2, 3]@xx G[2, 3]'@xx - G[2, 2]@xx G[3, 3]'@xx,									(* this rule allow obtain 'g_ij' by directly calculation *)

	G[3, 3][xx__]^nn_ G[2, 2]'@xx__  -> (GG'[xx]+ 2 G[2, 3]@xx G[2, 3]'@xx - G[2, 2]@xx G[3, 3]'@xx)G[3,3][xx]^(nn-1)

};

ass = GG'[xx_] ->-(2G[2, 3][xx]G[2, 3]'[xx] - G[2, 2][xx]G[3, 3]'[xx] - G[2, 2]'[xx]G[3, 3][xx]);

simLowG={

	G[2,2]@xx__->Gdown[3,3]@xx GG@xx, G[2,3]@xx__->-Gdown[2,3]@xx GG@xx, G[3,3]@xx__->Gdown[2,2]@xx GG@xx,

	G[2,2]'@xx__->Gdown[3,3]'@xx GG@xx + Gdown[3,3]@xx GG'@xx, G[2,3]'@xx__->-Gdown[2,3]'@xx GG@xx - Gdown[2,3]@xx GG'@xx, G[3,3]'@xx__->Gdown[2,2]'@xx GG@xx + Gdown[2,2]@xx GG'@xx

};


simLowg={

	g@xx__ G[2,2]'@xx__->-gdown[3,3]@xx, g@xx__ G[2,3]'@xx__->gdown[2,3]@xx, g@xx__ G[3,3]'@xx__->-gdown[2,2]@xx

};


BackJacobianWrittenByHands:=Block[{pip},

	runBackJacobianWrittenByHands=1;


		(* ! *) zz = {G[it_,jt_][__] -> G[it,jt][z], G[it_,jt_]'[__] -> G[it,jt]'[z], GG[it_]->GG[z], GG'[it_]->GG'[z]};
		(* ! *) gpq = {
				x[3]^2 G[2,2][z]-2x[2]x[3]G[2,3][z]+x[2]^2 G[3,3][z]->(GPQ-2x[1]) GG[z],
				x[3]^2 G[2,2][z]->(GPQ-2x[1]) GG[z]+2x[2]x[3]G[2,3][z]-x[2]^2 G[3,3][z],
				x[3]^3 G[2,2][z]^2->((GPQ-2x[1]) GG[z]+2x[2]x[3]G[2,3][z]-x[2]^2 G[3,3][z])x[3]G[2,2][z],
				at___ x[3]^2 G[2,2][z] yt___->at((GPQ-2x[1]) GG[z]+2x[2]x[3]G[2,3][z]-x[2]^2 G[3,3][z])yt,
				x[3]^2 G[2,2]'[z]->GPQ' GG[z]+2x[2]x[3]G[2,3]'[z]-x[2]^2 G[3,3]'[z]+GG'[z] (GPQ-2x[1])
				};
		(* ! *)	antigpq={GPQ->2x[1]+(x[3]^2 G[2,2][z]-2x[2]x[3]G[2,3][z]+x[2]^2 G[3,3][z])/GG[z]};
		(* ! *)	antigpq=antigpq~Join~{GPQ' -> D[antigpq[[1, 2]], z]};

		(* ! *) s1 = Solve[{trans[2],trans[3]} /. Rule -> Equal, {y[2], y[3]}][[1]] /. zz /.sim // FS;
		(* ! *) t1 = trans[1] /. s1 /. Rule -> Equal /. zz // FS; t1 = t1 /. sim // FS; t1 =  t1 /. gpq;
		(* ! *) s2 = Solve[t1, y[1]][[1, 1]] // FS;
		(* ! *) t2 = s1 /. s2 // FS;
		(* ! *) s3 = Solve[trans[0] /. s2 /. Rule -> Equal /. y[0]^2 -> yy, yy][[1, 1]] /. yy -> y[0]^2;
		(* ! *) backtrans[0] = y[0] -> Sqrt[s3[[2]]];
		(* ! *) backtrans[1] = s2 /. backtrans[0] // FS;
		(* ! *) backtrans[2] = t2[[1]] /. backtrans[0] // FS;
		(* ! *) backtrans[3] = t2[[2]] /. backtrans[0] // FS;

		TransToPriv=backtrans/@{0,1,2,3}/.z->x[0];

		(* ! *) texHeadPrint[" The Simplification Definition is used: "];
				varPrint[gpq];
		(* ! *) Print[gpq[[1]]];	equationLabel="gpq_definition";texPrint["",gpq[[1]],""];
				varPrint[backtrans];
		(* ! *) Do[texMatrixPrint[backtrans[i]],{i,0,3}];

		(* ! *) Do[backtransNoSim[i]=backtrans[i]/.antigpq/.z->x[0]//FS,{i,0,3}];

		(* ! *) backjacobian[2,0]=Sqrt[x[0]](( G[3,3]'[z]x[2]-G[2,3]'[z]x[3])-( G[3,3][z]x[2]-G[2,3][z]x[3])(GG'[z]/GG[z]+GPQ'/GPQ/2-1/2/x[0]))/GG[z]/Sqrt[GPQ];
		(* ! *) backjacobian[3,0]=Sqrt[x[0]]((-G[2,3]'[z]x[2]+G[2,2]'[z]x[3])-(-G[2,3][z]x[2]+G[2,2][z]x[3])(GG'[z]/GG[z]+GPQ'/GPQ/2-1/2/x[0]))/GG[z]/Sqrt[GPQ];

		pip[it_]:=it/.sim//.zz//.gpq//FS//PowerExpand;

		(* ! *)	Do[If[!((i==2 && j==0) || (i==3 && j==0)),
		(* ! *)		backjacobian[i,j]=D[backtransNoSim[i][[2]],x[j]]//FS;
		(* ! *)		backjacobian[i,j]=FixedPoint[pip,backjacobian[i,j]];	(* new at 31.01.2024 *)
		(* ! *)		];
		(* ! *)		backjacobian[i,j]=backjacobian[i,j]/.z->x[0];
				,{i,0,3},{j,0,3}];


		(* ! *)	Print[" Verified! "];

		Clear[s1,t1,s2,t2,s3];

		Print["zz, gpq, antigpq, pip[x] - are not clear! "];

];


(* ============================================================================================== *)




(* this is a great job, but unusual at moment *)
(* this is a metric in Syncr. CS written directly by hands, without calculations *)
(* ------------ simplifications ----------------*)

SyncMetricWrittenByHands:=Block[{},

	runSyncMetricWrittenByHands=1;

	(*
	texHeadPrint[" Definition for simplification of backward transform. "];
	hzsim=x[3]^2 G[2, 2][x[0]]-> F^2-2*GG[x[0]]*x[1] + 2*x[2]*x[3]*G[2,3][x[0]] - x[2]^2*G[3,3][x[0]];
	hysim = D[hzsim[[1]], x[0]] -> (F^2)' + D[hzsim[[2]], x[0]];
	Print[hzsim//.w//yoyo]; texPrint["",hzsim,""];
	Print[hysim//.w//yoyo]; texPrint["",hysim,""];
	*)



	(*Print["---- sims cov. ---- "];*)
	Clear[z];
	ngsync[0,0]=1; 	ngsync[0,1]=ngsync[0,2]=ngsync[0,3]=0;
	ngsync[2,2]=g[z]GG[z]^2 D[G[2,2][z]/GG[z],z]/y[1]^2/.z->y[0]y[1]//FS;
	ngsync[2,3]=g[z]GG[z]^2 D[G[2,3][z]/GG[z],z]/y[1]^2/.z->y[0]y[1]//FS;
	ngsync[3,3]=g[z]GG[z]^2 D[G[3,3][z]/GG[z],z]/y[1]^2/.z->y[0]y[1]//FS;
	ngsync[1,3]=-ngsync[2, 3]y[2]/y[1]-ngsync[3, 3]y[3]/y[1];
	ngsync[1,2]=-ngsync[2, 2]y[2]/y[1]-ngsync[2, 3]y[3]/y[1];
	ngsync[1,1]=ngsync[2, 2]y[2]^2/y[1]^2+2 ngsync[2, 3]y[2]y[3]/y[1]^2+ngsync[3, 3]y[3]^2/y[1]^2-y[0]^2/y[1]^2;
	Do[ngsync[j,i]=ngsync[i,j],{i,0,3},{j,i+1,3}];

	(*Do[Print[i,j,".      ",ngsync[i,j]//.w//yoyo],{i,0,3},{j,i,3}];*)



	(*Print["---- sims contrav. ---- "];*)
	vgsync[0,0]=1; 	vgsync[0,1]=vgsync[0,2]=vgsync[0,3]=0;
	Do[vgsync[1,i]=-y[1]y[i]/y[0]^2,{i,3}];
	vgsync[2,2]=-D[G[3,3][z]/GG[z],z]y[1]^2 - y[2]^2/y[0]^2/.z->y[0]y[1];
	vgsync[2,3]= D[G[2,3][z]/GG[z],z]y[1]^2-y[2]y[3]/y[0]^2/.z->y[0]y[1];
	vgsync[3,3]=-D[G[2,2][z]/GG[z],z]y[1]^2 - y[3]^2/y[0]^2/.z->y[0]y[1];
	Do[vgsync[j,i]=vgsync[i,j],{i,0,3},{j,i+1,3}];

	(*Do[Print[i,j,".      ",vgsync[i,j]//.w//yoyo],{i,0,3},{j,i,3}];*)

];




HandMadeVSDirectlyCalculatedMetricsComparision:=Block[{},

			(* At present we have 2 methods of discovering of introducing hand-made metric in data file:
				1) ValueQ[SimMetricWrittenByHands];
				2) runSimMetricWrittenByHands===1
			*)

			If[ValueQ[SyncMetricWrittenByHands],SyncMetricWrittenByHands]; (* from '30general_diff' at 11.01.2024 *)

			If[runSyncMetricWrittenByHands===1,
				Print[" Metric tensor is simplified by hands, see input data file "];
				TrueTest=(Table[ngsync[i,j]==ngsync0[i,j]/.ass/.antisim//FS,{i,0,3},{j,0,3}]//Flatten)~DeleteCases~True;
				If[
					TrueTest=={},Print[" Simplified metric tensor is the same as the directly calculated "],
					Print[" Attention! Some difference between hand-made & directly calculated metrics is obtained! "];
					Print[TrueTest//.w]
				],
				Print[" Metric tensor is directly calculated "];
				Do[ngsync[i,j]=ngsync0[i,j];vgsync[i,j]=vgsync0[i,j],{i,0,3},{j,0,3}]
			];

			texHeadPrint[" Metric in synchr. coord. system "];
			Do[
				texPrintingTensorIJ[ngsync, "\\tilde g_{````} = ", "gcovar[``,``] := "]
			,{i,0,3},{j,i,3}];

			texHeadPrint[" Contravariant metric tensor in Synch. CS "];
			Do[
				texPrintingTensorIJ[vgsync, "\\tilde g^{````} = ", "gcontr[``,``] := "]
			,{i,0,3},{j,i,3}];
];

Main Program

(* the goal of this file is transition from rules 'w' to the fuction 'Format' *)
(* iterators: i,j,k,m,n. don't use! *)

SetOptions[$FrontEnd, Background -> GrayLevel[0.], FontColor -> GrayLevel[1], FontSize -> 18,FontFamily -> "Dejavu Sans Mono"];
SetOptions[OpenWrite["texoutput.tex"],PageWidth->Infinity];
yoyo[it_] := StyleForm[it, FontFamily -> "Dejavu Sans Mono"]//TF;		(* for some Linuxes *)
(*yoyo[it_] := it//TF;*)

(* this program demands some metric tensor before it *)

If[!dontclear===1, Print["General case"]; Clear["`*"]];    dontclear=.;


If[!ValueQ[VG],Print["    Write, please, some metric tensor!"];Abort[]];
If[!ValueQ[sim],Print[" No simplification helper rules defined"];sim={}];
If[!ValueQ[antisim],Print["No antisims"];antisim={}];


var=x/@{0,1,2,3};
vary=var/.x->y;


SF=StringForm;
OF=OutputForm;
IF=InputForm;
TF=TraditionalForm;
SB=Subscript;
SPB=Subsuperscript;
SPS=Superscript;
FS=FullSimplify;
EA=ExpandAll;



(* ------------------------- BEAUTY ----------------------------*)

If[!ValueQ[subscribed],subscribed={a,b,c,t,u,l,fi,A,F,Fx}];
If[!ValueQ[superscribed],superscribed={y,Fup,J,Jx}];
If[!ValueQ[grecletter],grecletter={al,be,ga,de,ka,ep,la,mu,nu,ro,si,k,A,B}];


grecletter=DeleteCases[grecletter,jt_Integer];	(* a piece of "POLUNDRA" from june 2017 *)

(* 'stf' is a diff. indexes with a comma, ssf is a funct. indexes *)

stf[xt_]:= Block[{a,i,k,st}, st=","; a=List @@ xt[[0,0]]; Do[st=st <> ToString @ xt[[i,1]],{i,Length[a]},{k,a[[i]]}]; st];				(* 08.02.2024 *)
ssf[xt_]:=StringJoin @@ ToString /@ xt[[0,1]];

FoF[xx_, yy_] := Block[{}, If[!ValueQ[xx],Format[xx] := yy//yoyo; Format[xx, TeXForm] := yy]];

Format[ppp:Derivative[__][(yt_/;MemberQ[subscribed,yt])[__]][__]] := SB[yt, ssf[ppp] <> stf[ppp]];										(* 09.04.2024 *)
Format[ppp:Derivative[__][(yt_/;MemberQ[subscribed,yt])[__]][__], TeXForm] := SB[yt, ssf[ppp] <> stf[ppp]];
Format[ppp:Derivative[__][(yt_/;MemberQ[superscribed,yt])[__]][__]] := SPB[yt, ssf[ppp] <> stf[ppp]];
Format[ppp:Derivative[__][(yt_/;MemberQ[superscribed,yt])[__]][__], TeXForm] := SPB[yt, ssf[ppp] <> stf[ppp]];

wpq={

Sum[it__[k]jt__[k], {k, 3}] -> SB[it, "n"]SPS[jt, "n"],
G[2,3][xx__]jt__[2]jt__[3]  -> (SPS[G,"pq"]SB[jt,"p"]SB[jt,"q"] - G[2,2][xx]jt[2]^2 - G[3,3][xx]jt[3]^2)/2,
G[2,3]'[xx__]jt__[2]jt__[3] -> (SPS["G","pq"]' SB[jt,"p"]SB[jt,"q"] - G[2,2]'[xx]jt[2]^2 - G[3,3]'[xx]jt[3]^2)/2

(*Gdown[2,3]'[xx__]jt__[2]jt__[3] -> (SB["G","pq"]' SPS[jt,"p"]SPS[jt,"q"] - Gdown[2,2]'[xx]jt[2]^2 - Gdown[3,3]'[xx]jt[3]^2)/2,*)

};

w={};

FoF[ al[it_], SB[al,it]];
FoF[ la[it_], SB[la,it]];
FoF[ si[it_], SB[si,it]];
FoF[ fi[x[it_]], SB[fi,it]];


FoF[ G[it_,jt_][a_A b_A], SPB["G","S",SF[" ````",it,jt]]];
FoF[ G[it_,jt_][a_B b_B], SPB["G","D",SF[" ````",it,jt]]];
FoF[ G[it_,jt_][_xS], SPB["G","S",SF[" ````",it,jt]]];
FoF[ G[it_,jt_][_xD], SPB["G","D",SF[" ````",it,jt]]];
FoF[ G[it_,jt_]@__  , SPS["G",SF["````",it,jt]]];
FoF[ Gdown[it_,jt_]@__, SB["G",SF["````",it,jt]]];
FoF[ gdown[it_,jt_]@__, SB["g",SF["````",it,jt]]];
FoF[ g[it_,jt_]@__ , SB["g",SF["````",it,jt]]];
FoF[ GG @_xS, SB["G","S"]];
FoF[ GG @_xD, SB["G","D"]];
FoF[ GG @__, "G"];
FoF[ g @__ , "g"];
FoF[ x @it_, SPS["x",it]];
FoF[ dddx @it_, SPS["dx",it]];
FoF[ y @it_, SPS["y",it]];
FoF[ xS @it_, SPB["x","S",SF[" ``",it]]];
FoF[ yS @it_, SPB["y","S",SF[" ``",it]]];
FoF[ xD @it_, SPB["x","D",SF[" ``",it]]];

FoF[ A[it_]@@var, SB["A",it]];
FoF[ SB[A,it_]@@var, SB["A",it]];
FoF[ F[it_,jt_], SB["F",SF["````",it,jt]]];
FoF[ F[it_,jt_]@__, SB["F",SF["````",it,jt]]];
FoF[ Fx[it_,jt_]@__, SB["F",SF["````",it,jt]]];
FoF[ Fup[it_,jt_], SPS["F",SF["````",it,jt]]];
FoF[ Fup[it_,jt_]@__, SPS["F",SF["````",it,jt]]];
FoF[ J[it_]@__, SPS["J",it]];
FoF[ Jx[it_]@__, SPS["J",it]];
FoF[ Jprivil[it_], SPB["J","priv",it]];


(*Format[ Jsync[it_] ] = Format[Jsync[it_], TeXForm] = SPB["J","sync",it];*)
FoF[ Jsync[it_], SPB["J","sync",it]];

Unprotect[Abs, DiscreteDelta];													(* 09.04.2024 *)
FoF[ Abs[it__], SF["|``|",it]];
FoF[ DiscreteDelta,de];
Protect[Abs, DiscreteDelta];



Format[ it__'  @jt__ ] = Format[it__'  @jt__, TeXForm] = it[jt]';
Format[ it__'' @jt__ ] = Format[it__'' @jt__, TeXForm] = it[jt]'';
Format[ it__'''@jt__ ] = Format[it__'''@jt__, TeXForm] = it[jt]''';

FoF[GPQ,"Q"];
FoF[cc ,"c"];
FoF[ee ,"e"];
FoF[MM ,"m"];

FoF[al ,\[Alpha]];
FoF[be ,\[Beta]];
FoF[ga ,\[Gamma]];
FoF[de ,\[Delta]];
FoF[ep ,\[Epsilon]];
FoF[ka ,\[Kappa]];
FoF[la ,\[Lambda]];
FoF[La ,\[CapitalLambda]];
FoF[mu ,\[Mu]];
FoF[nu ,\[Nu]];
FoF[pi ,\[Pi]];
FoF[ro ,\[Rho]];
FoF[si ,\[Sigma]];
FoF[ta ,\[Tau]];
FoF[th ,\[Theta]];
FoF[fi ,\[Phi]];
FoF[Om ,\[Omega]];
FoF[Del,\[CapitalDelta]];




(*w1={ep^2->1,1/ep->ep};   w1=DeleteCases[w1,jt_Integer->it_];  (* short epsylon-operations *)*)


(*============================= PREAMBLES =================================================*)

texPreamble:=Block[{},

	OF["\\documentclass{report}				"]>>texoutput.tex;
	OF["\\usepackage[russian]{babel}       	"]>>>texoutput.tex;
	OF["\\usepackage[utf8]{inputenc}       	"]>>>texoutput.tex;
	OF["\\usepackage{amssymb}              	"]>>>texoutput.tex;
	OF["%\\usepackage{amsmath}             	"]>>>texoutput.tex;
	OF["\\usepackage{xcolor}               	"]>>>texoutput.tex;
	OF["\\topmargin=-1.0cm                 	"]>>>texoutput.tex;
	OF["\\oddsidemargin=-0.5cm             	"]>>>texoutput.tex;
	OF["\\textheight=24 truecm             	"]>>>texoutput.tex;
	OF["\\textwidth=174 truemm             	"]>>>texoutput.tex;
	OF["\\def\baselinestretch{1.2}         	"]>>>texoutput.tex;
	OF["\\newcommand{\bb}{\begin{equation}}	"]>>>texoutput.tex;
	OF["\\newcommand{\ee}{\end{equation}}  	"]>>>texoutput.tex;
	OF["\\newcommand{\Mfunction}{}		    "]>>>texoutput.tex;
	OF["\\newcommand{\Mvariable}{}    		"]>>>texoutput.tex;


	OF["\begin{document}"]>>>texoutput.tex;

	OF["(* \n
		Definitions: \n\n
		'jacobi' - an element of the Jacoby matrix,\n
		'backjacobi' - an element of the backward Jacoby matrix,\n
		'gcovar' - a component of covariant metric tensor in syncron CS,\n
		'gcontr' - a component of contravariant metric tensor in syncron CS,\n
		'cc'- light velocity, \n
		'ka' - gravitational const, \n
		'La' - cosmological const, \n
		'pi' - number Pi, \n
		'F' - electromagnetic field tensor, \n
		'J' - current, \n
		'T' - stress tensor,\n
		'maxw' - 2-pair Maxwell eq-n, \n
		'Ein' - Einstein eq-n \n
	*)"]>>mathoutput;
	OF[""]>>>mathoutput;

];

texPreamble;

(*============================= OUTPUT FUNCTIONS =================================================*)

SetAttributes[varPrint, HoldAll];
varPrint[xx__]:=Block[{}, SetAttributes[Print, HoldAll]; Print["variable: ",xx]; ClearAttributes[Print, HoldAll]];

texPrint[prefix_,expression_,suffix_]:=Block[{},

	If[Notex=!=1,
		OF["\\bb"]>>>texoutput.tex;
		If[prefix =!= "",prefix//.w//TeXForm>>>texoutput.tex];
		expression//TeXForm>>>texoutput.tex;
		If[suffix =!= "",suffix//.w//TeXForm>>>texoutput.tex];
		If[ValueQ[equationLabel],OF[SF["\\label{``}",equationLabel]]>>>texoutput.tex;equationLabel=.];
		OF["\\ee"]>>>texoutput.tex;
	];
];

SlashRemoover[xx_]:=If[xx[[0]]===String,StringReplace[xx,{"\\"->""}],xx];

texHeadPrint[header_]:=Block[{},

	Print[];
	Print["-----",SlashRemoover[header]//yoyo,"------"];
	header//TeXForm>>>texoutput.tex;
	OF[SF["(* ---- `` ----*)",header]]>>>mathoutput;
];

(* !!! for lists beginned at 1 *)	(* syntax example: 'expr, " = 0", FS' - 2-th must be a string, 3-th - action like FS, EA, TF etc. *)

SetAttributes[texListPrint, HoldAll];
texListPrint[list_,epiplya___String,actioplya___Symbol(*,saveplya___Integer*)]:=Block[{},varPrint[list];	texMatrixPrint[list,epiplya,actioplya(*,saveplya*)]];

(* !!! for cycling 'Do' usage! without 'varPrint' !!! *)

texMatrixPrint[list_,epiplya___String,actioplya___Symbol(*,saveplya___Integer*)]:=Block[{},

	If[ValueQ[prolog],prolog=SequenceForm[prolog, " = "],prolog=""];
	If[epiplya[[0]]===0,epilog="",epilog=epiplya];
	If[actioplya[[0]]===0,action=Identity,action=actioplya];
	If[list[[0]]===List,
		Do[Print[i,".   ",list[[i]]//.w//yoyo//action,epilog];             texPrint["",list[[i]]//.w//action,epilog],{i,Length[list]}],
		Print[SlashRemoover[prolog],list//.w//yoyo//action,SlashRemoover[epilog]];  texPrint[prolog,list//.w//action,epilog]
	];
	(*If[saveplya[[0]]===Integer,Save["mathoutput",list]]; (*<- this must be improoved !! *)
	Print["saveplya = ",saveplya];*)
	Clear[Notex,prolog,epilog,action];
];

(* !!! this function acts in a cycle with 'i,j' only !!! *)

texPrintingTensorIJ[tensor_,texstring_,mathstring_]:=Block[{},		(* for tensors 2 range only *)
		(* *)	Print[i,j,".    ",tensor[i,j]//.w//yoyo];
		(* *)	OF["\\bb"]>>>texoutput.tex;
		(* *)	OF[SF[texstring,i,j]]>>>texoutput.tex;
		(* *)	tensor[i,j]//.w//TeXForm>>>texoutput.tex;
		(* *)	OF["\\ee"]>>>texoutput.tex;
		(* *)
		(* *)	OF[SF[mathstring,i,j]]>>>mathoutput;
		(* *)	tensor[i,j]>>>mathoutput;
		(* *)	OF[""]>>>mathoutput;
];

(*-------------------  standard 2024 (no n, no w1)      --------------------------*)

OF[" \\section{Metric and equations of motion in privileged CS}"]>>>texoutput.tex;

texHeadPrint[" Recent metric in privileged CS "];

If[ValueQ[ddelt] && ddelt=!=1,
	VG1=VG ddelt//Simplify; Print[1/ddelt//.w,"  ",VG1//.w//MatrixForm]; VG1=.,
	Print[SPS["g","ij"]," = ",VG/.sim//.w//MatrixForm];
	OF["\\bb g^{ij}\\ =\\ \\left("]>>>texoutput.tex;
	VG/.sim//.w//MatrixForm//TeXForm>>>texoutput.tex;
	OF["\\right) \\ee"]>>>texoutput.tex;];
vdet=(Det[VG]//FS); Print["Det|",SPS["g","ij"],"| = ",vdet//.w//yoyo," ",SF["\[Congruent]"]," ",vdet/.sim//.w//yoyo," < 0"];
ddet=1/vdet;

prolog=SequenceForm["\\det ", SB["g", "ij"]];
texListPrint[ddet," = g < 0"];

sqrtddet=(Sqrt[-ddet]//FS)/.sim; Print[Sqrt[-g]," = ",sqrtddet//.w//yoyo];

NG=(Inverse[VG]//FS)/.sim; Print[SB["g","ij"]," = ",NG//.w];

Do[ng[i,j]=NG[[i+1,j+1]],{i,0,3},{j,0,3}];
Do[vg[i,j]=VG[[i+1,j+1]],{i,0,3},{j,0,3}];

dssquare=Sum[ng[i,j]dddx[i]dddx[j],{i,0,3},{j,0,3}]~Collect~g[_];
	OF["\\bb ds^2\\ =\\ "]>>>texoutput.tex;
	dssquare//TeXForm>>>texoutput.tex;
	OF["\\ee"]>>>texoutput.tex;


standart:=Block[{},

	Do[G[i,j,k]=Sum[vg[k,m](D[ng[i,m],x[j]]+D[ng[j,m],x[i]]-D[ng[i,j],x[m]])/2,{m,0,3}]//FS;
		(*If[G[i,j,k]=!=0,Print[Subsuperscript[\[CapitalGamma],SF["````",i,j],SF["  ``",k]],"  =  ",G[i,j,k]/.w];];*)
		G[j,i,k]=G[i,j,k],{i,0,3},{j,i,3},{k,0,3}];

	Do[R[i,k]=Sum[D[G[i,k,j],x[j]]-D[G[i,j,j],x[k]]+Sum[G[i,k,j]*G[j,m,m],{m,0,3}]-Sum[G[i,j,m]*G[k,m,j],{m,0,3}],{j,0,3}]//EA//Simplify;
		(*Print[SB[R,SF["````",i,k]],"  =  ",R[i,k]//.w];*)
		,{i,0,3},{k,i,3}];
	Do[R[k,i]=R[i,k],{i,0,2},{k,i+1,3}];

	RR=Sum[vg[k,m]R[k,m],{k,0,3},{m,0,3}]//Expand//Simplify;
];


(*============================= MAIN =================================================*)




(* ------- maxw 1 pair test ---------------- *)
(* !!! not in general form *)

maxw1t:=Block[{},
	Print["-------- maxwell 1 test -------------"];

	Do[maxw1[i,k,l]=D[F[i,k]@@var,x[l]]+D[F[l,i]@@var,x[k]]+D[F[k,l]@@var,x[i]]//FS;
	If[maxw1[i,k,l]=!=0,
		Print[i,k,l,"    ",maxw1[i,k,l]//.w];
		"\bb">>>texoutput.tex;
		maxw1[i,k,l]//.w//TeXForm>>>texoutput.tex;
		"=0\ee">>>texoutput.tex;];
	,{i,0,1},{k,1,2},{l,2,3}];

];

(* 1. F - an arbitrary antisymmetric tensor, low indexes! *)

MaxwEqPrivilegedCS:=Block[{},

	runMaxwEqPrivilegedCS=1;

	Clear[maxwF, maxwA];

	(* F is defined in the datafile *)

	Do[F/:F[i,i]@@var=0,{i,0,3}];
	Do[F/:F[j,i]@@var=-F[i,j]@@var,{i,0,3},{j,i+1,3}];
	Do[FupF[i,k]=Sum[F[l,m]@@var vg[i,l] vg[m,k],{l,0,3},{m,0,3}],  {i,0,3},{k,0,3}];
	Do[FupA[i,k]=Sum[(D[A[m]@@var,x[l]]-D[A[l]@@var,x[m]]) vg[i,l] vg[m,k],{l,0,3},{m,0,3}],  {i,0,3},{k,0,3}];

	Max2[Fup_,maxw_]:=Block[{},
		maxw=Table[Numerator[  Sum[D[sqrtddet Fup[i,j],x[j]],{j,0,3}]+sqrtddet J[i]@@var//FS ]/.sim//FS,	{i,0,3}];
		texListPrint[maxw," = 0"]
	];

	(* An example of usage: *)

	texHeadPrint[" 2 pair of Maxwell eq-ns with F in Priv. CS "];
	Max2[FupF,maxwF];

	texHeadPrint[" 2 pair of Maxwell eq-ns with A in Priv. CS "];
	Max2[FupA,maxwA];

];

ChargeConservPrivilegedCSTesting:=Block[{}, (* - it must lead to identity! - *)

	Do[F/:F[i,i]@@var=0,{i,0,3}];
	Do[F/:F[j,i]@@var=-F[i,j]@@var,{i,0,3},{j,i+1,3}];
	Do[FupF[i,k]=Sum[vg[i,l]vg[m,k]F[l,m]@@var,{l,0,3},{m,0,3}],  {i,0,3},{k,0,3}];
	Do[FupA[i,k]=Sum[(D[A[m]@@var,x[l]]-D[A[l]@@var,x[m]]) vg[i,l] vg[m,k],{l,0,3},{m,0,3}],  {i,0,3},{k,0,3}];

	texHeadPrint[" Char. conserv. with covar. F "];
	ccl=Sum[D[sqrtddet FupF[i,k],x[i],x[k]],{i,0,3},{k,0,3}]//FS;
	texListPrint[ccl," = 0"];

	texHeadPrint[" Char. conserv. with potential A "];
	ccl=Sum[D[sqrtddet FupA[i,k],x[i],x[k]],{i,0,3},{k,0,3}]//FS;
	texListPrint[ccl," = 0"];

];

ChargeConservPrivilegedCS:=Block[{},

	texHeadPrint[" Char. conserv. with contravar. J in Priv. CS "];
	ccl=Sum[D[sqrtddet J[i]@@var,x[i]],{i,0,3}]//FS;
	texListPrint[ccl," = 0"];
];



(* 2. --------- Action & Eikonal in Priv. CS ---------- *)


HamJac:=Block[{},

	runHamJac=1;

	texHeadPrint[" Action general form "];
	SS=fi[x[0]]+la[1]x[1]+la[2]x[2]+la[3]x[3];
	prolog="S";
	texListPrint[SS/.wpq,",\\ \\ \\ \\ n = 1,2,3."];

	texHeadPrint[" Hamilton-Jacoby Eq-n in recent metric "];
	hamjac=Sum[vg[i,j]D[SS,x[i]]D[SS,x[j]],{i,0,3},{j,0,3}]-MM^2/.sim;
	texListPrint[hamjac/.wpq," = 0,\\ \\ \\ \\ p,q = 2,3,"];

	texHeadPrint[" thus, "];
	solvhamjac=Solve[hamjac==0,fi'[x[0]]][[1,1]]//FS//EA;
	(*texListPrint[solvhamjac,FS];*)

	dsolvhamjac=Integrate[solvhamjac[[2]],x[0]]//FS;
	prolog = SB[\[Phi], 0];
	texListPrint[dsolvhamjac/.wpq,","];

	SS=dsolvhamjac+la[1]x[1]+la[2]x[2]+la[3]x[3];
	prolog="S";
	texListPrint[SS//.wpq,"."];

];

MotionEq:=Block[{},

	If[runHamJac=!=1,HamJac];
	runMotionEq=1;

	texHeadPrint[" Equations of motion "];
	moteq=Table[D[SS,la[k]]-si[k]==0,{k,3}];
	texListPrint[moteq/.wpq,EA];

	(*texHeadPrint[" Massive particle traectories (solutions of motion eq-ns relative x) "];*)
	solvmoteq=Solve[moteq,x/@{1,2,3}][[1]]//FS;
	(*texListPrint[solvmoteq,EA];*)
];

Eikonal:=Block[{},

	If[runMotionEq=!=1,MotionEq];
	runEikonal=1;

	texHeadPrint[" Eikonal "];
	psi=SS/.MM->0/.la->ka(*/.ka[1]->1*);
	prolog = \[CapitalPsi];
	texListPrint[psi];

	texHeadPrint[" Massless particle traectories "];
	eikon=moteq/.MM->0/.la->ka/.si->ga/.ka[1]->1//FS;
	texListPrint[eikon,EA];

];


TwoArbitraryPoints:=Block[{},

	If[runEikonal=!=1,Eikonal];
	runTwoArbitraryPoints=1;

	texHeadPrint[" Eikonal eq-n with 2 arbitrary points: S & D \\\\"]; (* S - source *)

	texHeadPrint[" Eikonal eq. for S"];
	RadTraectoryA=eikon/.x->xS;
	texListPrint[RadTraectoryA,FS];

	texHeadPrint[" It`s solution relative gammas"];
	s1=Solve[RadTraectoryA,ga/@{1,2,3}][[1]];
	texListPrint[s1,EA];

	texHeadPrint[" Subst. it to Eeq for D"];
	RadTraectoryB=(eikon/.x->xD/.s1//FS)~Collect~ka[_];
	texListPrint[RadTraectoryB];

	texHeadPrint[" It`s solution relative k-s"];
	s2=Solve[{RadTraectoryB[[2]],RadTraectoryB[[3]]},k/@{2,3}][[1]]//Simplify;
	texListPrint[s2];

	texHeadPrint[" Relation (retarding) btw S & D FULL (without simplifying definitions)"];
	eqqF=(Numerator[RadTraectoryB[[1,1]]-RadTraectoryB[[1,2]]/.s2//Simplify]//.sim//FS)~Collect~(xD[_]-xS[_])/.antisim//FS; 			(* comment: 'tric' with '/.sim' & '/.antisim' is needed for primary calculation *)
	texListPrint[eqqF," = 0"];


	OF[""]>>ff;				(* <- new cool experimental feature to manipulate of files, function 'Save["file",expr]', 29.02.2024 *)
							(* empty file 'ff' will be created, non-empty file 'ff' will be cleaned *)


	(* attempt to introduce some optional simplifications *)

	(* this is actual for '30general_diff' only! *)

	If[dataFileName == "30general_diff",

		texHeadPrint[" Let us introduce some simplifications\\\\"];

		Format[delG[it_,jt_]] = Format[delG[it_,jt_], TeXForm] = SPS[SF["````",\[CapitalDelta],"G"],SF["````",it,jt]];
		Format[delX[it_]] = Format[delX[it_], TeXForm] = SPS[SF["````",\[CapitalDelta],"x"],it];
		Format[delGdown[it_,jt_]] = Format[delGdown[it_,jt_], TeXForm] = SB[SF["````",\[CapitalDelta],"G"],SF["````",it,jt]];
		Format[delGG] = Format[delGG, TeXForm] = SF["````",\[CapitalDelta],"G"];


		simOptional1:={
					G[it_,jt_][xS[at_]]->delG[it,jt]+G[it,jt][xD[at]],			(* don't mix! *)
					xS[it_]->delX[it]+xD[it]
					};
			Print[simOptional1];											(* we can't place it to 'texListPrint' *)

			OF["\bb"]>>>texoutput.tex;											(* stupid lowlevel tex output for 'simOptional1' *)
			delG[p,q]//TeXForm>>>texoutput.tex;
			OF[" = "]>>>texoutput.tex;
			G[p,q][xS[0]]-G[p,q][xD[0]]//TeXForm>>>texoutput.tex;
			OF[",\\ \\ \\ \\ "]>>>texoutput.tex;
			delX[p]//TeXForm>>>texoutput.tex;
			OF[" = "]>>>texoutput.tex;
			xS[p]-xD[p]//TeXForm>>>texoutput.tex;
			OF[",\ee"]>>>texoutput.tex;

			Save["mathoutput",simOptional1];

		texHeadPrint[" so, "];
		eqqSim1=eqqF/.simOptional1;
		texListPrint[eqqSim1," = 0"];		Save["mathoutput",eqqSim1];

		texHeadPrint[" Still one definition "];
		simOptional2:={
					delG[2,3]^(jt_Integer /; Positive[jt])->(-delGG+delG[2,2]delG[3,3]) delG[2,3]^(jt-2),				(* don't mix! *)
					delG[3,3]->delGdown[2,2]delGG,delG[2,3]->-delGdown[2,3]delGG,delG[2,2]->delGdown[3,3]delGG
					};
			Print[simOptional2];											(* we can't place it to 'texListPrint' *)

			OF["\bb"]>>>texoutput.tex;											(* stupid lowlevel tex output for 'simOptional1' *)
			delGdown[p,q]//TeXForm>>>texoutput.tex;
			OF[" = \left["]>>>texoutput.tex;
			delG[p,q]//TeXForm>>>texoutput.tex;
			OF["\\right]^{-1}"]>>>texoutput.tex;
			OF[",\ee"]>>>texoutput.tex;

			Save["mathoutput",simOptional2];

		texHeadPrint[" so, "];
		eqqSim2=eqqSim1/delGG//.simOptional2//EA;
		texListPrint[eqqSim2," = 0,"];		Save["mathoutput",eqqSim2];

		texHeadPrint[" or most compact "];
		ww00qq=G[2, 3]'[at__]jt__[2]jt__[3] -> (SPS["G'","pq"]SB[jt,"p"]SB[jt,"q"] - G[2, 2]'[at]jt[2]^2 - G[3, 3]'[at]jt[3]^2)/2;
		simOptional3:={it__[2, 3]jt__[2]jt__[3] -> (it["p", "q"]jt["p"]jt["q"] - it[2, 2]jt[2]^2 - it[3, 3]jt[3]^2)/2};
		eqqSim3=eqqSim2/.simOptional3//FS;
		texListPrint[eqqSim3," = 0."];		Save["mathoutput",eqqSim3];

		texHeadPrint[" Constans k with this terminology "];
		s2sim=s2/.simOptional1//FS;
		s2sim=s2sim//.simOptional2//FS;
		texListPrint[s2sim];		Save["mathoutput","s2sim"];					(* <- "s2sim" is a perspective form of argument 'as string' for 'Save' optinon of 'texListPrint' *)

	]; (* <- end if *)


];



TwoArbitraryPointsSim:=Block[{},  (* ---------------- this is needed for data file '30' only, with 'Sin[th]' & 'Cos[th]' ------------ *)

	If[runTwoArbitraryPoints=!=1,TwoArbitraryPoints];
	runTwoArbitraryPointsSim=1;

	texHeadPrint[" Attempt to simplification in FULL"];


	RadTraectoryASim=RadTraectoryA/.antisim/.A[0]->A[0]^(1/Sin[th])//PowerExpand;
	Print["Eikonal eq. for A:         "//yoyo,RadTraectoryASim//.w//yoyo];texPrint["Eikonal eq. for A:         ",RadTraectoryASim//.w,""];

	s1Sim=s1/.antisim/.A[0]->A[0]^(1/Sin[th])//PowerExpand;
	Print["It`s solution:             "//yoyo,s1Sim//.w//yoyo];texPrint["It`s solution:             ",s1Sim//.w,""];

	RadTraectoryBSim=RadTraectoryB/.antisim/.A[0]->A[0]^(1/Sin[th])/.B[0]->B[0]^(1/Sin[th])//PowerExpand;
	Print["Subst. it to Eeq for B:    "//yoyo,RadTraectoryBSim//.w//yoyo];texPrint["Subst. it to Eeq for B:    ",RadTraectoryBSim//.w,""];

	s2Sim=s2/.antisim/.A[0]->A[0]^(1/Sin[th])/.B[0]->B[0]^(1/Sin[th])//PowerExpand;
	s2Sim=(s2Sim/.Csc[th]->xyxy//Simplify)/.xyxy->Csc[th];
	Print["It`s solution:             "//yoyo,s2Sim//.w//yoyo];texPrint["It`s solution:             ",s2Sim//.w,""];

	eqqSim=eqq/.antisim/.A[0]->A[0]^(1/Sin[th])/.B[0]->B[0]^(1/Sin[th])//PowerExpand;
	eqqSim=(eqqSim/.Csc[th]->xyxy//Simplify)/.xyxy->Csc[th];
	Print["Relation btw A & B:        "//yoyo,eqqSim//.w//yoyo];texPrint["Relation btw A & B:        ",eqqSim//.w,""];

];



(* 3. --------- Synchron Coordinates ---------- *)

Trans:=Block[{},

	If[runMotionEq=!=1,MotionEq];
	runTrans=1;

	OF[" \\section{Synchronous CS}"]>>>texoutput.tex;

	Print[];
	Print[];
	Print["=========================== Metric Tensor Priv. to Synchr. CS Transition ==============================================="//yoyo];

	texHeadPrint[" Privileged to Synchron CS transformation rules "];
	trans[0]=x[0]->y[1] y[0];
	Do[trans[k]=Solve[moteq[[k]]/.{MM->1,trans[0],la->y,si[k]->0},x[k]][[1,1]]//FS,{k,3}];
	TransToSync=trans/@{0,1,2,3};
	texListPrint[TransToSync/.wpq];

	texHeadPrint[" Jacoby matrix "];
	varPrint[jacobian];
	Do[
		jacobian[i,j]=D[trans[i][[2]],y[j]]//FS;
		jacobianDisplay[i,j]=(jacobian[i,j]~Collect~y[_])//.w/.wpq//FS;
		texPrintingTensorIJ[jacobianDisplay, "\\frac{\\partial  x^``}{\\partial y^``} = ", "jacobi[``,``] := "]
	,{i,0,3},{j,0,3}];
	Clear[jacobianDisplay];
];

SyncMetric:=Block[{},

	If[runTrans=!=1,Trans];
	runSyncMetric=1;

	(* Trere are 2 methods for synchr. metric:
		1) 'ngsync0' - by direct calculation;
		2) 'ngsync' - by hands, it placed in data file.
		Finally, we must use 'ngsync' only. So, we use 'TrueTest' for comparision of them.
	*)

	Print[" ATTENTION! Direct calculations! "];
	texHeadPrint[" Metric in syncr. CS "];

	pip[it_]:=((it//EA)/.sim//EA)/.simOptForGij//FS;
	varPrint[ngsync];
	Do[
		ngsync0[i,j]=Sum[ng[l,k] jacobian[l,i] jacobian[k,j]/.trans[0],{l,0,3},{k,0,3}]//FS;
		ngsync0[i,j]=FixedPoint[pip,ngsync0[i,j]]; 												(* temporary!!! *)
		prolog=SB["g",SF["````",i,j]];
		texMatrixPrint[EA[ngsync0[i,j]]//.wpq,FS];
	,{i,0,3},{j,i,3}];
	Do[ngsync0[j,i]=ngsync0[i,j],{i,0,3},{j,i+1,3}];

	texHeadPrint[" We can introduce a definition "];
			Notex=1;texListPrint[{simLowG}];

			OF["\bb"]>>>texoutput.tex;											(* stupid lowlevel tex output for 'simOptional1' *)
			Gdown[p,q]@_//TeXForm>>>texoutput.tex;
			OF[" = \left["]>>>texoutput.tex;
			G[p,q]@_//TeXForm>>>texoutput.tex;
			OF["\\right]^{-1}"]>>>texoutput.tex;
			OF[",\ee"]>>>texoutput.tex;

	texHeadPrint[" so, "];
	varPrint[ngsyncLowG];
	Do[ngsyncLowG[i,j]=ngsync0[i,j]/.simLowG//FS;
		prolog=SB["g",SF["````",i,j]];
		texMatrixPrint[EA[ngsyncLowG[i,j]],FS];
	,{i,0,3},{j,i,3}];

	(* !!! perspective simplification: introduction of g_down *)
	(*
	texHeadPrint[" Or, with still one definition "];
			texMarixPrint[simLowg];

	texHeadPrint[" so, "];

	Do[
		ngsyncLowg[i,j]=EA[ngsync0[i,j]]/.simLowg//FS;
		prolog=SB["g",SF["````",i,j]];
		texMatrixPrint[EA[ngsyncLowg[i,j]],FS];

	,{i,0,3},{j,i,3}];
	*)


	texHeadPrint[" Contravariant metric tensor in syncr CS "];
	varPrint[vgsync];
	NGsync=Table[ngsync0[i-1,j-1],{i,4},{j,4}];
	VGsync=Inverse[NGsync]//FS;
	Do[
		vgsync0[i,j]=VGsync[[i+1,j+1]];
		vgsync0[i,j]=FixedPoint[pip,vgsync0[i,j]]/.ass/.simOptForGij//FS; 						(* temporary!!! *)
		prolog=SPS["g",SF["````",i,j]];
		texMatrixPrint[EA[vgsync0[i,j]],FS];
	,{i,0,3},{j,i,3}];
	Do[vgsync0[j,i]=vgsync0[i,j],{i,0,3},{j,i+1,3}];


	texHeadPrint[" or, with low-indexed funtions G, "];
	varPrint[vgsyncLowG];
	Do[vgsyncLowG[i,j]=vgsync0[i,j]/.simLowG//FS;
		prolog=SPS["g",SF["````",i,j]];
		texMatrixPrint[EA[vgsyncLowG[i,j]],FS];
	,{i,0,3},{j,i,3}];

	(* !!! this is the result of accurate optimisation of directly calculates metrics !!! *)

	Do[ngsync[i,j]=ngsync0[i,j];vgsync[i,j]=vgsync0[i,j],{i,0,3},{j,0,3}];



	(* this method is not needed now, but we must remember about *)

	(* HandMadeVSDirectlyCalculatedMetricsComparision; *)


	texHeadPrint[" Det of cov. metric tensor in Synch. CS "];
	d0=Det[NGsync]/.ass//FS;  d0=d0/.sim;
	prolog = SB["g","sync"];
	texListPrint[d0];


	Print[" Sqrt From Det of metric tensor in Synch. CS"];
	d2=Simplify[Sqrt[-d0],{GG[y[0] y[1]]>0,y[0]>0,y[1]>0}] ; Print[Sqrt[-g]," = ",d2//.w//yoyo];
	(*d2=Simplify[Sqrt[-d0],{Element[GG[y[0] y[1]], Reals], Element[y[0], Reals], Element[y[1], Reals]}] ; Print[Sqrt[-g]," = ",d2//.w//yoyo]; *)


	(* ----- back trans -----*)



	If[ValueQ[BackJacobianWrittenByHands],
		texHeadPrint[" Backward transformation from Sync. to Priv. CS \\\\ "];
		BackJacobianWrittenByHands; (* from '30general_diff' at 11.01.2024 *)


		(*
		If[runBackJacobianWrittenByHands===1,
			Print[" Backward Transformation Jacobyan is simplified by hands, see input data file "];
			TrueTest=(Table[backjacobian[i,j]==backjacobian0[i,j]/.ass/.antisim//FS,{i,0,3},{j,0,3}]//Flatten)~DeleteCases~True;
			If[
				TrueTest=={},Print[" Simplified Backward Transformation Jacobyan is the same as the directly calculated "],
				Print[" Attention! Some difference between hand-made & directly calculated Jacobyans is obtained! "]; Print[TrueTest//.w]
			],
			Print[" Backward Transformation Jacobyan is directly calculated "];
			Do[backjacobian[i,j]=backjacobian0[i,j],{i,0,3},{j,0,3}]
		];
		*)



		texHeadPrint[" Jacoby matrix of backward transform. "];
		Print[" (written by hands) "];
		varPrint[backjacobian];
		Do[
			texPrintingTensorIJ[backjacobian, "\\frac{\\partial  y^``}{\\partial x^``} = ", "backjacobi[``,``] := "]
		,{i,0,3},{j,0,3}];
	];


];



MaxwEqSynchronCS:=Block[{},					(* an old shit *)

	If[runSyncMetric=!=1,SyncMetric];
	runMaxwEqSynchronCS=1;

	Print[];
	Print[];
	Print["=========================== Maxw. Eq. Priv. to Synchr. CS Transition ==============================================="//yoyo];

	wwwtrrans=(qq__ @@ var /. TransToSync) -> qq @@ var;
	blantigpq=GPQ->y[0]/y[1];

	Print[" F synchr. 'F' is F(y) "];
	Do[F/:F[i,j]@@vary=Sum[F[l,k]@@var jacobian[l,i] jacobian[k,j],{l,0,3},{k,0,3}]/.F->Fx/.TransToSync//FS;
		Print[SB[OverTilde[F],SF["````",i,j]]," =  ",F[i,j]@@vary//.w]
	,{i,0,3},{j,i+1,3}];
	Print[" J synchr. 'J' is J(y) "];
	Do[J/:J[i]@@vary=(Sum[J[j]@@var backjacobian[i,j],{j,0,3}]/.J->Jx/.TransToSync/.blantigpq//FS//PowerExpand)//.sim//FS;
		Print[SB[OverTilde[J],SF["``",i]]," =  ",J[i]@@vary//.w]
	,{i,0,3}];


	Do[F/:F[i,i]@@vary=0,{i,0,3}];
	Do[F/:F[j,i]@@vary=-F[i,j]@@vary,{i,0,3},{j,i+1,3}];
	Do[FupF[i,k]=Sum[F[l,m]@@vary vgsync[i,l] vgsync[m,k],{l,0,3},{m,0,3}],  {i,0,3},{k,0,3}];

	Max2[Fup_,maxw_]:=Block[{},
		Do[
			maxw[i]=Sum[D[d2 Fup[i,j],y[j]],{j,0,3}]+d2 J[i]@@vary;
			maxw[i]=Numerator[maxw[i]/.sim//Simplify];
			maxw[i]=maxw[i]/.sim//Simplify;
			Print[i,".   ",maxw[i]/.wwwtrrans//.w//yoyo," = 0"]; texPrint["",maxw[i]//.w," = 0"],
		{i,0,3}];
	];

	texHeadPrint[" 2 pair of Maxwell eq-ns with F in Synchr. CS "];

	Max2[FupF,maxwF];

			Print[];
			Print[" --------------- Calculus -----------------------"];
			Print[];
			yohoho=antigpq[[1]] /. z -> x[0] /. trrans /. antisim // FS;
			Print[" ATTENTION! We must consieder this condition:  ",yohoho//.w,"            (1)"];
			Print[];
			Print[];
			s1 = Solve[maxwF[0] == 0 /. wwwtrrans, D[Fx[0, 2] @@ var, x[2]]][[1, 1]] /. ass // FS;
			s11=s1//.sim//FS; Print["from Maxw(0):    ",s11 //. w];
			t2 = maxwF[2] /. wwwtrrans /. s1 /. ass // FS; Print["Maxw(2):    0 = ",t2 //. w];
			t3 = -maxwF[3] /. wwwtrrans /. s1 /. ass // FS; Print["Maxw(3):    0 = ",t3 //. w];
			Print[];
			Print["therefore:"];
			ss = Solve[{t2 == 0, t3 == 0}, {Jx[2] @@ var, Jx[3] @@ var}][[1]] // FS; Print[ss //. w];
			Print["or"];
			tt = Solve[{t2 == 0, t3 == 0}, {D[Fx[0, 2] @@ var, x[1]],   D[Fx[0, 3] @@ var, x[1]]}][[1]] // FS; tt =   tt //. sim // FS; Print[tt //. w];
			Print["Substitute it to (1):"];
			s2 = s1 //. sim // FS;
			s4 = s2 /. ss // FS; Print[s4 //. w];
			Print["therefore:"];
			s5 = Solve[Equal @@ s4, Jx[1] @@ var][[1, 1]] // FS; Print[s5 //. w];
			Print["Finally:"];
			ss = {s5}~Join~ss; Print[ss //. w//yoyo];
			Print[];
			Print["The current:"];
			q0 = J[0] @@ vary /. wwwtrrans /. ss // FS; Print[SPS[OverTilde[J],0]," = ",q0 //. w];
			q1 = J[1] @@ vary /. wwwtrrans /. ss // FS; Print[SPS[OverTilde[J],1]," = ",q1 //. w];
			q2 = J[2] @@ vary /. wwwtrrans /. ss // FS; Print[SPS[OverTilde[J],2]," = ",q2 //. w];
			q3 = J[3] @@ vary /. wwwtrrans /. ss // FS; Print[SPS[OverTilde[J],3]," = ",q3 //. w];


	(*
	Do[ FA[i,j][y[0],y[1],y[2],y[3]]=D[A[i]@@vary,y[j]]-D[A[j]@@vary,y[i]],  {i,0,3},{j,0,3}];
	Do[FupA[i,k]=Sum[FA[l,m]@@vary vgsync[i,l] vgsync[m,k],{l,0,3},{m,0,3}],  {i,0,3},{k,0,3}];

	texHeadPrint[" 2 pair of Maxwell eq-ns with A in Synchr. CS "];

	Max2[FupA,maxwA];
	*)

	(*
	(* ------------------ simplification block ----------------- *)
	texHeadPrint[" Simplification "];
	Do[Print["------------- ", k, " --------------"];
    Do[co[i, j] = Coefficient[maxwA[k], D[A[i] @@ vary, y[j]]] // EA // FS;
      Print[i, j, ".    ", co[i, j] //. w // yoyo], {i, 0, 3}, {j, i + 1,  3}];
    co[k] = Coefficient[maxwA[k], J[k]] // FS;

    msim[k] = Sum[co[i, j](D[A[i] @@ vary, y[j]] - D[A[j] @@ vary, y[i]]), {i, 0, 3}, {j, i + 1, 3}] + co[k]J[k];
    Print[msim[k] //. w // yoyo];	texPrint["",msim[k]//.w," = 0"];
    Print["Verif:   ", maxwA[k] - msim[k] // EA // FS],
    {k, 0, 3}];
    *)

];

ChargeConservSynchronCS:=Block[{},

	If[runSyncMetric=!=1,SyncMetric];
	runChargeConservSynchronCS=1;

	texHeadPrint[" Char. conserv. with contravar. J in Synchr. CS "];

	ccl=(Sum[D[d3 J[i]@@vary,y[i]],{i,0,3}]//FS)/.antisim;
	texListPrint[ccl," = 0"];
];

DelayCorrespSynchronCS:=Block[{},

	If[runTrans=!=1,Trans];
	If[runTwoArbitraryPoints=!=1,TwoArbitraryPoints];
	runDelayCorrespSynchronCS=1;

	texHeadPrint[" Relation btw A & B in Synch. CS "];
	trA = Table[trans[i], {i, 0, 3}] /. x -> A /. y -> A;
	trB = Table[trans[i], {i, 0, 3}] /. x -> B /. y -> B;
	eqqS = eqq /. trA /. trB // FS;
	Print[eqqS//.w//yoyo];
	eqqSF=Numerator[eqqS]/.antisim;
	Print[" Full Form "];
	texListPrint[eqqSF," = 0"];
];


(* ------------ EXPERIMENTAL ----------------------*)

MaxwEqSynchronCSexperimental:=Block[{},

	(* goal: to simplify separated coefficients & assembly whole eq-n after it *)

	If[runSyncMetric=!=1,SyncMetric];
	runMaxwEqSynchronCS=1;

	Print[];
	Print[];
	Print["=========================== Experiment ==============================================="//yoyo];

	Clear[F];
	Do[F[i,i][y[0],y[1],y[2],y[3]]=0,{i,0,3}];
	Do[F[j,i][y[0],y[1],y[2],y[3]]=-F[i,j][y[0],y[1],y[2],y[3]],{i,0,3},{j,i+1,3}];
	Do[FupF[i,k]=Sum[F[l,m]@@vary vgsync[i,l] vgsync[m,k],{l,0,3},{m,0,3}],  {i,0,3},{k,0,3}];

	Max2[maxw_]:=Block[{},

		Print[" Coefficients at components of $F_{kl}$ in  Maxwell Eq. with index i "];

		Do[If[k=!=l,coefAtFkl[i,k,l]=Sum[vgsync[i,k]vgsync[j,l]D[Log[d2],y[j]],{j,0,3}]+
			Sum[D[vgsync[i,k],y[j]]vgsync[j,l],{j,0,3}]+vgsync[i,k]Sum[D[vgsync[j,l],y[j]],{j,0,3}]/.Log[y[0] y[1]]->L];
		,{i,0,3},{k,0,3},{l,0,3}];

		Do[coefAtFcoupled[i,k,l]=coefAtFkl[i,k,l]-coefAtFkl[i,l,k]//FS;
			coefAtFcoupled[i,k,l]=coefAtFcoupled[i,k,l]/.simplificationhelper//FS;
			Print[i," ",k,l,"      ",coefAtFcoupled[i,k,l]//.w//yoyo]
		,{i,0,3},{k,0,3},{l,k+1,3}];


		Print[" Coefficients at j-th derivatives of $F_{kl}$ in i-th Maxwell Eq. "];

		Do[If[k=!=l,coefAtDerivjFkl[i,k,j,l]=vgsync[i,k]vgsync[j,l]/.Log[y[0] y[1]]->L];
		,{i,0,3},{j,0,3},{k,0,3},{l,0,3}];

		Do[coefAtDerivFcoupled[i,k,j,l]=coefAtDerivjFkl[i,k,j,l]-coefAtDerivjFkl[i,l,j,k]//FS;
			coefAtDerivFcoupled[i,k,j,l]=coefAtDerivFcoupled[i,k,j,l]/.simplificationhelper//FS;
			Print[i," ",k,j,l,"      ",coefAtDerivFcoupled[i,k,j,l]//.w//yoyo]
		,{i,0,3},{k,0,3},{l,k+1,3},{j,0,3}];




		Do[maxw[i]=Sum[coefAtFcoupled[i,k,l]F[k,l]@@vary,{k,0,3},{l,k+1,3}] +
			Sum[(coefAtDerivFcoupled[i,k,j,l])D[F[k,l]@@vary,y[j]],{k,0,3},{l,k+1,3},{j,0,3}]+J[i];

			Print[i,".   ",maxw[i]//.w//yoyo," = 0"]; texPrint["",maxw[i]//.w," = 0"],
		{i,0,3}];
	];

	texHeadPrint[" 2 pair of Maxwell eq-ns with F in Synchr. CS "];

	Max2[maxwFexp];
		(*
	Do[ FA[i,j][y[0],y[1],y[2],y[3]]=D[A[i]@@vary,y[j]]-D[A[j]@@vary,y[i]],  {i,0,3},{j,0,3}];
	Do[FupA[i,k]=Sum[FA[l,m]@@vary vgsync[i,l] vgsync[m,k],{l,0,3},{m,0,3}],  {i,0,3},{k,0,3}];

	texHeadPrint[" 2 pair of Maxwell eq-ns with A in Synchr. CS "];

	Max2[FA,maxwAexp];
	*)
];


MaxwEqForFreeFallingSource:=Block[{},		(* new at 21.03.2024 *)

	If[runSyncMetric=!=1,SyncMetric];
	MaxwEqForFreeFallingSource=1;


	(* this is old velobike and it's blocked just now *)

	Do[F/:F[i,i]@@vary=0,{i,0,3}];
	Do[F/:F[j,i]@@vary=-F[i,j]@@vary,{i,0,3},{j,i+1,3}];
	Do[FupF[i,k]=Sum[F[l,m]@@vary vgsync[i,l] vgsync[m,k],{l,0,3},{m,0,3}],  {i,0,3},{k,0,3}];

	Max2[Fup_,maxw_]:=Block[{},
		Do[
			maxw[i]=Sum[D[d2 Fup[i,j],y[j]],{j,0,3}]+4 pi/cc d2 Jsync[i]//FS;
			maxw[i]=Numerator[maxw[i]/.sim//Simplify];
			maxw[i]=maxw[i]/.sim//Simplify;
			Print[i,".   ",maxw[i]//.w," = 0"];
		,{i,0,3}];

	];

	(*Max2[FupF,maxwF];*)

];

StatChargeRadToPrivCSBackTransform:=Block[{},		(* the same, as above *)

	If[runSyncMetric=!=1,SyncMetric];
	runStatChargeRadToPrivCSBackTransform=1;

	OF[" \\section{Radiation of free falling charge}"]>>>texoutput.tex;

	texHeadPrint[" The Current of static charge in the Synhcron CS "];
	varPrint[Jsynchron];
	Jsynchron[0]=ee cc/d2 DiscreteDelta[y[1]-yS[1],y[2]-yS[2],y[3]-yS[3]];		Jsynchron[1]=Jsynchron[2]=Jsynchron[3]=0;
	Do[
		prolog=Jsync[i];
		texMatrixPrint[Jsynchron[i]/.wpq]
	,{i,0,3}];


	texHeadPrint[" The Current in the Privileged CS in Y variables "];
	varPrint[JprivY];
	Do[
		JprivY[i]=jacobian[i,0] Jsync[0];
		prolog=Jprivil[i];
		texMatrixPrint[JprivY[i]/.wpq]
	,{i,0,3}];


	texHeadPrint[" The Current in the Privileged CS in X variables "];
	varPrint[JprivX];
	Do[
		JprivX[i]=JprivY[i]/.TransToPriv//FS;
		prolog=Jprivil[i];
		texMatrixPrint[JprivX[i]];
		J/:J[i]@@var=JprivX[i];
		,{i,0,3}];
    OF["where GPQ is defined in (\\ref{gpq_definition}).\\\\"]>>>texoutput.tex;

    Print["Short form of JprivX[1]"];
    G[3, 2][z_] = G[2, 3][z];Gdown[3, 2][z_] = Gdown[2, 3][z];
    s3=Solve[(Sum[x[s]x[r]Gdown[r,p][z]Gdown[s,q][z]G[p,q]'[z],{s,2,3},{r,2,3},{p,2,3},{q,2,3}]/.x[2]^2Gdown[2,2][z]^2G[2,2]'[z]->y)==GPQRS,y][[1,1]]/.y->x[2]^2Gdown[2,2][z]^2G[2,2]'[z]/.z->x[0]//EA;
    t3=(JprivX[1] /. Take[simLowG, 3]//EA)/.s3//FS;
    Format[GPQRS]=SPS["x","p"]SPS["x","q"]SB["G","pr"]SB["G","qs"]SPS["G'","rs"];
    Print[Jprivil[1]," = ",t3];


    Print[ "We can use the GPQ because the Current is not differentiated during Maxw Eq-ns calculus" ];

    (*A/:A[1]@@var=0;	*)		(* <--   ATTENTION!!! this is an assumption! *)

    (* other assumption: F(psi) *)
    (*
    Eikonal;
    psi=psi/. ka[1] -> 1;
	Do[F /: F[i, j] @@ var = FF[i, j][psi] , {i, 0, 3}, {j, i + 1, 3}];
	Do[A /: A[i] @@ var = AA[i][psi] , {i, 0, 3}];
	Format[FF[it_, jt_][__]] = 		Format[FF[it_, jt_][__],TeXForm] = 		SB["F", SF["````", it, jt]];
	Format[FF[it_, jt_]'[__]] = 	Format[FF[it_, jt_]'[__],TeXForm] = 	SB["F", SF["````", it, jt]]';
	Format[AA[it_][__]] = 			Format[AA[it_][__],TeXForm] = 			SB["A",it];
	Format[AA[it_]'[__]] = 			Format[AA[it_]'[__],TeXForm] = 			SB["A",it]';
	Format[AA[it_]''[__]] = 		Format[AA[it_]''[__],TeXForm] = 		SB["A",it]'';
	Format[ka[it_]] = 				Format[ka[it_],TeXForm] = 				SB[ka, it];
	*)

    MaxwEqPrivilegedCS;

    texHeadPrint[" Let us to eliminate the Current form Maxw. Eq-ns with F "];					(* 27.03.2024 *)
    s1 = Solve[maxwF[[1]] == 0, Jsync[0]][[1,1]];
    texListPrint[Equal@@s1];
    t1 = Table[DeleteCases[maxwF[[i+1]]/.s1//FS, (GPQ x[0])^__], {i, 3}];
	texListPrint[t1," = 0"];
	OF["(* Left parts of Maxw. Eq-ns in Priv. CS without J[0] for F *)"]>>>mathoutput;
	Do[OF[SF["maxwellF[``] := ",i]]>>>mathoutput;	t1[[i]]>>>mathoutput;	OF[""]>>>mathoutput;,{i,3}];

    texHeadPrint[" The same for Maxw. Eq-ns with vector potential A "];
    s2 = Solve[maxwA[[1]] == 0, Jsync[0]][[1,1]];
    texListPrint[s2/.Rule->Equal];
    t2 = Table[DeleteCases[maxwA[[i+1]]/.s2//FS, (GPQ x[0])^__], {i, 3}];
    texListPrint[t2," = 0"];
	OF["(* Left parts of Maxw. Eq-ns in Priv. CS without J[0] for A *)"]>>>mathoutput;
	Do[OF[SF["maxwellA[``] := ",i]]>>>mathoutput;	t2[[i]]>>>mathoutput;	OF[""]>>>mathoutput;,{i,3}];


	texHeadPrint[" Lorentz Gauge and it's derivatives "];
		lorGauge=Solve[0==-Sum[D[sqrtddet Sum[vg[i,j] A[i]@@var,{i,0,3}],x[j]],{j,0,3}]//FS//Numerator, D[A[0]@@var,x[1]]][[1,1]];
		texListPrint[lorGauge];
		DlorGauge=Table[D[lorGauge,x[i]],{i,0,3}];
		texListPrint[DlorGauge];
	texHeadPrint[" Contravariant potential vector A^i "];
		Aup=Table[Sum[vg[i,j] A[j]@@var,{j,0,3}],{i,0,3}];
		texListPrint[Aup];
	texHeadPrint[" Dalambertian of A^i "];
		Do[G[i,j,k]=Sum[vg[k,m](D[ng[i,m],x[j]]+D[ng[j,m],x[i]]-D[ng[i,j],x[m]])/2,{m,0,3}]//FS;	G[j,i,k]=G[i,j,k],{i,0,3},{j,i,3},{k,0,3}];
		Do[nablaA[be,de]=D[A[de]@@var,x[be]]-Sum[G[de,be,ka] A[ka]@@var,{ka,0,3}],{de,0,3},{be,0,3}];

		DalA=Table[Sum[vg[ga,de] Sum[vg[al,be](D[nablaA[de,be],x[al]]-Sum[G[al,be,la] nablaA[la,de],{la,0,3}]-Sum[G[al,de,la] nablaA[la,be],{la,0,3}]),{al,0,3},{be,0,3}],{de,0,3}]//FS,{ga,0,3}];
		texListPrint[DalA];

	texHeadPrint[" Dalambertian of A^i with Lorentz Gauge "];
		DalALor = DalA /. sim // FS;
		DalALor = EA[DalALor] /. sim2derivs // FS;
		DalALor = DalALor /. sim2derivs // FS;
		DalALor = DalALor /. sim // FS;
		DalALor = DalALor /. lorGauge /. DlorGauge // FS;
		DalALor = DalALor /. sim // FS;
		texListPrint[DalALor];

];

MaxwEqPrivilegedCSversion2:=Block[{},

	(* for '30general' & with math-output *)

	If[runMaxwEqPrivilegedCS=!=1,MaxwEqPrivilegedCS];
	runMaxwEqPrivilegedCSversion2=1;

	If[!ValueQ[sim],sim={}];

	OF[""]>>>mathoutput;
	OF["(*  ----------------- MAXWELL EQ_NS -------------------- *)"]>>>mathoutput;		(* begin of 'mathoutput' *)
	OF[""]>>>mathoutput;



	texHeadPrint[" 2 pair of Maxwell eq-ns with F in Priv. CS more simple "];
	sim = {g[2, 3]'[x[0]] -> (g'[x[0]] + g[2, 2]'[x[0]] g[3, 3][x[0]] + g[2, 2][x[0]] g[3, 3]'[x[0]])/2/g[2, 3][x[0]]}~Join~sim;
	Do[
		OF[SF["maxw[``] := ",i]]>>>mathoutput;
		maxwF[i]>>>mathoutput;
		(*OF[";"]>>>mathoutput;*)
		OF[""]>>>mathoutput;
		maxwF[i]=maxwF[i]//.sim//FS; maxwF[i]=maxwF[i]//.sim//FS; Print[i,"    ",maxwF[i]//.w//yoyo," = 0"]; texPrint["",maxwF[i]//.w," = 0"];
	,{i,0,3}];

	texHeadPrint[" 2 pair of Maxwell eq-ns with A in Priv. CS more simple  "];
	Do[maxwA[i]=maxwA[i]//.sim//FS; maxwA[i]=maxwA[i]//.sim//FS; Print[i,"    ",maxwA[i]//.w//yoyo," = 0"]; texPrint["",maxwA[i]//.w," = 0"];	,{i,0,3}];

];


StressElectromagneticTensor:=Block[{},


	If[!ValueQ[sim],sim={}];
	If[!ValueQ[RR],standart];

	Clear[F];

		(*!*) (* solution *)
		F/:F[0,1]@@var=0;F/:F[1,2]@@var=0;F/:F[1,3]@@var=0;F/:F[2,3]@@var=0;

	Do[F/:F[i,i]@@var=0,{i,0,3}];
	Do[F/:F[j,i]@@var=-F[i,j]@@var,{i,0,3},{j,i+1,3}];



	(*Do[ F/:F[i,j]@@var=D[A[i]@@var,x[j]]-D[A[j]@@var,x[i]],  {i,0,3},{j,0,3}];	*)

	texHeadPrint[" Components of Stress Tensor "];

	Do[
		T[i,k]=(-Sum[F[i,j]@@var F[k,l]@@var vg[j,l],{j,0,3},{l,0,3}]+ng[i,k] Sum[F[j,m]@@var F[n,l]@@var vg[j,n] vg[m,l],{j,0,3},{l,0,3},{m,0,3},{n,0,3}]/4)/4/pi//FS;
		OF[SF["T[``,``] := ",i,k]]>>>mathoutput;
		T[i,k]>>>mathoutput;
		OF[""]>>>mathoutput;
		T[i,k]=T[i,k]/.sim//FS;
		Print[i,k,"      ",T[i,k]//.w//yoyo];  texPrint["",T[i,k]//.w,""];
	,{i,0,3},{k,i,3}];

	Do[T[k,i]=T[i,k],{i,0,3},{k,i+1,3}];

	TT=Sum[T[i,k]vg[i,k],{i,0,3},{k,0,3}]/.sim//FS; TT=TT/.sim//FS; Print["T = ",TT//.w//yoyo]; texPrint["T = ",TT//.w,""];



	texHeadPrint[" Einstein eq-ns in recent metric "];

	Do[
		Ein[i,k]=Numerator[R[i,k]-(8 pi ka)/cc^4 (T[i,k]-ng[i,k] TT/2)+ng[i,k]La];
		OF[SF["Ein[``,``] := ",i,k]]>>>mathoutput;
		Ein[i,k]>>>mathoutput;
		OF[""]>>>mathoutput;
		R[i,k]=R[i,k]//.sim//FS;	R[i,k]=R[i,k]//.sim//FS;
		Ein[i,k]=Numerator[R[i,k]-(8 pi ka)/cc^4 (T[i,k]-ng[i,k] TT/2)+ng[i,k]La]//.sim;
		Print[i,k,"      ",Ein[i,k]//.w//yoyo];  texPrint["",Ein[i,k]//.w," = 0"];
	,{i,0,3},{k,i,3}];

	texHeadPrint[" Einstein eq-ns convolution "];

	Do[Ein[k,i]=Ein[i,k],{i,0,3},{k,i+1,3}];
	EE=Sum[Ein[i,k]vg[i,k],{i,0,3},{k,0,3}]//FS; EE=Numerator[EE//.sim//FS];  Print["0 = ",EE//.w//yoyo]; texPrint["",EE//.w," = 0"];

];

OsetrinsVishes151223:=Block[{},

	If[!ValueQ[RR],standart];

	OF[" Metric tensor "]>>>texoutput.tex;
	texPrint["g^{\\alpha\\beta} = ",VG//.w//MatrixForm,""];
	texPrint["g_{\\alpha\\beta} = ",NG//.w//MatrixForm,""];
	texPrint["g = ",ddet//.w,""];
	OF[" Curvature "]>>>texoutput.tex;
	texPrint["R_{00} = ",R[0,0]//.w,""];
	OF["\\bb R_{01} = R_{02} = ... = 0 \\ee"]>>>texoutput.tex;
	texPrint["R = ",RR//.w,""];

	MaxwEqPrivilegedCS;

	OF[" General view of Einstein eq-n"]>>>texoutput.tex;
	OF["\\bb R_{\\alpha\\beta} - \\frac{8\\pi\\kappa}{c^4}\\left(T_{\\alpha\\beta}-\\frac 12 g_{\\alpha\\beta} T\\right) + g_{\\alpha\\beta}\\Lambda = 0 \\ee"]>>>texoutput.tex;

	StressElectromagneticTensor;

	ChargeConservPrivilegedCS;

	(* sim is intuduced above in the 'StressElectromagneticTensor' *)

	ccl=Numerator[ccl/.sim//FS]; Print[ccl//.w//yoyo," = 0"]; texPrint["",ccl//.w," = 0"];


];

(* ======================= ACTIONS =========================*)


(*MaxwEqSynchronCS;*) (* baaad! *)

HamJac;


(*StatChargeRadToPrivCSBackTransform;*)

OF["\\end{document}"]>>>texoutput.tex;
Close["texoutput.tex"];
(* ======================= ADDITIONAL =========================*)

EmitSound[{Play[Sin[700*t+25*t*Sin[350*t]],{t,0,.5}]}]; (* бу-га-га! *)

Print["OS Version: ",$System];
Print["Data file: ",dataFileName];
Print["Current file: ",$Input];