On Saturday, January 11, 2014 9:35:52 PM UTC+1, Comer wrote: > > > Now I am trying to create the Weyl tensor. Here is what I do and the > response: > >
> W = tensorhead('W',[Lorentz]*4,[[2, 2]]) > > This definition is useless, it gets overridden later. terma = tensor_mul(Rational(1,2)*g(-a,-c)*Ric(-d,-b)) > print terma.args > terma = TensMul(*terma.args) > > termb = tensor_mul(Rational(1,2)*g(-a,-d)*Ric(-c,-b)) > print termb.args > termb = TensMul(*termb.args) > > termc = tensor_mul(Rational(1,2)*g(-b,-c)*Ric(-d,-a)) > print termc.args > termc = TensMul(*termc.args) > > termd = tensor_mul(Rational(1,2)*g(-b,-d)*Ric(-c,-a)) > print termd.args > termd= TensMul(*termd.args) > > terme = tensor_mul(Rational(1,3)*R*g(-a,-c)*g(-d,-b)) > print terme.args > terme = TensMul(*terme.args) > > termf = tensor_mul(Rational(1,3)*R*g(-a,-d)*g(-c,-b)) > print termf.args > termf = TensMul(*termf.args) > W = Riem -terma + termb + termc - termd + terme -termf > > You have to specify the indices in Riem. There are two objects here, TensorHead and TensMul. TensorHead is a tensor without indices, TensMul is a tensor with indices specified. Riem is a TensorHead Riem(-a, -b, -c, -d) is a TensMul Of course you cannot add TensorHead and TensMul, furthermore if you add TensMul they must have the same indices.ValueError: all tensors must have the same indices. So, I believe all terms have the same indices, just in different orders. > No, order does not count. It's just important that indices are the same. Your *Riem* object has no indices at all. > By construction the overall quantity should have the same symmetries in > its 4 indices as the Riemann tensor. When I print the terms individually > they all look as intended, but it chokes when I try to construct W using > them. What am I doing wrong? > You're not putting the indices in Riem. -- You received this message because you are subscribed to the Google Groups "sympy" group. To unsubscribe from this group and stop receiving emails from it, send an email to sympy+unsubscr...@googlegroups.com. To post to this group, send email to sympy@googlegroups.com. Visit this group at http://groups.google.com/group/sympy. For more options, visit https://groups.google.com/groups/opt_out.