Simplify clifford expresion: Works?
NOTE: I'm using one week old CVS version. I'm playing with rotations in Cl3, following with my previous mail basis definition. I'm implementing the following trivial rotation ex R=(cos(theta/2)*dirac_ONE(0)-e00*e01*sin(theta/2)); cout << "subs Rotation R * e00 * R^\\dag = " << canonicalize_clifford((R * e00 * clifford_star(R)).expand()) << endl; That wonderfully (wonderfully!!!) gives: Rotation R * e00 * R^\dag = 2*e~1*sin(1/2*theta)*cos(1/2*theta)-sin(1/2*theta)^2*e~0 +e~0*cos(1/2*theta)^2 I'm trying to trigonometrically simmplify, 2*cos(1/2*theta)*e~1*sin(1/2*theta) -----to---> sin(theta) To that end: cout << "subs Rotation R * e00 * R^\\dag = " << canonicalize_clifford((R * e00 * clifford_star(R)).expand()).subs(lst(2*sin(1/2*theta)*cos(1/2*theta)==sin(theta))) << endl; that gives subs Rotation R * e00 * R^\dag = 2*e~1*sin(1/2*theta)*cos(1/2*theta)+e~(sin(theta))*cos(1/2*theta)^2-sin(1/2*theta)^2*e~(sin(theta)) Also, if I use cout << "subs Rotation R * e00 * R^\\dag = " << canonicalize_clifford((R * e00 * clifford_star(R)).expand()).subs(lst(2*sin(1/2*theta)*cos(1/2*theta)==sin(theta)),subs_options::algebraic) << endl; I get the same result subs Rotation R * e00 * R^\dag = 2*e~1*sin(1/2*theta)*cos(1/2*theta)+e~(sin(theta))*cos(1/2*theta)^2-sin(1/2*theta)^2*e~(sin(theta)) I think this is a bug. ???? Have a nice weekend! Javier
Dear Javier,
"JRG" == Javier Ros Ganuza <jros@unavarra.es> writes:
JRG> I get the same result .... JRG> I think this is a bug. It is not easy to make our computers as intelligent as we may wish. Try to modify your substitution rules to be more flexible: use wildcards, use the rule sin($1)*cos($1)==sin(2*$1)/2, etc. Good luck, Vladimir -- Vladimir V. Kisil email: kisilv@maths.leeds.ac.uk -- www: http://maths.leeds.ac.uk/~kisilv/
Dear Vladimir, On Fri, 2007-05-25 at 15:43 +0100, Vladimir Kisil wrote:
It is not easy to make our computers as intelligent as we may wish. Try to modify your substitution rules to be more flexible: use wildcards, use the rule sin($1)*cos($1)==sin(2*$1)/2, etc.
cout << "subs Rotation R * e00 * R^\\dag = " << canonicalize_clifford((R * e00 * clifford_star(R)).expand()) << endl; cout << "subs Rotation R * e00 * R^\\dag = " << canonicalize_clifford((R * e00 * clifford_star(R)).expand()).subs(sin(wild())*cos(wild())==sin(2*wild())/2) << endl; cout << "subs Rotation R * e00 * R^\\dag = " << canonicalize_clifford((R * e00 * clifford_star(R)).expand()).subs(sin(wild())*cos(wild())==sin(2*wild())/2,subs_options::algebraic) << endl; Gives no subs at all subs Rotation R * e00 * R^\dag = e~0*cos(1/2*theta)^2 +2*e~1*sin(1/2*theta)*cos(1/2*theta)-e~0*sin(1/2*theta)^2 subs Rotation R * e00 * R^\dag = e~0*cos(1/2*theta)^2 +2*e~1*sin(1/2*theta)*cos(1/2*theta)-e~0*sin(1/2*theta)^2 subs Rotation R * e00 * R^\dag = e~0*cos(1/2*theta)^2 +2*e~1*sin(1/2*theta)*cos(1/2*theta)-e~0*sin(1/2*theta)^2 I understand that cout << "subs Rotation R * e00 * R^\\dag = " << canonicalize_clifford((R * e00 * clifford_star(R)).expand()) << endl; cout << "subs Rotation R * e00 * R^\\dag = " << canonicalize_clifford((R * e00 * clifford_star(R)).expand()).subs(2*sin(1/2*theta)*cos(1/2*theta)==sin(theta)) << endl; cout << "subs Rotation R * e00 * R^\\dag = " << canonicalize_clifford((R * e00 * clifford_star(R)).expand()).subs(2*sin(1/2*theta)*cos(1/2*theta)==sin(theta),subs_options::algebraic) << endl; Produces nonsense substitutions: subs Rotation R * e00 * R^\dag = -e~0*sin(1/2*theta)^2 +cos(1/2*theta)^2*e~0+2*cos(1/2*theta)*e~1*sin(1/2*theta) subs Rotation R * e00 * R^\dag = -e~(sin(theta))*sin(1/2*theta)^2 +2*cos(1/2*theta)*e~1*sin(1/2*theta)+cos(1/2*theta)^2*e~(sin(theta)) subs Rotation R * e00 * R^\dag = -e~(sin(theta))*sin(1/2*theta)^2 +2*cos(1/2*theta)*e~1*sin(1/2*theta)+cos(1/2*theta)^2*e~(sin(theta)) For example: what does mean: -e~(sin(theta)) ? Also in this simple expresion, even expand() is giving a bad result cout << "out: " << ((2*sin(1/2*theta)*cos(1/2*theta) + 1).expand()) << endl; cout << "out: " << ((2*sin(1/2*theta)*cos(1/2*theta) + 1).expand()).subs(2*sin(1/2*theta)*cos(1/2*theta)==sin(theta)) << endl; cout << "out: " << ((2*sin(1/2*theta)*cos(1/2*theta) + 1).expand()).subs(2*sin(1/2*theta)*cos(1/2*theta)==sin(theta),subs_options::algebraic) << endl; cout << "out: " << ((2*sin(1/2*theta)*cos(1/2*theta) + 1).expand()).subs(sin(wild())*cos(wild())==sin(2*wild())/2) << endl; cout << "out: " << ((2*sin(1/2*theta)*cos(1/2*theta) + 1).expand()).subs(sin(wild())*cos(wild())==sin(2*wild())/2,subs_options::algebraic) << endl; out: 1 out: 1 out: 1 out: 1 out: 1 Is it something wroken in CVS version? I've been playing with subs with previous versions (a different project), and I have always got good results? Thanks Javier
Good luck, Vladimir
Hello! On Mon, May 28, 2007 at 09:44:44AM +0200, Javier Ros Ganuza wrote:
cout << "subs Rotation R * e00 * R^\\dag = " << canonicalize_clifford((R * e00 * clifford_star(R)).expand()) << endl;
cout << "subs Rotation R * e00 * R^\\dag = " << canonicalize_clifford((R * e00 * clifford_star(R)).expand()).subs(sin(wild())*cos(wild())==sin(2*wild())/2) << endl;
cout << "subs Rotation R * e00 * R^\\dag = " << canonicalize_clifford((R * e00 * clifford_star(R)).expand()).subs(sin(wild())*cos(wild())==sin(2*wild())/2,subs_options::algebraic) << endl;
Gives no subs at all
subs Rotation R * e00 * R^\dag = e~0*cos(1/2*theta)^2 +2*e~1*sin(1/2*theta)*cos(1/2*theta)-e~0*sin(1/2*theta)^2 subs Rotation R * e00 * R^\dag = e~0*cos(1/2*theta)^2 +2*e~1*sin(1/2*theta)*cos(1/2*theta)-e~0*sin(1/2*theta)^2 subs Rotation R * e00 * R^\dag = e~0*cos(1/2*theta)^2 +2*e~1*sin(1/2*theta)*cos(1/2*theta)-e~0*sin(1/2*theta)^2
Interesting. This program works for me: $ cat substest.cpp #include <iostream> #include <stdexcept> #include <ginac/ginac.h> using namespace std; using namespace GiNaC; int main(int argc, char** argv) { symbol x("x"), p("p"), eps("eps"); varidx mu(symbol("mu"), 4-2*eps), nu(symbol("nu"), 4-2*eps); ex test = dirac_gamma(mu)*dirac_gamma(nu)*sin(x/2)*cos(x/2) + lorentz_g(mu, nu)*pow(sin(x), 2); cout << test << " ==> " << endl; cout << test.subs(sin(wild())*cos(wild())==sin(2*wild())/2, subs_options::algebraic) << endl; return 0; } $ g++ substest.cpp -lginac $ ./a.out (gamma~mu*gamma~nu)*cos(1/2*x)*sin(1/2*x)+eta~mu~nu*sin(x)^2 ==> eta~mu~nu*sin(x)^2+1/2*(gamma~mu*gamma~nu)*sin(x) $ pkg-config --modversion ginac 1.3.7
I understand that
cout << "subs Rotation R * e00 * R^\\dag = " << canonicalize_clifford((R * e00 * clifford_star(R)).expand()) << endl;
cout << "subs Rotation R * e00 * R^\\dag = " << canonicalize_clifford((R * e00 * clifford_star(R)).expand()).subs(2*sin(1/2*theta)*cos(1/2*theta)==sin(theta)) << endl;
In C[++] 1/2 means integer division, so 1/2*theta is zero. So your rule is subs(0==sin(theta))...
cout << "subs Rotation R * e00 * R^\\dag = " << canonicalize_clifford((R * e00 * clifford_star(R)).expand()).subs(2*sin(1/2*theta)*cos(1/2*theta)==sin(theta),subs_options::algebraic) << endl;
Produces nonsense substitutions:
subs Rotation R * e00 * R^\dag = -e~0*sin(1/2*theta)^2 +cos(1/2*theta)^2*e~0+2*cos(1/2*theta)*e~1*sin(1/2*theta) subs Rotation R * e00 * R^\dag = -e~(sin(theta))*sin(1/2*theta)^2 +2*cos(1/2*theta)*e~1*sin(1/2*theta)+cos(1/2*theta)^2*e~(sin(theta)) subs Rotation R * e00 * R^\dag = -e~(sin(theta))*sin(1/2*theta)^2 +2*cos(1/2*theta)*e~1*sin(1/2*theta)+cos(1/2*theta)^2*e~(sin(theta))
... and you got exactly what you asked for: e~0 turned into e~(sin(theta)
For example: what does mean: -e~(sin(theta)) ?
Something like \gamma~(4-2*eps) in dimensional regularisation? :)
Also in this simple expresion, even expand() is giving a bad result
cout << "out: " << ((2*sin(1/2*theta)*cos(1/2*theta) + 1).expand()) << endl;
Again, 1/2 is 0, so the expression is 1, ...
cout << "out: " << ((2*sin(1/2*theta)*cos(1/2*theta) + 1).expand()).subs(2*sin(1/2*theta)*cos(1/2*theta)==sin(theta)) << endl;
... and the rule is to replace zero with sin(theta) ...
cout << "out: " << ((2*sin(1/2*theta)*cos(1/2*theta) + 1).expand()).subs(2*sin(1/2*theta)*cos(1/2*theta)==sin(theta),subs_options::algebraic) << endl;
cout << "out: " << ((2*sin(1/2*theta)*cos(1/2*theta) + 1).expand()).subs(sin(wild())*cos(wild())==sin(2*wild())/2) << endl;
cout << "out: " << ((2*sin(1/2*theta)*cos(1/2*theta) + 1).expand()).subs(sin(wild())*cos(wild())==sin(2*wild())/2,subs_options::algebraic) << endl;
out: 1 out: 1 out: 1 out: 1 out: 1
... and (obviously) there are no matches. Best regards, Alexei -- All science is either physics or stamp collecting.
Thanks very much, I0m sorry it was my mistake :) (1/2 ->> numeric(1,2)) Javier On Mon, 2007-05-28 at 12:27 +0400, Sheplyakov Alexei wrote:
Hello!
On Mon, May 28, 2007 at 09:44:44AM +0200, Javier Ros Ganuza wrote:
cout << "subs Rotation R * e00 * R^\\dag = " << canonicalize_clifford((R * e00 * clifford_star(R)).expand()) << endl;
cout << "subs Rotation R * e00 * R^\\dag = " << canonicalize_clifford((R * e00 * clifford_star(R)).expand()).subs(sin(wild())*cos(wild())==sin(2*wild())/2) << endl;
cout << "subs Rotation R * e00 * R^\\dag = " << canonicalize_clifford((R * e00 * clifford_star(R)).expand()).subs(sin(wild())*cos(wild())==sin(2*wild())/2,subs_options::algebraic) << endl;
Gives no subs at all
subs Rotation R * e00 * R^\dag = e~0*cos(1/2*theta)^2 +2*e~1*sin(1/2*theta)*cos(1/2*theta)-e~0*sin(1/2*theta)^2 subs Rotation R * e00 * R^\dag = e~0*cos(1/2*theta)^2 +2*e~1*sin(1/2*theta)*cos(1/2*theta)-e~0*sin(1/2*theta)^2 subs Rotation R * e00 * R^\dag = e~0*cos(1/2*theta)^2 +2*e~1*sin(1/2*theta)*cos(1/2*theta)-e~0*sin(1/2*theta)^2
Interesting. This program works for me:
$ cat substest.cpp #include <iostream> #include <stdexcept> #include <ginac/ginac.h> using namespace std; using namespace GiNaC;
int main(int argc, char** argv) { symbol x("x"), p("p"), eps("eps"); varidx mu(symbol("mu"), 4-2*eps), nu(symbol("nu"), 4-2*eps);
ex test = dirac_gamma(mu)*dirac_gamma(nu)*sin(x/2)*cos(x/2) + lorentz_g(mu, nu)*pow(sin(x), 2); cout << test << " ==> " << endl; cout << test.subs(sin(wild())*cos(wild())==sin(2*wild())/2, subs_options::algebraic) << endl; return 0; } $ g++ substest.cpp -lginac $ ./a.out (gamma~mu*gamma~nu)*cos(1/2*x)*sin(1/2*x)+eta~mu~nu*sin(x)^2 ==> eta~mu~nu*sin(x)^2+1/2*(gamma~mu*gamma~nu)*sin(x) $ pkg-config --modversion ginac 1.3.7
I understand that
cout << "subs Rotation R * e00 * R^\\dag = " << canonicalize_clifford((R * e00 * clifford_star(R)).expand()) << endl;
cout << "subs Rotation R * e00 * R^\\dag = " << canonicalize_clifford((R * e00 * clifford_star(R)).expand()).subs(2*sin(1/2*theta)*cos(1/2*theta)==sin(theta)) << endl;
In C[++] 1/2 means integer division, so 1/2*theta is zero. So your rule is subs(0==sin(theta))...
cout << "subs Rotation R * e00 * R^\\dag = " << canonicalize_clifford((R * e00 * clifford_star(R)).expand()).subs(2*sin(1/2*theta)*cos(1/2*theta)==sin(theta),subs_options::algebraic) << endl;
Produces nonsense substitutions:
subs Rotation R * e00 * R^\dag = -e~0*sin(1/2*theta)^2 +cos(1/2*theta)^2*e~0+2*cos(1/2*theta)*e~1*sin(1/2*theta) subs Rotation R * e00 * R^\dag = -e~(sin(theta))*sin(1/2*theta)^2 +2*cos(1/2*theta)*e~1*sin(1/2*theta)+cos(1/2*theta)^2*e~(sin(theta)) subs Rotation R * e00 * R^\dag = -e~(sin(theta))*sin(1/2*theta)^2 +2*cos(1/2*theta)*e~1*sin(1/2*theta)+cos(1/2*theta)^2*e~(sin(theta))
... and you got exactly what you asked for: e~0 turned into e~(sin(theta)
For example: what does mean: -e~(sin(theta)) ?
Something like \gamma~(4-2*eps) in dimensional regularisation? :)
Also in this simple expresion, even expand() is giving a bad result
cout << "out: " << ((2*sin(1/2*theta)*cos(1/2*theta) + 1).expand()) << endl;
Again, 1/2 is 0, so the expression is 1, ...
cout << "out: " << ((2*sin(1/2*theta)*cos(1/2*theta) + 1).expand()).subs(2*sin(1/2*theta)*cos(1/2*theta)==sin(theta)) << endl;
... and the rule is to replace zero with sin(theta) ...
cout << "out: " << ((2*sin(1/2*theta)*cos(1/2*theta) + 1).expand()).subs(2*sin(1/2*theta)*cos(1/2*theta)==sin(theta),subs_options::algebraic) << endl;
cout << "out: " << ((2*sin(1/2*theta)*cos(1/2*theta) + 1).expand()).subs(sin(wild())*cos(wild())==sin(2*wild())/2) << endl;
cout << "out: " << ((2*sin(1/2*theta)*cos(1/2*theta) + 1).expand()).subs(sin(wild())*cos(wild())==sin(2*wild())/2,subs_options::algebraic) << endl;
out: 1 out: 1 out: 1 out: 1 out: 1
... and (obviously) there are no matches.
Best regards, Alexei
-- All science is either physics or stamp collecting.
_______________________________________________ GiNaC-list mailing list GiNaC-list@ginac.de https://www.cebix.net/mailman/listinfo/ginac-list
participants (3)
-
Javier Ros Ganuza
-
varg@theor.jinr.ru
-
Vladimir Kisil