1 | initial version |
Based on the advice from @max and @eric_g - the following works:
commutator_f.expr() \
.collect(diff(f)[0].expr()) \
.collect(diff(f)[1].expr()) \
.collect(diff(f)[2].expr()) \
.collect(diff(f)[3].expr())
Many thanks GPN