1 /** @file exam_clifford.cpp
3 * Here we test GiNaC's Clifford algebra objects. */
6 * GiNaC Copyright (C) 1999-2001 Johannes Gutenberg University Mainz, Germany
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
25 static unsigned check_equal(const ex &e1, const ex &e2)
29 clog << e1 << "-" << e2 << " erroneously returned "
30 << e << " instead of 0" << endl;
36 static unsigned check_equal_simplify(const ex &e1, const ex &e2)
38 ex e = simplify_indexed(e1) - e2;
40 clog << "simplify_indexed(" << e1 << ")-" << e2 << " erroneously returned "
41 << e << " instead of 0" << endl;
47 static unsigned clifford_check1(void)
49 // checks general identities and contractions
54 varidx mu(symbol("mu"), dim), nu(symbol("nu"), dim), rho(symbol("rho"), dim);
57 e = dirac_ONE() * dirac_ONE();
58 result += check_equal(e, dirac_ONE());
60 e = dirac_ONE() * dirac_gamma(mu) * dirac_ONE();
61 result += check_equal(e, dirac_gamma(mu));
63 e = dirac_gamma(varidx(2, dim)) * dirac_gamma(varidx(1, dim)) *
64 dirac_gamma(varidx(1, dim)) * dirac_gamma(varidx(2, dim));
65 result += check_equal(e, dirac_ONE());
67 e = dirac_gamma(mu) * dirac_gamma(nu) *
68 dirac_gamma(nu.toggle_variance()) * dirac_gamma(mu.toggle_variance());
69 result += check_equal_simplify(e, pow(dim, 2) * dirac_ONE());
71 e = dirac_gamma(mu) * dirac_gamma(nu) *
72 dirac_gamma(mu.toggle_variance()) * dirac_gamma(nu.toggle_variance());
73 result += check_equal_simplify(e, 2*dim*dirac_ONE()-pow(dim, 2)*dirac_ONE());
75 e = dirac_gamma(nu.toggle_variance()) * dirac_gamma(rho.toggle_variance()) *
76 dirac_gamma(mu) * dirac_gamma(rho) * dirac_gamma(nu);
77 e = e.simplify_indexed().collect(dirac_gamma(mu));
78 result += check_equal(e, pow(2 - dim, 2).expand() * dirac_gamma(mu));
83 static unsigned clifford_check2(void)
85 // checks identities relating to gamma5
90 varidx mu(symbol("mu"), dim), nu(symbol("nu"), dim);
93 e = dirac_gamma(mu) * dirac_gamma5() + dirac_gamma5() * dirac_gamma(mu);
94 result += check_equal(e, 0);
96 e = dirac_gamma5() * dirac_gamma(mu) * dirac_gamma5() + dirac_gamma(mu);
97 result += check_equal(e, 0);
102 static unsigned clifford_check3(void)
108 symbol dim("D"), m("m"), q("q"), l("l"), ldotq("ldotq");
109 varidx mu(symbol("mu"), dim), nu(symbol("nu"), dim), rho(symbol("rho"), dim),
110 sig(symbol("sig"), dim), kap(symbol("kap"), dim), lam(symbol("lam"), 4);
114 result += check_equal(dirac_trace(e), 0);
116 e = dirac_gamma(mu) * dirac_gamma(nu) * dirac_gamma(rho);
117 result += check_equal(dirac_trace(e), 0);
119 e = dirac_gamma5() * dirac_gamma(mu);
120 result += check_equal(dirac_trace(e), 0);
122 e = dirac_gamma5() * dirac_gamma(mu) * dirac_gamma(nu);
123 result += check_equal(dirac_trace(e), 0);
125 e = dirac_gamma5() * dirac_gamma(mu) * dirac_gamma(nu) * dirac_gamma(rho);
126 result += check_equal(dirac_trace(e), 0);
129 sp.add(q, q, pow(q, 2));
130 sp.add(l, l, pow(l, 2));
133 e = pow(m, 2) * dirac_slash(q, dim) * dirac_slash(q, dim);
134 e = dirac_trace(e).simplify_indexed(sp);
135 result += check_equal(e, 4*pow(m, 2)*pow(q, 2));
137 // cyclicity without gamma5
138 e = dirac_gamma(mu) * dirac_gamma(nu) * dirac_gamma(rho) * dirac_gamma(sig)
139 - dirac_gamma(nu) * dirac_gamma(rho) * dirac_gamma(sig) * dirac_gamma(mu);
141 result += check_equal(e, 0);
143 e = dirac_gamma(mu) * dirac_gamma(nu) * dirac_gamma(rho) * dirac_gamma(sig) * dirac_gamma(kap) * dirac_gamma(lam)
144 - dirac_gamma(nu) * dirac_gamma(rho) * dirac_gamma(sig) * dirac_gamma(kap) * dirac_gamma(lam) * dirac_gamma(mu);
145 e = dirac_trace(e).expand();
146 result += check_equal(e, 0);
148 // cyclicity of gamma5 * S_4
149 e = dirac_gamma5() * dirac_gamma(mu) * dirac_gamma(nu) * dirac_gamma(rho) * dirac_gamma(sig)
150 - dirac_gamma(sig) * dirac_gamma5() * dirac_gamma(mu) * dirac_gamma(nu) * dirac_gamma(rho);
152 result += check_equal(e, 0);
154 // non-cyclicity of order D-4 of gamma5 * S_6
155 e = dirac_gamma5() * dirac_gamma(mu) * dirac_gamma(nu) * dirac_gamma(rho) * dirac_gamma(sig) * dirac_gamma(kap) * dirac_gamma(mu.toggle_variance())
156 + dim * dirac_gamma5() * dirac_gamma(nu) * dirac_gamma(rho) * dirac_gamma(sig) * dirac_gamma(kap);
158 e = (e / (dim - 4)).normal();
159 result += check_equal(e, 8 * eps0123(nu, rho, sig, kap));
161 // one-loop vacuum polarization in QED
162 e = dirac_gamma(mu) *
163 (dirac_slash(l, dim) + dirac_slash(q, dim) + m * dirac_ONE()) *
164 dirac_gamma(mu.toggle_variance()) *
165 (dirac_slash(l, dim) + m * dirac_ONE());
166 e = dirac_trace(e).simplify_indexed(sp);
167 result += check_equal(e, 4*((2-dim)*l*l + (2-dim)*ldotq + dim*m*m).expand());
169 e = dirac_slash(q, dim) *
170 (dirac_slash(l, dim) + dirac_slash(q, dim) + m * dirac_ONE()) *
171 dirac_slash(q, dim) *
172 (dirac_slash(l, dim) + m * dirac_ONE());
173 e = dirac_trace(e).simplify_indexed(sp);
174 result += check_equal(e, 4*(2*ldotq*ldotq + q*q*ldotq - q*q*l*l + q*q*m*m).expand());
179 static unsigned clifford_check4(void)
181 // simplify_indexed()/dirac_trace() cross-checks
186 varidx mu(symbol("mu"), dim), nu(symbol("nu"), dim), rho(symbol("rho"), dim),
187 sig(symbol("sig"), dim), lam(symbol("lam"), dim);
190 e = dirac_gamma(mu) * dirac_gamma(nu) * dirac_gamma(rho) * dirac_gamma(mu.toggle_variance());
191 t1 = dirac_trace(e).simplify_indexed();
192 t2 = dirac_trace(e.simplify_indexed());
193 result += check_equal((t1 - t2).expand(), 0);
195 e = dirac_gamma(mu) * dirac_gamma(nu) * dirac_gamma(rho) * dirac_gamma(sig) * dirac_gamma(mu.toggle_variance()) * dirac_gamma(lam);
196 t1 = dirac_trace(e).simplify_indexed();
197 t2 = dirac_trace(e.simplify_indexed());
198 result += check_equal((t1 - t2).expand(), 0);
200 e = dirac_gamma(sig) * dirac_gamma(mu) * dirac_gamma(nu) * dirac_gamma(rho) * dirac_gamma(nu.toggle_variance()) * dirac_gamma(mu.toggle_variance());
201 t1 = dirac_trace(e).simplify_indexed();
202 t2 = dirac_trace(e.simplify_indexed());
203 result += check_equal((t1 - t2).expand(), 0);
205 e = dirac_gamma(mu) * dirac_gamma(nu) * dirac_gamma(rho) * dirac_gamma(mu.toggle_variance()) * dirac_gamma(sig) * dirac_gamma(nu.toggle_variance());
206 t1 = dirac_trace(e).simplify_indexed();
207 t2 = dirac_trace(e.simplify_indexed());
208 result += check_equal((t1 - t2).expand(), 0);
213 unsigned exam_clifford(void)
217 cout << "examining clifford objects" << flush;
218 clog << "----------clifford objects:" << endl;
220 result += clifford_check1(); cout << '.' << flush;
221 result += clifford_check2(); cout << '.' << flush;
222 result += clifford_check3(); cout << '.' << flush;
223 result += clifford_check4(); cout << '.' << flush;
226 cout << " passed " << endl;
227 clog << "(no output)" << endl;
229 cout << " failed " << endl;