# Providing a Weight to a Derivative

I tried to isolate terms with a certain order of derivation by defining a Weight property to the derivative.

(x, y)::Coordinate.
(i, j)::Indices(values={x, y}, position=fixed).
\nabla{#}::Derivative.
h_{i j}::Depends(x, y, \nabla{#}).
\delta{#}::KroneckerDelta:
\nabla{#}::Weight(label=order, value=1);

Then, a test expression

test := A \delta_{i j} + h_{i j}
+ \nabla_{x}{h_{i j}}
+ B \nabla_{y}{h_{i j}}
+ C \nabla_{x}{ \nabla_{y}{ h_{i j} } }
+ \nabla_{x}{ \nabla_{x}{ h_{i j} } };

Finally, I'd like to define terms with a certain order on derivatives,

term0 := @(test).
keep_weight(_, $order=0$);
term1 := @(test).
keep_weight(_, $order=1$);
term2 := @(test).
keep_weight(_, $order=2$);

It results in the

The zeroth order is Ok, but the first and second yield problems.

### Question

What is the right way (if any) of providing Weight to a derivative operator?

P.D.: The same occurs with the PartialDerivative or by changing the WeightInherit type to multiplicative.

related to an answer for: Extending zoom() function

+1 vote

Thank you for the answer @kasper. I have notice, however, that the solution does not work properly when the derivative is a PartialDerivative. I assume that is due to the fact that higher order partial derivatives are denoted as $\partial{xy}$ or $\partial{xx}$.