I am reading through some exercises of the chapter I am reading about numerical integration. I stumbled upon the following question:
Find the formula $\int_0^1 f(x) \,dx \simeq A_0 f(x_0) + A_1 f(x_1)$ that is exact for functions of the form $f(x) = a e^x + b \cos(\pi x/2)$
I know that for any polynomial of degree $\leq n$ its integral can be exactly estimated (that is, is equal to) by the formula $$ \int_a^b f(x) \,dx = \sum_{i=0}^{n} A_i f(x_i) $$ where $A_i = \int_a^b \ell (x)\, dx$ (Lagrange fundamental polynomial) for $n+1$ distinct nodes $x_i \quad 0 \leq i \leq n$.
However, the $f$ in the exercise is clearly not a polynomial. So no idea how to find such a formula that is exact as with numerical integration for polynomials. Can you help?