3
$\begingroup$

How to convert the following formula into the traditional form of product?

(x[1] - x[2])^2 (x[1] - x[3])^2 (x[2] - x[3])^2 (x[1] - 
   x[4])^2 (x[2] - x[4])^2 (x[3] - x[4])^2 (x[1] - x[5])^2 (x[2] - 
   x[5])^2 (x[3] - x[5])^2 (x[4] - x[5])^2

to

$\prod_{1 \leqslant j<i \leqslant 5}\left(x_i-x_j\right)^2$

EDIT

Sorry for my inaccurate description of the problem. This is a problem in the textbook:

$s_k=x_1^k+x_2^k+\cdots+x_n^k, k=0,1,2, \cdots$,

$\boldsymbol{A}=\left(a_{i j}\right)_{n \times m}$ , and $a_{i j}=s_{i+j-2}, i, j=1,2, \cdots, n_{\text {. }}$

To prove

$|\boldsymbol{A}|=\prod_{1 \leqslant j<i \leqslant n}\left(x_i-x_j\right)^2$

The following is the code taking the 5th order matrix as an example, but I hope to get the results in textbook form ($\prod_{1 \leqslant j<i \leqslant 5}\left(x_i-x_j\right)^2$) directly with code.

Clear["Global`*"];
s[k_] := Sum[x[v]^k, {v, 1, 5}];
mA[i_, j_] := s[i + j - 2];

mA = Table[mA[i, j], {i, 1, 5}, {j, 1, 5}]
FullSimplify[Det[mA]]

(x[1] - x[2])^2 (x[1] - x[3])^2 (x[2] - x[3])^2 (x[1] - x[4])^2 (x[2] - x[4])^2 (x[3] - x[4])^2 (x[1] - x[5])^2 (x[2] - x[5])^2 (x[3] - x[5])^2 (x[4] - x[5])^2

$\endgroup$
2
  • $\begingroup$ What do you mean by convert? Use (x[1] - x[2])^2 (x[1] - x[3])^2 (x[2] - x[3])^2 (x[1] - x[4])^2 (x[2] - x[4])^2 (x[3] - x[4])^2 (x[1] - x[5])^2 (x[2] - x[5])^2 (x[3] - x[5])^2 (x[4] - x[5])^2 as the input and output $\prod_{1 \leqslant j<i \leqslant 5}\left(x_i-x_j\right)^2$, or create an expression that looks like $\prod_{1 \leqslant j<i \leqslant 5}\left(x_i-x_j\right)^2$ and will evaluate to the given expression as shown by Bob in answer below? $\endgroup$
    – xzczd
    Commented Sep 20, 2022 at 4:50
  • $\begingroup$ Please take a look at my EDIT. Thank you. @xzczd $\endgroup$
    – lotus2019
    Commented Sep 20, 2022 at 7:25

1 Answer 1

4
$\begingroup$
$Version

(* "13.1.0 for Mac OS X x86 (64-bit) (June 16, 2022)" *)

Clear["Global`*"];

Format[x[n_]] := Subscript[x, n]

expr = (x[1] - x[2])^2 (x[1] - x[3])^2 (x[2] - x[3])^2* 
     (x[1] - x[4])^2 (x[2] - x[4])^2 (x[3] - x[4])^2* 
      (x[1] - x[5])^2 (x[2] - x[5])^2 (x[3] - x[5])^2* 
      (x[4] - x[5])^2;

(expr2 = 
   Inactive[Product][(x[i] - x[j])^2, {i, 1, 5}, {j, 1, i - 1}]) // 
     TraditionalForm

enter image description here

expr == expr2 // Activate // Simplify

(* True *)

EDIT: More generally,

s[k_, n_] = Sum[x[v]^k, {v, 1, n}];

mA[n_Integer?Positive] := 
  Table[s[i + j - 2, n], {i, 1, n}, {j, 1, n}];

mAdet[n_Integer?Positive] := Det[mA[n]] // Simplify

(prod[n_] = Inactive[Product][
   (x[i] - x[j])^2, {i, 1, n}, {j, 1, i - 1}]) // 
  TraditionalForm

enter image description here

And @@ Table[mAdet[n] == prod[n] // Activate // Simplify, 
  {n, 1, 6}]

(* True *)

EDIT 2: Add zero to the original expression

(expr3 = expr + prod[5] - Activate[prod[5]] // Simplify) //
 TraditionalForm

enter image description here

$\endgroup$
3
  • $\begingroup$ Thank you for your answer. I edited the question. What I described earlier is not accurate enough. $\endgroup$
    – lotus2019
    Commented Sep 20, 2022 at 7:42
  • $\begingroup$ Thank you for your editing. In my question, I mean whether it is possible to directly add some commands to the code so that it can be directly output into the traditional form of product "expr2". At present, the code you give still needs to get this result "expr" first, and then convert it to the traditional format "expr2" by observing the expression "expr". In fact, it is semi-automatic. Maybe this requirement of mine is relatively difficult and MMA cannot achieve it. Anyway, thank you very much. @Bob Hanlon $\endgroup$
    – lotus2019
    Commented Sep 21, 2022 at 3:23
  • $\begingroup$ Thank you for your EDIT 2. This is very helpful to me. $\endgroup$
    – lotus2019
    Commented Sep 22, 2022 at 7:29

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.