Symmetry

Symmetric polynomials

A polynomial that does not change when its variables are shuffled can always be rewritten using just a few building blocks. That is why you can know the sum of the squares of the roots of an equation without solving it.

The building blocks

A polynomial in x1,…,xnx_1, \dots, x_n is symmetric when every permutation of the variables leaves it unchanged. The elementary symmetric polynomials are

e1=∑ixi,e2=∑i<jxixj,…,en=x1x2⋯xn, e_1 = \sum_i x_i, \qquad e_2 = \sum_{i < j} x_i x_j, \qquad \dots, \qquad e_n = x_1 x_2 \cdots x_n ,

so eke_k is the sum of all products of kk different variables. They are exactly the coefficients that appear when a product of linear factors is multiplied out (Vieta's formulas):

(t−x1)(t−x2)⋯(t−xn)=tn−e1tn−1+e2tn−2−⋯+(−1)nen. (t - x_1)(t - x_2)\cdots(t - x_n) = t^n - e_1 t^{n-1} + e_2 t^{n-2} - \dots + (-1)^n e_n .

Two other families are the power sums pk=x1k+⋯+xnkp_k = x_1^k + \dots + x_n^k and the complete homogeneous polynomials hkh_k, the sum of all monomials of degree kk.

The fundamental theorem

Every symmetric polynomial is a polynomial in e1,…,ene_1, \dots, e_n, in exactly one way. The proof is an algorithm, and it is the one the library runs.

Order the monomials lexicographically. Because ff is symmetric, its leading monomial x1a1⋯xnanx_1^{a_1} \cdots x_n^{a_n} has a1≥a2≥⋯≥ana_1 \ge a_2 \ge \dots \ge a_n (otherwise a permutation of it would be larger). The product

e1 a1−a2 e2 a2−a3⋯en an e_1^{\,a_1 - a_2}\, e_2^{\,a_2 - a_3} \cdots e_n^{\,a_n}

has the same leading monomial. Subtract the right multiple of it from ff: what is left is symmetric with a smaller leading monomial. Repeat until nothing is left.

For f=x2+y2f = x^2 + y^2: the leading monomial is x2x^2, matched by e12=x2+2xy+y2e_1^2 = x^2 + 2xy + y^2. The difference is −2xy=−2e2-2xy = -2e_2. So x2+y2=e12−2e2x^2 + y^2 = e_1^2 - 2e_2.

import { ring, elementary, powerSum, completeHomogeneous, isSymmetric, toElementary } from "@ratmath/structures";

const R = ring("x, y, z");
String(elementary(R, 2));                    // "xy + xz + yz"
String(powerSum(R, 3));                      // "x³ + y³ + z³"
isSymmetric(R.poly("x^2 y + y^2 z + z^2 x")); // false: only cyclic shifts fix it

const { polynomial, ring: E } = toElementary(powerSum(R, 3));
String(polynomial);                          // "e1³ − 3e1·e2 + 3e3"
E.vars;                                      // ["e1", "e2", "e3"]
// substituting the elementary polynomials back recovers the original
polynomial.compose([elementary(R, 1), elementary(R, 2), elementary(R, 3)]).equals(powerSum(R, 3));   // true

Roots without solving

If x1,…,xnx_1, \dots, x_n are the roots of tn+cn−1tn−1+⋯+c0t^n + c_{n-1}t^{n-1} + \dots + c_0, Vieta's formulas give ek=(−1)kcn−ke_k = (-1)^k c_{n-k}. Any symmetric expression in the roots is then a polynomial in the coefficients. The roots of t3−2t2−5t+6t^3 - 2t^2 - 5t + 6 have e1=2e_1 = 2, e2=−5e_2 = -5, e3=−6e_3 = -6, so the sum of their cubes is e13−3e1e2+3e3=8+30−18=20e_1^3 - 3e_1e_2 + 3e_3 = 8 + 30 - 18 = 20. (The roots are 1, −2 and 3, and indeed 1−8+27=201 - 8 + 27 = 20.)

The formulas for power sums are Newton's identities, and the discriminant is the symmetric polynomial ∏i<j(xi−xj)2\prod_{i<j}(x_i - x_j)^2 written in the coefficients. The same theorem is the starting point of Galois theory: the symmetric functions of the roots are the ones that lie in the base field.

Try itEdit the code and run it with @ratmath/structures and Core's Rational in scope. The last line's value is shown; PRINT(…) adds lines, TEX(…) typesets math.
Ctrl/⌘ + Enter runs