Hi Vladimir, On 07/16/2016 12:00 PM, Vladimir V. Kisil wrote:
I am confused by the following. The routine simplify_indexed() calls reposition_dummy_indices(), which has the freedom to toggle dummy indices covariance to achieve canonical order. Leaving aside the question "does the position of an index have geometrical/physical significance and can be harmlessly toggled?", I come to the following unpredictability of the GiNaC output in the different runs of the same compiled programme:
#include <ginac/ginac.h> #include <fstream> using namespace std; using namespace GiNaC;
int main(){ realsymbol x("x"), y("y");
varidx mu(symbol("mu", "\\mu"), 2); ex e = clifford_unit(mu, diag_matrix(lst{-1,-1}));
ex V = lst_to_clifford(lst{x,y}, e);
cout << V << endl; // -> e~mu*[[x],[y]].mu cout << simplify_indexed(V) << endl; // in different runs can be either // (A) -> e~mu*[[x],[y]].mu (as above) or // (B) -> e.mu*[[x],[y]]~mu cout << canonicalize_clifford(V*V) << endl; // depanding on the above outcomes: // (A) -> (e~mu*e~symbol6)*[[x],[y]].symbol6*[[x],[y]].mu // (B) -> -2*ONE*y^2-[[x],[y]]~symbol6*[[x],[y]]~mu*(e.symbol6*e.mu)-2*x^2*ONE cout << canonicalize_clifford(simplify_indexed(V)*simplify_indexed(V)) << endl; // (A) -> (e~mu*e~symbol10)*[[x],[y]].mu*[[x],[y]].symbol10 // (B) -> -(e~symbol13*e~mu)*[[x],[y]].mu*[[x],[y]].symbol13-2*ONE*y^2-2*x^2*ONE cout << canonicalize_clifford(simplify_indexed(V)*V) << endl; // (A) -> -[[x],[y]]~symbol14*(e.symbol14*e~mu)*[[x],[y]].mu-2*ONE*y^2-2*x^2*ONE // (B) -> -2*ONE*y^2-[[x],[y]]~mu*[[x],[y]]~symbol20*(e.symbol20*e.mu)-2*x^2*ONE cout << canonicalize_clifford(expand_dummy_sum(simplify_indexed(V)*V)) << endl; // (A) -> -y^2*ONE-x^2*ONE // (B) -> y^2*(e.1*e~1)+x^2*(e.0*e~0)+x*y*(e.0*e~1)-x*y*(e~0*e.1)
return 0; }
Any advice on usability/necessity of this behaviour?
IMHO, simplify_indexed() should try harder repositioning dummy indices, so cases like yours always return the simplest form. Can you propose a patch? All my best, -richy. -- Richard B. Kreckel <http://in.terlu.de/~kreckel/>