This is a read only copy of the old FEniCS QA forum. Please visit the new QA forum to ask questions

Collect like terms in a form

0 votes

Is there a straightforward way to identify when terms are identical within a form and collect them? For example, automatically convert

(u + w + u + u + w)*dx

to

(3*u + 2*w)*dx

The motivation is that automatic differentiation tends to produce huge sums that are a gigantic mess. Often one ends out with lots of duplicate terms. It would be nice to be able to automatically simplify them, similar to how one can simplify() expressions in computer algebra systems like Maple, Mathematica, etc.

If this is not possible with standard methods, what do I need to learn about FEniCS in order to implement this or other computer algebra operations on forms?

asked Apr 8, 2015 by Nick Alger FEniCS User (1,490 points)
...