Generating generating expressions for sequences (yes, "generating generating" in the title is correct :) )

Context

In middle (?) school we are taught about sequences and, in particular, we are taught about linear sequences where the nth term is generated with an expression of the form an + b, where a and b are some coefficients. In this challenge, we will deal with sequences generated by polynomials of arbitrary degree.

Task

Given the first m terms of a sequence, find the coefficients of the polynomial of lowest degree that could have generated such a sequence.

A polynomial, and thus the generating expression you are looking for, is to be seen as a function \$p(n)\$ that takes n as an argument and returns

$$a_0 + a_1 n + a_2 n^2 + a_3 n^3 + \cdots + a_k n^k$$

where \$k \geq 0\$ and \$a_i, 0 \leq i \leq k\$ have to be found by you.

You will assume that the m terms you were given correspond to taking n = 0, n = 1, ..., n = m-1 in the generating polynomial above.

Examples

If I am given the sequence [2, 2, 2] then I realize this is a constant sequence and can be generated by a polynomial of degree 0: p(n) = 2.

If I am given the sequence [1, 2, 3] then I realize this cannot come from a constant polynomial but it could come from a linear polynomial p(n) = n + 1, so that is what my output should be. Notice how

p(0) = 1
p(1) = 2
p(2) = 3    # and NOT p(1) = 1, p(2) = 2, p(3) = 3


Input

Your input will be the first terms of a sequence, which you can take in any reasonable format/data type. A standard list is the most obvious choice.

You may assume the input sequence is composed of integers (positive, 0 and negative).

Output

The coefficients of the polynomial of lowest degree that could have generated the input sequence. The output format can be in any sensible way, as long as the coefficients can be retrieved unambiguously from the output. For this, both the value of each coefficient and the degree of each coefficient are important. (e.g. if using a list, [1, 0, 2] is different from [0, 1, 2]).

You can assume the polynomial you are looking for has integer coefficients.

Test cases

For these test cases, the input is a list with the first terms; the output is a list of coefficients where (0-based) indices represent the coefficients, so [1, 2, 3] represents 1 + 2x + 3x^2.

[-2] -&gt; [-2]
[0, 0] -&gt; [0]
[2, 2, 2] -&gt; [2]
[4, 4] -&gt; [4]
[-3, 0] -&gt; [-3, 3]
[0, 2, 4, 6] -&gt; [0, 2]
[2, 6] -&gt; [2, 4]
[3, 7] -&gt; [3, 4]
[4, 8, 12, 16] -&gt; [4, 4]
[-3, -1, 5, 15, 29] -&gt; [-3, 0, 2]
[0, 1, 4, 9] -&gt; [0, 0, 1]
[3, 2, 3, 6, 11] -&gt; [3, -2, 1]
[3, 4, 13, 30, 55] -&gt; [3, -3, 4]
[4, 12, 28, 52, 84] -&gt; [4, 4, 4]
[2, 4, 12, 32, 70] -&gt; [2, 1, 0, 1]
[3, 6, 21, 54] -&gt; [3, -1, 3, 1]
[4, 2, 12, 52, 140] -&gt; [4, -2, -3, 3]
[10, 20, 90, 280] -&gt; [10, 0, 0, 10]
[-2, 8, 82, 352, 1022, 2368, 4738] -&gt; [-2, 4, -1, 4, 3]
[4, 5, 32, 133, 380] -&gt; [4, -2, 0, 2, 1]
[1, 0, 71, 646, 2877, 8996, 22675] -&gt; [1, -1, 0, -3, 0, 3]
[4, 2, 60, 556, 2540, 8094, 20692] -&gt; [4, -2, -1, 0, -2, 3]
[1, 2, -17, 100, 1517, 7966, 28027, 78128, 186265] -&gt; [1, 3, -2, 4, -3, -2, 1]
[4, 5, 62, 733, 4160, 15869, 47290, 118997] -&gt; [4, 3, -1, -3, 1, 0, 1]


Test cases generated with this code



This is code-golf so shortest submission in bytes, wins! If you liked this challenge, consider upvoting it! If you dislike this challenge, please give me your feedback. Happy golfing!
JavaScript (ES7),  193 ... 154  145 bytes
Saved 9 bytes thanks to @Bubbler
Returns \$(a_0,a_1,...,a_k)\$ with some possible trailing zeros.

v=&gt;v.map((_,i)=&gt;(g=(i,m=v.map((n,y)=&gt;v.map((_,x)=&gt;x==i?n:y**x)))=&gt;+m||m.reduce((s,[v],i)=&gt;v*g(0,m.map(([,...r])=&gt;r).filter(_=&gt;i--))-s,0))(i)/g())

Try it online!
(removed the penultimate test case, which requires more precision than IEEE-754 provides)
How?
We use Cramer's rule to solve a system of linear equations based on a square Vandermonde matrix:

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 &lt;n\$:
$$Vn=\begin{pmatrix}
1&amp;0&amp;0&amp;...&amp;0\\
1&amp;1&amp;1&amp;...&amp;1\\
1&amp;2&amp;4&amp;...&amp;2^{n-1}\\
\vdots&amp;\vdots&amp;\vdots&amp;\ddots&amp;\vdots\\
1&amp;n-1&amp;(n-1)^2&amp;...&amp;(n-1)^{n-1}
\end{pmatrix}$$

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&amp;0&amp;0&amp;0&amp;0\\
\color{blue}2&amp;1&amp;1&amp;1&amp;1\\
\color{blue}{12}&amp;2&amp;4&amp;8&amp;16\\
\color{blue}{52}&amp;3&amp;9&amp;27&amp;81\\
\color{blue}{140}&amp;4&amp;16&amp;64&amp;256
\end{vmatrix}/|V_5|=\frac{1152}{288}=4$$
The coefficient \$a_1\$ is given by:
$$a_1=\begin{vmatrix}
1&amp;\color{blue}4&amp;0&amp;0&amp;0\\
1&amp;\color{blue}2&amp;1&amp;1&amp;1\\
1&amp;\color{blue}{12}&amp;4&amp;8&amp;16\\
1&amp;\color{blue}{52}&amp;9&amp;27&amp;81\\
1&amp;\color{blue}{140}&amp;16&amp;64&amp;256
\end{vmatrix}/|V_5|=\frac{-576}{288}=-2$$
And so on.