What does it mean by the approximation $\int_a^bf(x)dx\approx\sum_{i=0}^nA_if(x_i)$ is exact for all polynomials of degree up to $2n+1$? There is these notes about Gaussian Quadrature and I am trying to understand what does the sentence "is exact for all polynomials of degree up to $2n+1$" actually mean.
Gaussian Quadrature - General $n$:
Given an interval $[a,b]$ and a natural number $n$, we want to find constants $A_i$ and $x_i\in[a,b]$ such that the approximation
$$\int_a^bf(x)dx\approx\sum_{i=0}^nA_if(x_i)$$
is exact for all polynomials of degree up to $2n+1$.
My doubts:
Does the sentence mean for all $f(x)$ that has the degree $0$ to $2n+1$, we have $\int_a^bf(x)dx=\sum_{i=0}^nA_if(x_i)$ ? What does the word exact mean? And what does it mean by for all polynomials?
Thanks for the help!
 A: You already guessed it mostly: The $A_i$ shall be determined in such a way that the $\approx$ can be replaced with $=$ whenever the function $f$ is in fact a polynomial function of degree up to $2n+1$, i.e., whenever $f(x)=a_{2n+1}x^{2n+1}+a_{2n}x^{2n}+\ldots + a_1x+a_0$.
For example, the simple approximation $\int_a^b f(x)\,\mathrm dx\approx (b-a)\cdot f(a)$ is exact for constant functions, i.e., for all polynomials of degree up to $0$. (In fact, for some lucky choices of $a$ and $b$ this might even be exact for degree $1$ polynomials - can you guess what "lucky" means here?)
A: In order to build the formula that approximates an integral as a sum, Gauss chose to make the formula exact (such that the value of the integral and the sum coincide) for some well-chosen functions $f$.
He chose polynomials for two reasons:


*

*polynomials are smooth functions, they can well approximate smooth functions (provided the degree isn't too high),

*that makes the computation tractable, as polynomials are easy to integrate.
Then by linearity, if the formula is exact for those polynomials, it is also exact for all their linear combinations, and will yield good approximations for smooth functions.
