I have the following term which I would like to express correctly in Mathematica:

$$ \prod_{j=1,j\neq i}^m(\rho_i-\rho_j) $$

Can you please help?

  • 1
    $\begingroup$ The question is unclearly formulated. Is it a product by $j$ or by $i,j$? $\endgroup$ – user64494 Jun 3 at 6:36

Long form:

Product[(ρ[i] - ρ[j]), {i, 1, m}, {j, i + 1, m}] Product[(ρ[i] - ρ[j]), {i, 1, m}, {j, 1, i - 1}]

By observing that each factor occurs twice (up to sign):

Product[ - (ρ[i] - ρ[j])^2, {i, 1, m}, {j, i + 1, m}]

By counting the signs:

(-1)^(m (m - 1)/2) Product[(ρ[i] - ρ[j])^2, {i, 1, m}, {j, i + 1, m}]
  • $\begingroup$ Thank you so much. You mean without the ^2 cous its not in the question, but it helped. $\endgroup$ – Y.L Jun 2 at 20:51
  • $\begingroup$ Yes the square is in the question: every term occurs twice (with opposite signs). There should be a $(-1)^{m(m-1)/2}$ factor too, to account for these signs. $\endgroup$ – Roman Jun 2 at 20:59
  • $\begingroup$ @Roman Huh, I completely forgot about the sign. Thanks for pointing this out! $\endgroup$ – Henrik Schumacher Jun 2 at 21:01


ClearAll[ prod]
prod[m_, i_] := Product[ρ[i] - ρ[j], {j, DeleteCases[Range[m], i]}]

prod[5, 2]

(-ρ[1] + ρ[2]) (ρ[2] - ρ[3]) (ρ[2] - ρ[4]) (ρ[2] - ρ[5])


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.