1
$\begingroup$

It is a rather easy problem but I don't manage to solve it.

Expand[(a[1] x + a[2] y + a[3] z) (b[1] x + b[2] y + b[3] z) (c[1] x +
 c[2] y + c[3] z)]

The problem is that is gives me product of a[i] b[j] c[k] as coefficients and I would like to have instead something like d[ijk].

Example :

a[1]b[3]c[2] xyz -> d[132] xyz

Attempt :

equa = Expand[(a[1] x + a[2] y + a[3] z) (b[1] x + b[2] y + 
     b[3] z) (c[1] x + c[2] y + c[3] z)]
For[i = 1, i <= 3, i++,
 For [j = 1, j <= 3, j++,
  For[k = 1, k <= 3, k++,
   equa = equa /. {a[i] b[j] c[k] -> d[i j k]}
    ]]]

but ijk in d[i j k] are multiplied.

$\endgroup$
2
$\begingroup$
exp = Expand[(a[1] x + a[2] y + a[3] z) (b[1] x + b[2] y + 
     b[3] z) (c[1] x + c[2] y + c[3] z)];

exp /. t_. a[i_] b[j_] c[k_] :> t d@FromDigits[{i, j, k}]

x^3 d[111] + x^2 y d[112] + x^2 z d[113] + x^2 y d[121] + x y^2 d[122] + x y z d[123] + x^2 z d[131] + x y z d[132] + x z^2 d[133] + x^2 y d[211] + x y^2 d[212] + x y z d[213] + x y^2 d[221] + y^3 d[222] + y^2 z d[223] + x y z d[231] + y^2 z d[232] + y z^2 d[233] + x^2 z d[311] + x y z d[312] + x z^2 d[313] + x y z d[321] + y^2 z d[322] + y z^2 d[323] + x z^2 d[331] + y z^2 d[332] + z^3 d[333]

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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