TITLE: Determine the coefficients of an unknown black-box polynomial
QUESTION [5 upvotes]: Let $p$ be a polynomial of known degree $n$:
$$p(x) = a_0 + a_1 x + \ldots + a_n x^n$$
Suppose we have a magic black box that can evaluate the polynomial for us.  How could one then determine the coefficients $a_i$?  Lagrange polynomials provide a solution, but perhaps we can do better given that we have freedom to choose where to evaluate $p$?
Of course I'm not really sure what I mean by 'better' - minimal number of operations?  Perhaps there are optimal solutions for a given degree, but is tricky in general.  I'll start you off with my solution for the linear case:
$$\begin{align*}a_0 &= p(0) \\ a_1 &= p(1) - a_0\end{align*}$$
And for a quadratic:
$$\begin{align*}
a_0 &= p(0) \\
a_2 &= \frac{1}{2}\left[p(-1) + p(1) - 2a_0\right] \\
a_1 &= p(1) - a_2 - a_0
\end{align*}$$

REPLY [2 votes]: Just evaluate at the integers from $0$ to $n$. You get the right amount of information, and what you can do with it is calculate the successive differences, $\Delta_0(m)=p(m)$, and for $i\ge0$, $\Delta_{i+1}(m)=\Delta_i(m+1)-\Delta_i(m)$. Of course $\Delta_i$ is defined only for the integers from $0$ to $n-i$. Now $p(x)=\sum_{i=0}^n\Delta_i(0)C_i(x)$, where $C_i(x)$ is the $i$-th binomial polynomial, $C_0=1$, and for $i\ge1$, $C_i(x)=C_{i-1}(x)\cdot(x-i+1)/i$. To get the original coefficients $a_m$, of course you need to expand the binomial polynomials, but if you’re doing many of these problems, this last operation needs to be done only once and the results stored.