a field-theory motivated approach to computer algebra


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;
\(\displaystyle{}\text{Attached property Weight to }\left[A, B\right].\)
\(\displaystyle{}A B B+A A A+A B+B\)
drop_weight(_, $field=3$);
\(\displaystyle{}A B+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:
\(\displaystyle{}\text{Attached property Weight to }\left[A, B\right].\)
\(\displaystyle{}\text{Attached property Weight to }C.\)
drop_weight(_, $field=3$);
\(\displaystyle{}A B+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};
\(\displaystyle{}\text{Attached property Weight to }\left[\phi, \chi\right].\)
\(\displaystyle{}\text{Attached property PartialDerivative to }\partial{\#}.\)
\(\displaystyle{}\text{Attached property WeightInherit to }\partial{\#}.\)
\(\displaystyle{}\phi \partial_{0}{\phi}+\partial_{0}{\lambda}+\lambda \partial_{3}{\chi}\)
drop_weight(_, $small=1$);
\(\displaystyle{}\phi \partial_{0}{\phi}+\partial_{0}{\lambda}\)
Copyright © 2001-2024 Kasper Peeters