I use a custom function/head Operator[low, high] which encodes a generic polynomial expression split into "low" and "high" summands following considerations which are irrelevant to this question.

Two Operator objects should sum in the following way:

Operator[a,b] + Operator[c,d] -> Operator[a+c,b+d]

which is just standard element–wise summation that List does automatically. How can I tell Mathematica that this kind of automatic simplification or rearrangement is not only allowed, but desirable?


1 Answer 1


One of the standard ways for such things is using TagSetDelayed

Operator /: Operator[a_, b_] + Operator[c_, d_] := Operator[a + c, b + d]
  • $\begingroup$ Thanks, that works really well! I'm a bit mystified about semantics behind /: but I'll read up. $\endgroup$
    – Dom Miketa
    Commented Dec 21, 2018 at 15:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.