Derive a numerical integration formula (i.e. determine A,B,C and $\alpha$) of the form
$$\int_{-1}^{1}|x|f(x) \approx Af(-\alpha)+Bf(0) + Cf(\alpha) $$
that is exact for polynomials of degree $\leq 2$. Is it exact for polynomials of degree greater than 2?
I'm quite sure we use Gaussian quadrature for this, but I don't really understand the method too well an don't know how to apply it. We are not given the nodes or anything so I don't know how to start.
Clearly any odd powers in the polynomial will integrate out to zero.
$$\int_{-1}^1 |x| \left( a x^4 + b x^2 + c\right)\mathrm{d}x = \frac{a}{3}+\frac{b}{2}+c$$
Assume $f(x) = a x^4 + b x^2 + c$
$$A f(-\alpha) + B f(0) + C f(\alpha) = a \alpha ^4 (A+C)+\alpha ^2 b (A+C)+c (A+B+C)$$
$$ A + B + C = 1$$ $$ \alpha^2 (A+C) = \frac{1}{2}$$ $$ \alpha^4 (A+C) = \frac{1}{3}$$
This gives
$$ A + C = \frac{3}{4} $$ $$ B = \frac{1}{4} $$ $$ \alpha = \sqrt{\frac{2}{3}}$$
So we can for example pick $A = C$
$$\int_{-1}^1 |x| f(x) \mathrm{d} x \approx \frac{3}{8} f\left(-\sqrt{\frac{2}{3}}\right) + \frac{1}{4} f(0) + \frac{3}{8} f\left(\sqrt{\frac{2}{3}}\right) $$