# Gaussian quadrature with arbitrary weight function

In class, our professor told us how to evaluate the integral $\int_a^bw(x)f(x) dx$ by finding the Gaussian nodes $x_i$ and weight $w_i$ with weight function $w(x)=1$ (also known as Legendre quadrature). However, in homework, I came across with some other weight functions and I don't really know how to handle it.(I tried in google and I couldn't find a regular way of finding the gaussian nodes and that's why I am trying here now)

For example, if we have $\int_0^1 x^4f(x)dx=A_0f(x_0)+A_1f(x_1)$, how should we find $A_0,x_0,A_1,x_1$? And in this circumstance, for which degree of polynomial of $f(x)$ the integration is exact?

And the other question asks us "Derive a two-point integration formula for integrals of the form $\int_{-1}^1f(x)(1+x^2)dx$, which is exact when $f(x)$ is polynomial of degree 3.". Here I can't understand how we can derive a two point integration formula here when our weight function is already quadratic? And why does the question mention the degree of 3? I am confused here.

Furthermore, what if our weight function becomes some analytic functions such as $\frac{1}{\sqrt{1-x^2}}$ and $e^{-x}$? What is the general approach of it?

I really hope somebody can explain to me and help me out. Thanks!

In order to calculate $\int_0^1 x^{4}f(x)\,dx$ you use the Method of Undetermined Coefficients. That is:
Let $f_{i}(x)=x^{i}$. Then, calculate $c=\int_0^1 x^{4}f_{i}(x)\,dx$ and $A_{0} f_{i}(x_{0})+A_{1}f_{i}(x_{1})$. From this, you will get an equation of the form $c=A_{0} x_{0}^{i}+A_{1}x_{1}^{i}$. In this problem, we have 4 unknowns hence to solve for $A_{0}, x_{0}, A_{1}, x_{1}$ you must create 4 equations using this method. From there you can solve for your variables.
The Method of Undetermined Coefficients can work with any weight function, using the integral $\int_a^b w(x)f(x)\,dx$ for each $f_{i}(x)=x^{i}$ as defined in the method above.