Processing math: 100%
Cadabra
a field-theory motivated approach to computer algebra

drop_weight

Drop terms with given weight
Drop those terms for which a product has the indicated weight. Weights are computed by making use of the Weight property of symbols. This algorithm does the opposite of keep_weight. As an example, consider the simple case in which we want to drop all terms with 3 fields. This is done using
{A,B}::Weight(label=field); ex:=A B B + A A A + A B + B;
Attached property Weight to [A,B].
ABB+AAA+AB+B
drop_weight(_, $field=3$);
AB+B
However, you can also do more complicated things by assigning non-unit weights to symbols, as in the example below,
{A,B}::Weight(label=field); C::Weight(label=field, value=2); ex:=A B B + A A A + A B + A C + B:
Attached property Weight to [A,B].
Attached property Weight to C.
drop_weight(_, $field=3$);
AB+B
Weights can be "inherited" by operators by using the WeightInherit property. Here is an example using partial derivatives,
{\phi,\chi}::Weight(label=small, value=1); \partial{#}::PartialDerivative; \partial{#}::WeightInherit(label=all, type=multiplicative); ex:=\phi \partial_{0}{\phi} + \partial_{0}{\lambda} + \lambda \partial_{3}{\chi};
Attached property Weight to [ϕ,χ].
Attached property PartialDerivative to #.
Attached property WeightInherit to #.
ϕ0ϕ+0λ+λ3χ
drop_weight(_, $small=1$);
ϕ0ϕ+0λ
Copyright © 2001-2024 Kasper Peeters
Questions? info@cadabra.science