How does gaussian quadrature work for this example? I'm trying to determine the weights for the following integral using gaussian quadrature:
$\int_{0}^{1} x^2 f(x) \approx w_0 f(0) + w_1 f(a)$
I understand that you write polynomials from $\ x^n$ where n = 0, 1, 2...
I am confused when it comes to evaluating the first couple of lines of this:
if we take $x^0$ then would this yield $\int_{0}^{1} x^2 x^0 = \frac{1}{3} \approx w_0 *0  + w_1$ which implies $\ \frac{1}{3} = w_1$ or is this not how it works? I am quite unsure about this example in specific, if the latter equation is correct, then what would the weight of $w_0$ evaluate to (since it always going to be 0 in the equation)? Also, would the order of precision for this equation be 2?
thank you!
 A: $1)$ It should be $\frac{1}{3}=w_0+w_1$, since $f(x)=x^0=1$ is constant. Next, you impose exactness on $f(x)=x,$ which gives a second equation $$\int\limits_0^1 x\cdot x^2\, dx=w_0\cdot 0+w_1\cdot a,$$ or $$\frac{1}{4}=aw_1.$$ Now, you have a $2\times 2$ system of linear equations that you can solve to find $w_0,$ $w_1.$
$2)$ A Gaussian quadrature rule with $n$ nodes will have a degree of precision of $2n-1.$ If $n=2,$ then the degree of precision would be $3$. However, you need to check if these nodes came from performing Gaussian quadrature, as was claimed. Not every set of nodes is going to give you a Gaussian quadrature rule. It seems like what you’re referring to is the process of undetermined coefficients to find the weights; Gaussian quadrature is more substantial and involves choosing the nodes appropriately. If you want to check exactness in the given rule, with $a$ provided to you, do the process outlined in step 1) to find the weights, then test on $x^2,\cdots$. If you want to choose the weights and one of the nodes, see the other answer. 
A: The formula can't be exact for polynomials of order $3$ because
$$\int_0^1x^2\cdot x(x-a)^2dx>0$$
Because the integrand is positive except at isolated points whereas the integration formula says its value is zero. If it is to be exact for polynomials of order $2$ then we must have
$$\int_0^1x^2\cdot x(x-a)\cdot x^ndx=0$$
For $0\le n<1$. This is kind of trivial in this case but in general with $n$ interior points and the one endpoint $x=0$ you need to construct a polynomial orthogonal to all polynomials of lesser degree with respect to the weight function $x^2\cdot x$ over the interval $(0,1)$. The only polynomial of lesser degree in this case is $f(x)=1$ so we want
$$\int_0^1x^3(x-a)dx=\frac15-\frac14a=0$$
So $a=4/5$. Now we can evaluate
$$\int_0^1x^2(x-a)dx=\frac14-\frac13a=\frac14-\frac13\cdot\frac45=-\frac1{60}=w_0(0-a)=-\frac45w_0$$
So $w_0=\frac1{48}$. And again
$$\int_0^1x^2\cdot xdx=\frac14=w_1(a)=\frac45w_1$$
So $w_1=\frac5{16}$. Check:
$$\begin{align}\int_0^1x^2\cdot1dx&=\frac13=\frac1{48}(1)+\frac5{16}(1)\\
\int_0^1x^2\cdot xdx&=\frac14=\frac1{48}(0)+\frac5{16}\left(\frac45\right)\\
\int_0^1x^2\cdot x^2dx&=\frac15=\frac1{48}(0)+\frac5{16}\left(\frac45\right)^2\end{align}$$
This is called left-Radau-Jacobi integration.
A: With Gaussian quadrature  we have $$\int_{-1}^1g(x)dx \approx g(-1/{\sqrt 3})+ g(1/{\sqrt 3})$$
Thus $$\int_0^1x^2f(x)dx=1/2 \int_{-1}^1 (\frac {t+1}{2})f(\frac {t+1}{2})dt\approx $$
$$(1/2)\int_{-1}^1 g(t)dt \approx (1/2) [g(-1/{\sqrt 3})+ g(1/{\sqrt 3})]$$ 
