I am currently working on a project for calculating polynomial shifts via python of nth degree. The user can input n amount of inputs which get stored in an array that then get converted via the shift and turned back into a new polynomial. The problem is, the higher the degree of n, the more calculations necessary to turn the shifted value to it's polynomial coefficient:
What the program should do is add and multiply all the values uniquely and save the result in a new array:
e.g. for a polynomial of degree 4, it will have inputs [a,b,c,d]
shiftedPCL[0] = a + b + c + d
shiftedPCL[1] = a*b + b*c + c*d + a*c + b*d + a*d
shiftedPCL[2] = a*b*c + b*c*d + a*b*d + a*c*d
shiftedPCL[3] = a*b*c*d
The first and last lines of the equations can be solved simply by summing and multiplying all the values in a list respectively, and I have created a simple recursive code to calculate the second to last line of equations using recursion, but for n greater than 3 it is useless, as it cannot calculate any lines that aren't the first, last or second to last.
This is why I would like to know if there's a way to add and multiply all elements in a list as shown above (for lists of any length).