Regarding the first part of your question, you could try
test := H = a + b a + b c;
factor_out(test, $a$);
zoom(test, $ a Q?? $);
For the second, you could try (notice that I'm not using an equation in my expression):
test := a + b a + b c;
factor_out(test, $a$)
take_match(_, $a Q??$);
this separates the the part to be assigned to a new variable
H2 := @(test);
and now you can return test
to its original expression
replace_match(test);
Update (2019-Sep-06)
Thanks to @kasper answer to a related question, I provide an updated solution to @sapor question (se comments below.
The solution is to assing a Weight
property to the derivative,. However, the assignation of this property for the derivative is define through the parameter self
of the WeightInherit
property. Thus, consider the following
(x, y)::Coordinate.
(i, j)::Indices(values={x, y}, position=fixed).
\partial{#}::Derivative.
h_{i j}::Depends(x, y, \partial{#}).
\delta{#}::KroneckerDelta.
\partial{#}::WeightInherit(label=order, self=1, type=multiplicative);
test := A \delta_{i j} + h_{i j}
+ \partial_{x}{h_{i j}}
+ B \partial_{y}{h_{i j}}
+ C \partial_{x}{ \partial_{y}{ h_{i j} } }
+ \partial_{x}{ \partial_{x}{ h_{i j} } };
Now, we can take the particular order witht he keep_weight
algorithm
term0 := @(test).
keep_weight(_, $order=0$);
term1 := @(test).
keep_weight(_, $order=1$);
term2 := @(test).
keep_weight(_, $order=2$);
*NOTE:** The solution above does not work properly if the derivative is declared as PartialDerivative