Welcome to Cadabra Q&A, where you can ask questions and receive answers from other members of the community.
+1 vote

Hi everybody!

I can not figure out why drop_weight command doesn't work in the following code

{\alpha, \beta, \rho, \mu, \nu, \sigma, \lambda, \theta, \gamma}::Indices(position=fixed).
\partial{#}::PartialDerivative.
{\partial{#}}::WeightInherit(label=all, type=Multiplicative).
{h^{\mu \nu}, h_{\mu \nu}, h, g_{\mu \nu}, g^{\mu \nu}}::Depends(\partial).
\Gamma^{\alpha}_{\beta \rho}::Depends(\partial, \nabla).
\Gamma^{\alpha}_{\beta \rho}::TableauSymmetry(shape={2}, indices={1,2}).
k::Weight(label=expan, value=1).
{k, h, \eta^{\mu \nu}, h^{\mu \nu}, \partial{#}}::SortOrder.

invMetric:=g^{\mu \nu}->\eta^{\mu \nu} -k h^{\mu \nu};
metric:=g_{\mu \nu}->\eta_{\mu \nu} +k h_{\mu \nu};
jac:=g->1+\frac{k}{2}h;

gamma:=\Gamma^{\alpha}_{\beta \rho} -> \frac{1}{2} g^{\alpha \theta} [ \partial_{\rho}{g_{\theta \beta}}
+ \partial_{\beta}{g_{\theta \rho}}-\partial_{\theta}{g_{\beta \rho}}];
@substitute!(gamma)(@(metric)):
@substitute!(gamma)(@(invMetric)):
@distribute!(%):
@unwrap!(%):
@prodsort!(%):
@collect_factors!(%);
@drop_weight!(%){expan}{2};

Cheers!

in General questions by (1.1k points)

I've no idea what is going on, but it seems that the problem is that Cadabra is not able to distinguish the order of k**2. BTW, it isn't working in Cadabra2 either.

@doxdrum, thanks for your attention. Even if you exclude @factor_out command, the @drop_weight doesn't recognize k*k as weight 2!

1 Answer

+2 votes
 
Best answer

The version now on github handles weights of powers of objects, e.g. $k^2$:

k::Weight(label=expan, value=1);
ex:= k**2 A + k**3 B + k k C + k D;
keep_weight(_, $expan=2$);

yields

k**2 A + k k C

Hope this helps.

by (76.7k points)
selected by

Thank you again!

...