ASKSAGE: Sage Q&A Forum - Individual question feedhttps://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Sun, 19 Jul 2020 12:20:51 -0500What are these extra terms in symmetric polynomial calculations?https://ask.sagemath.org/question/52563/what-are-these-extra-terms-in-symmetric-polynomial-calculations/I am trying to calculate the discriminant of the cubic using symmetric polynomials, here is my attempt:
P = PolynomialRing(QQ, 'x', 3)
x = P.gens()
S = SymmetricFunctions(QQ)
e = SymmetricFunctions(QQ).e()
def nice_symmetric_poly(coeffs, u):
v = var(coeffs)
return sum(x[1]*product(v[i] for i in x[0]) for x in list(u))
d = (x[0]-x[1])*(x[0]-x[2])*(x[1]-x[2])
u = e.from_polynomial(d^2)
nice_symmetric_poly('a b c d e', u)
This gives me u:
e[2, 2, 1, 1] - 4*e[2, 2, 2] - 4*e[3, 1, 1, 1] + 18*e[3, 2, 1] - 27*e[3, 3] - 8*e[4, 1, 1] + 24*e[4, 2]
and the nice polynomial version:
b^2*c^2 - 4*b^3*d - 4*c^3 + 18*b*c*d - 8*b^2*e - 27*d^2 + 24*c*e
but I was expecting the result from here https://www.johndcook.com/blog/2019/07/14/discriminant-of-a-cubic/
Δ = 18bcd – 4b³d + b²c² – 4c³ – 27d².
I don't understand why these "e" terms exist: - 8*b^2*e + 24*c*e
and why is there anything with a e[4] in it inside `u`.
Thank you for any insight into this problem.Sun, 19 Jul 2020 11:21:45 -0500https://ask.sagemath.org/question/52563/what-are-these-extra-terms-in-symmetric-polynomial-calculations/Answer by nbruin for <p>I am trying to calculate the discriminant of the cubic using symmetric polynomials, here is my attempt:</p>
<pre><code>P = PolynomialRing(QQ, 'x', 3)
x = P.gens()
S = SymmetricFunctions(QQ)
e = SymmetricFunctions(QQ).e()
def nice_symmetric_poly(coeffs, u):
v = var(coeffs)
return sum(x[1]*product(v[i] for i in x[0]) for x in list(u))
d = (x[0]-x[1])*(x[0]-x[2])*(x[1]-x[2])
u = e.from_polynomial(d^2)
nice_symmetric_poly('a b c d e', u)
</code></pre>
<p>This gives me u:</p>
<pre><code>e[2, 2, 1, 1] - 4*e[2, 2, 2] - 4*e[3, 1, 1, 1] + 18*e[3, 2, 1] - 27*e[3, 3] - 8*e[4, 1, 1] + 24*e[4, 2]
</code></pre>
<p>and the nice polynomial version:</p>
<pre><code>b^2*c^2 - 4*b^3*d - 4*c^3 + 18*b*c*d - 8*b^2*e - 27*d^2 + 24*c*e
</code></pre>
<p>but I was expecting the result from here <a href="https://www.johndcook.com/blog/2019/07/14/discriminant-of-a-cubic/">https://www.johndcook.com/blog/2019/0...</a></p>
<pre><code>Δ = 18bcd – 4b³d + b²c² – 4c³ – 27d².
</code></pre>
<p>I don't understand why these "e" terms exist: - 8<em>b^2</em>e + 24<em>c</em>e</p>
<p>and why is there anything with a e[4] in it inside <code>u</code>.</p>
<p>Thank you for any insight into this problem.</p>
https://ask.sagemath.org/question/52563/what-are-these-extra-terms-in-symmetric-polynomial-calculations/?answer=52564#post-id-52564If you use `u.expand(3) == d^2` (as mentioned in the documentation of `from_polynomial`) I get equality. With the same trick you can then see what `e[4,2].expand(3)` is supposed to mean and it seems to be 0. The same for `e[4,1,1].expand(3)`. So, it seems that the routine is at least internally consistent. It shouldn't include 0-functions in its representations, though; that's just confusing.
I suspect what's happening: it's converting to symmetric functions through another basis (monomial basis, where the indexing is by a non-increasing exponent vector, taken to be the exponents of the leading monomial) and then it converts to the elementary basis in a way that's valid for symmetric functions in an arbitrary number of variables, at the cost of including loads of 0 terms for particular realizations (fair enough, because at this point the system doesn't know the number of variables that the symmetric function is in any more)
It looks like `u.restrict_parts(3)` culls the bits you're not interested in.
I've seen this before: in principle combinatorics and algebra mean the same thing when they talk about symmetric functions, but their motivating questions for studying them are so different that their notations and conventions diverge to the point of being incompatible.Sun, 19 Jul 2020 12:20:51 -0500https://ask.sagemath.org/question/52563/what-are-these-extra-terms-in-symmetric-polynomial-calculations/?answer=52564#post-id-52564