Function Repository Resource:

LogSymmetricPolynomial

Source Notebook

Calculate the log of an elementary symmetric polynomial

Contributed by: Pieter-Jan De Smet

ResourceFunction["LogSymmetricPolynomial"][k,{x1,,xn}]

gives the log of the elementary symmetric polynomial of degree k in the variables x1,,xn.

Details

The degree k must satisfy 0kn.
The numbers xi should be real and positive.
The implementation is based on the formula , where the integration is over an anticlockwise circle around the origin. Although in theory this integral is independent of the radius of the circle, in practice, the radius should be chosen so that there are not too many oscillations in the integrand[B]. If all xa are positive, then one can use theorem 12.1 in[B] to find a good radius.

Examples

Basic Examples (2) 

The log of the elementary symmetric polynomial of degree 3 in the 5 variables 0.1, 0.7, 0.2, 4, 6:

In[1]:=
k = 3;
x = {.1, .7, .2, 4, 6};
ResourceFunction["LogSymmetricPolynomial"][k, x]
Out[3]=

Obtain the same result with SymmetricPolynomial:

In[4]:=
Log[SymmetricPolynomial[k, x]]
Out[4]=

Properties and Relations (2) 

SymmetricPolynomial does not work for k large:

In[5]:=
k = 20;
m = 100;
x = RandomReal[{0, 10}, m];
Log[SymmetricPolynomial[k, x]]
Out[8]=

LogSymmetricPolynomial still works for this case:

In[9]:=
ResourceFunction["LogSymmetricPolynomial"][k, x]
Out[9]=

The log of a symmetric polynomial can also be computed directly using Vieta's formulas and numeric input:

In[10]:=
powsum[k_, vars_List] := Total[vars^k]
elsym[0, vars_List] := 1
elsym[1, vars_List] := Total[vars]
elsym[k_ /; k > 1, vars_List] := 1/k*Sum[(-1)^(i - 1) elsym[k - i, vars]*powsum[i, vars], {i, k}]
logsym[k_, vars_List] := Log[elsym[k, vars]]

This calculation gives the same result as LogSymmetricPolynomial, but can be notably slower:

In[11]:=
k = 20;
m = 100;
x = RandomReal[{0, 10}, m];
{logsym[k, x] // Timing, ResourceFunction["LogSymmetricPolynomial"][k, x] // Timing}
Out[14]=

Possible Issues (2) 

The variables xi should be positive:

In[15]:=
ResourceFunction["LogSymmetricPolynomial"][2, {-1, 1.2, 1.3}]
Out[15]=

The variables xi should be numeric:

In[16]:=
Clear[x1, x2, x3]
ResourceFunction["LogSymmetricPolynomial"][2, {x1, x2, x3}]
Out[17]=

Publisher

Pieter DeSmet

Requirements

Wolfram Language 13.0 (December 2021) or above

Version History

  • 1.0.0 – 03 January 2025

Source Metadata

Author Notes

The same integration formula is also valid for complex xa, but it is then more complicated to find a good radius. I have not implemented this.

License Information