Is there a simple and efficient way to evaluate Elementary Symmetric Polynomials in Python? [closed

preview_player
Показать описание

Below, you can find the text related to the question/problem. In the video, the question will be presented first, followed by the answers. If the video moves too fast, feel free to pause and review the answers. If you need more detailed information, you can find the necessary sources and links at the bottom of this description. I hope this video has been helpful, and even if it doesn't directly solve your problem, it will guide you to the source of the solution. I'd appreciate it if you like the video and subscribe to my channel!Is there a simple and efficient way to evaluate Elementary Symmetric Polynomials in Python? [closed]

I'm currently working on a project that involves evaluating Elementary Symmetric Polynomials (or "ESPs") using Python. So essentially I need to create a function that :
Elementary Symmetric Polynomials

takes a non-empty list x (of numeric values) as an input
outputs a list containing all the corresponding ESP evaluations, where each ESP is in len(x) variables (also, by convention, we could say that the "0-th" ESP is always equal to 1)

takes a non-empty list x (of numeric values) as an input
outputs a list containing all the corresponding ESP evaluations, where each ESP is in len(x) variables (also, by convention, we could say that the "0-th" ESP is always equal to 1)
For example, if my input list is x = [x1, x2, x3], then I want the function to output the list [1, x1 + x2 + x3, x1 * x2 + x1 * x3 + x2 * x3, x1 * x2 * x3].
x = [x1, x2, x3]
[1, x1 + x2 + x3, x1 * x2 + x1 * x3 + x2 * x3, x1 * x2 * x3]
all
polynomial time
I then stumbled upon Newton's identities (linking ESPs to power sums), and it does the job in a cubic time complexity ! For my purposes this time complexity is good enough, but is there a more efficient way of evaluating ESPs ? After some research, I didn't see any Stack Overflow posts with explicit code to solve my problem (although this Math Stack Exchange post does mention some algorithms). I also went through the following resources :
Newton's identities
cubic time complexity
but is there a more efficient way of evaluating ESPs ?
explicit
this Math Stack Exchange post

The pySymmPol package (and the corresponding article) : it looked promising, but in fact it doesn't support polynomial evaluation ...
This article, describing a fast algorithm to evaluate ESPs (with floating-point inputs) : unfortunately, it doesn't seem like the authors provide any code, and their algorithms seem very tedious to implement (also I think they said their code was written in C)

The pySymmPol package (and the corresponding article) : it looked promising, but in fact it doesn't support polynomial evaluation ...
The pySymmPol package
the corresponding article
This article, describing a fast algorithm to evaluate ESPs (with floating-point inputs) : unfortunately, it doesn't seem like the authors provide any code, and their algorithms seem very tedious to implement (also I think they said their code was written in C)
This article
very tedious
Additionally, here is the improved function that I implemented to solve my initial problem, using Newton's identities :
Additionally, here is the improved function that I implemented to solve my initial problem, using Newton's identities :
def evaluate_all_ESPs(x: list) - list:
"""
This function evaluates all the Elementary Symmetric Polynomials (or
"ESPs") in `len(x)` variables on the given input list of numeric values,
and returns the corresponding `len(x) + 1` evaluations in a list

If we label these evaluated ESPs as `e[k]` (where `0 = k = len(x)`),Source of the question:

Question and source license information:
Рекомендации по теме
join shbcf.ru