two point gaussian quadrature to approximate $\int_0^1(1-x)f(x)\text{ dx}$ I want to use two point gaussian quadrature to approximate $$\int_0^1(1-x)f(x)\text{ dx}$$
Because $(1−x)$ is a linear polynomial, polynomials $f$ of degree at most $2n−2=2$ (because we use two point gaussian quadrature $n=2$) can be accurately integrated. So, I would deal with a polynomial $p(x)=a_0+a_1x+a_2x^2$.
Integration yields $$\int_{-1}^1p(x)(1−x) dx=a_0(2)+a_1\left(−\frac{2}{3}\right)+a_2\left(\frac{2}{3}\right)$$
However, the quadrature is of the form $$\int_{-1}^1p(x)(1−x)\text{ dx}≈c_1p(x_1)+c_2p(x_2)$$
So, we have four variables but only three equations. What am I doing wrong here?
 A: The Gauss-Legendre-quadrature is exact for polynomials upto degree 2n-1, if n is the number of points. So, with two points, the formula is exact upto degree 3. The reason is, that 
$$\int_{-1}^1 x^n dx = 0$$
for odd n. So you only need the constant term and the quadratic term, so two points
are enough.
Concrete, you have four equations :
$$c_1+c_2 = 2$$
$$c_1x_1+c_2x_2 = 0$$
$$c_1x_1^2+c_2x_2^2 = \frac{2}{3}$$
$$c_1x_1^3+c_2x_2^3 = 0$$
We multiply the second equation with $x_1^2$ and subtract the fourth to get
$$c_2x_2(x_1^2-x_2^2) = 0$$
This means $x_1=-x_2$ because the abscisses must be different ($x_2=0$ would lead
to equal abscisses).
Inserting this in the second equation we get
$$-c_1x_2+c_2x_2 = 0$$
So it follows 
$$c_1=c_2=1$$
with the first equation.
Finally, inserting this in the third equation, gives $x_1^3=\frac{1}{3}$.
So $x_1=-x_2=\sqrt{\frac{1}{3}}$
Note that this solution only holds for the weighting function w(x) = 1.
For other weighting functions, we need gauss-quadrature. There are
formulas for the weights and the abscisses in the general case.
