I'd like to have an (obviously noncommutative) operator ** that always takes linear combinations of some (undefined) F with any number arguments, distributes the coefficients out and concatenates the arguments. Example:

(2*F[]+3*F[a,b]) ** (5*F[c])


Surely this can be done very elegantly? (Unfortunately, a property "Distributive" is not settable as attribute. When I do linear algebra, I miss such a feature each day...)

  • $\begingroup$ You might want to take a look at the answer to this question, which is very similar. $\endgroup$ Feb 10, 2022 at 4:45

1 Answer 1


Not sure how automatic or "pretty" you want this, but just implementing the description you gave could be done something like this:

myProd[a_ A_F, b_ B_F] := a b Join[A, B];
myProd[x_, y_] := ReleaseHold[Distribute[Hold[myProd][x, y]]];

Then, to reproduce your example:

(2*F[] + 3*F[a, b])~myProd~(5*F[c])

which outputs

10 F[c] + 15 F[a, b, c]

Now, I personally think it'd be better to build out some custom structures, basically define your own little algebra.

  • $\begingroup$ I definitely agree with the last statement, but if this special need is only use-once, a "cheap" solution suffices. P.S. Never saw some details of the syntax (A_F? Tilde is betweenfix notation?) but I learn fast :) $\endgroup$ Jan 7, 2022 at 10:27

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.