For a fixed function $f$ defined on $[-1, 1]$, let's define $$G_m(f)=\sum_{k=1}^m w_k^{(m)}f\left(x_k^{(m)}\right)$$ where $x_1^{(m)}, x_2^{(m)}, \ldots, x_m^{(m)}$ are the $m$ roots of the $m$th Legendre Polynomial and $w_1^{(m)}, w_2^{(m)}, \ldots, w_m^{(m)}$ are the corresponding weights demanded by Gaussian Quadrature.
We know that if $p$ is any polynomial of degree less than or equal to $2n-1$, then $$G_n(p)=\int_{-1}^1p(x)\;dx\,.$$
This has the easy corollary that for any polynomial $p$, there is a natural number $n$ such that $$\int_{-1}^1p(x)\;dx=G_n(p)=G_m(p)$$ for any $m\geq n$. The notation here hides the novelty in this result: $G_n$ is calculated vastly differently from $G_m$. The points and weights used in these approximations are different, but it's true nonetheless.
The question is:
Is the converse true? That is, for a fixed continuous function $f$ on $[-1, 1]$ such that there is a natural number $n$ such that $G_n(f)=G_m(f)$ for all $m\geq n$, is it true that $f$ must be a polynomial?
Of course, if $f$ satisfies this property we have that $$\int_{-1}^1f(x)\;dx=G_m(f)$$ for $m\geq n$. I thought this would be a clever twist of usage with the Weierstrass approximation theorem, but it's been a little more involved than that. I've looked into polynomials of best approximation, but I haven't been able to leverage these effectively. One of the stumbling blocks has been that we don't know $G_m(f^2)=G_n(f^2)$ for all $m\geq n$.
One of the things I've been attempting is to understand the set $$\{p: p(x_k^{(n)})=f(x_k^{(n)})\text{ for all }k\text{ and }\deg(p)\leq 2n-1\}\,.$$ Does this set include a polynomial of best approximation for $f$ with degree less than $2n-1$? I don't know. It does have the interpolating polynomial of degree $n-1$. But what relationships do these polynomials share?
Any help is appreciated.
The question was
The answer is trivially negative.
Recall that the symmetric quadrature on the interval symmetric wrt. zero has the form $$Q(f)=\sum_{i=1}^n w_i\bigl(f(x_i)+f(-x_i)\bigr)+w_0f(0)$$ (the case $w_0=0$ is possible).
Because each Gauss-Legendre quadrature is symmetric, it vanishes on any odd function. So, $G_m(f)=0$ for any $m$ and any odd function $f$ and, of course, there are many non-polynomial odd functions. Then the condition in question holds but the assertion is false.
Additionally, also the integral vanishes for integrable odd functions. Then the conjecture is false even with stronger assumption $\displaystyle\int_{-1}^1 f(x)\,\text{d}x=G_m(f)$ for any $m\in\Bbb N$.