# JavaScript (ES7), <s> 193 ... 154 </s> 145 bytes _Saved 9 bytes thanks to @Bubbler_ Returns \$(a_0,a_1,...,a_k)\$ with some possible trailing zeros. <!-- language-all: lang-javascript --> v=>v.map((_,i)=>(g=(i,m=v.map((n,y)=>v.map((_,x)=>x==i?n:y**x)))=>+m||m.reduce((s,[v],i)=>v*g(0,m.map(([,...r])=>r).filter(_=>i--))-s,0))(i)/g()) [Try it online!](https://tio.run/##nZXfbpswFMbv@xS@tFND/A8Dm8iu@hQRqlBKMqYQKtKhVOq7Z@fYuKXTqkGiEMDi@/yd3zHOr2qozru@eX6JTt1Tfd0X16HYDHFbPVP6yBtWbOihoA1vi3HwxF/Z5IkL3FyKovlx@va6Wl0Yg/v79u2tjfv66feupvTMt0PpnIbVgQreeumWx3HclzDcs3jfHF/qnj4WmyaKGIvOXDBGG7Y@UMau37d3hGwjVXKy7LNeOxmqBSdioR7VwokVJ/hdokexn9lwYm6Y2ThxpBfndkWDTIe6ITpksLNdXN1Y7li6vSE9zun0ECS9Qa@DHpJnnEjwk3NzOHpBjyQiyUkCBnCo/P8mAeA7A7iQjmG@lCEqAwYoAX4tjMhZNiOGSE08IIPE1oJvksxwCR5TnMhSAdMEzpmZh8O4qU1YEaOLhiMVM2MoB3EKBFAo7IxZ0NexmzrYGMcVw2A50ojZ9SDXj9dEYrPhyPGczXrj0Ef6HmNVfqdAV2CbIR2XSCjErS0MmlRn/zD2m5SDGvllpkNpiWcsNeackWpSmn/vPSTPPYWTNQg9S1OImOd4rWyafBFK@kDCcxKTXLgpuCWIDomBy0zkOC5srr5wC8hHR/W5TItLCcs0Ep1lktkciSlsiJQQNi3/thvXAoZ7X1nlXbzv@odq95NWpNiQXXc6d8c6PnYHuqcV/D1d/wA "JavaScript (Node.js) – Try It Online") (removed the penultimate test case, which requires more precision than IEEE-754 provides) ### How? We use [Cramer's rule][1] to solve a system of linear equations based on a square [Vandermonde matrix][2]: 1. Given an input vector of length \$n\$, we build a Vandermonde matrix \$V_n\$ of size \$n\times n\$ with coefficients \$\alpha_i=i,0\le i <n\$: $$Vn=\begin{pmatrix} 1&0&0&...&0\\ 1&1&1&...&1\\ 1&2&4&...&2^{n-1}\\ \vdots&\vdots&\vdots&\ddots&\vdots\\ 1&n-1&(n-1)^2&...&(n-1)^{n-1} \end{pmatrix}$$ 2. Using Cramer's rule, the coefficient \$a_i\$ of the polynomial is computed by taking the determinant of the matrix obtained by replacing the \$i\$-th column of \$V_n\$ with the input vector, and dividing by the determinant of \$V_n\$. ### Example for \$(4,2,12,52,140)\$ The constant coefficient \$a_0\$ is given by: $$a_0=\begin{vmatrix} \color{blue}4&0&0&0&0\\ \color{blue}2&1&1&1&1\\ \color{blue}{12}&2&4&8&16\\ \color{blue}{52}&3&9&27&81\\ \color{blue}{140}&4&16&64&256 \end{vmatrix}/|V_5|=\frac{1152}{288}=4$$ The coefficient \$a_1\$ is given by: $$a_1=\begin{vmatrix} 1&\color{blue}4&0&0&0\\ 1&\color{blue}2&1&1&1\\ 1&\color{blue}{12}&4&8&16\\ 1&\color{blue}{52}&9&27&81\\ 1&\color{blue}{140}&16&64&256 \end{vmatrix}/|V_5|=\frac{-576}{288}=-2$$ And so on. [1]: https://en.wikipedia.org/wiki/Cramer%27s_rule [2]: https://en.wikipedia.org/wiki/Vandermonde_matrix