3

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])

10F[c]+15F[a,b,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...)

Hauke Reddmann
  • 1,043
  • 7
  • 11

1 Answers1

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.

user84505
  • 26
  • 1
  • 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 :) – Hauke Reddmann Jan 07 '22 at 10:27