# Trying to sort the coefficients of the polynomial $(z-a)(z-b)(z-c)…(z-n)$ into a vector

So I have a factored polynomial of the form $(z-a)(z-b)(z-c)\ldots(z-n)$ for $n$ an even positive integer. Thus the coefficient of $z^k$ for $0 \le k < n$ will be the sum of all distinct $n-k$ element products taken from the set $\{a,b,\ldots,n\}$ multiplied by $(-1)^k$, I hope that makes sense, please ask if you need more clarification.

I'm trying to put these coefficients into a row vector with the first column containing the constant coefficient (which would be $abc\ldots n$) and the last column containing the coefficient for $z^n$ (which would be 1).

I imagine there is a way to brute force this with a ton of nested loops, but I'm hoping there is a more efficient way. This is being done in Matlab (which I'm not that familiar with) and I know Matlab has a ton of algorithms and functions, so maybe its got something I can use. Can anyone think of a way to do this?

• You could use the DocPolynom class: mathworks.co.uk/help/techdoc/matlab_oop/f3-28024.html – Jonathan May 6 '12 at 23:30
• This comment needs revision. Let the coefficient vector be $[c_1, c_2, \ldots, c_n],$ with $c_1 = 1$ and $c_n = ab\cdots n.$ Then $c_k = (-1)^k p_k,$ where $p_k$ is a sum of $\binom{n}{k}$ terms; each term is a product of $k$ different elements from $\{a,b, \dots, n \}.$ – user2468 May 6 '12 at 23:37
• Ok thanks J.D. you're right, I edited it so now I mention the alternating sign. – Thoth May 6 '12 at 23:42
• possible duplicate of Algorithm(s) for computing an elementary symmetric polynomial – J. M. is a poor mathematician May 7 '12 at 1:39