# Gaussian quadrature with a to $[0,1]$ reference domain instead of a $[-1,1]$ reference domain?

For 1-d Gaussian quadrature with two points per element we have the following formula to transform an integral from an arbitrary domain $[a, b]$ to the reference domain $[-1,1]$ on which various Gaussian quadrature formulas for weights node points are defined -

$$\int_a^b f(x) dx \approx \frac{b-a}{2}\sum_{i=1}^n w_i f(\frac{b-a}{2}x_i + \frac{a+b}{2})$$

where, in the case of $n = 2$ points we have $x_i = \pm \frac{1}{\sqrt{3}}$ and $w_i = 1$. See Gaussian Quadrature

Now I am wondering what is the equivalent transformation if our reference domain is $[0,1]$ instead of $[-1,1]$. We will obviously have to change the transformation that gets applied to $x_i$ and the scaling factor outside the integral. Do we also have to transform the weights?

Consider first the mapping from $[-1,1]$ to $[a,b]$, that is, $$g_1(\widehat{x})=\frac{b-a}{2}\widehat{x}+\frac{b+a}{2},$$ which clearly satisfies $g_1(-1)=a$ and $g_1(1)=b$. Then by the change of variables $$\int_a^b f(x)\,\mathrm{d}x = \int_{-1}^1 f(g_1(\widehat{x}))\frac{b-a}{2}\,\mathrm{d}\widehat{x} = \frac{b-a}{2}\int_{-1}^1 f(g_1(\widehat{x}))\,\mathrm{d}\widehat{x},$$ where the integral on the right hand side can be computed using the quadrature rule $$\int_{-1}^1 f(g_1(\widehat{x}))\,\mathrm{d}\widehat{x} = \sum_{i=1}^n \widehat{w}_i f(g_1(\widehat{x}_i))$$ with some points $\widehat{x}_i \in [0,1]$ and weights $\widehat{w}_i$, $i \in \{1,\cdots,n\}$.
Next consider the mapping from $[0,1]$ to $[a,b]$, that is, $$g_2(\widetilde{x})=(b-a)\widetilde{x}+a,$$ which satisfies $g_2(0)=a$ and $g_2(1)=b$. Similarly as before $$\int_a^b f(x)\,\mathrm{d}x = \int_0^1 f(g_2(\widetilde{x}))(b-a)\,\mathrm{d}\widetilde{x} = (b-a)\int_0^1 f(g_2(\widetilde{x}))\,\mathrm{d}\widetilde{x},$$ and $$\int_0^1 f(g_2(\widetilde{x}))\,\mathrm{d}\widetilde{x}=\sum_{i=1}^n \widetilde{w}_i f(g_2(\widetilde{x}_i))$$ for some other points $\widetilde{x}_i \in [0,1]$ and weights $\widetilde{w}_i$, $i \in \{1,\cdots,n\}$.
Combining some of the previous equations we get $$(b-a)\int_0^1 f(g_2(\widetilde{x}))\,\mathrm{d}\widetilde{x}=\frac{b-a}{2}\int_{-1}^1 f(g_1(\widehat{x}))\,\mathrm{d}\widehat{x}$$ or, equivalently, $$\sum_{i=1}^n \widetilde{w}_i f(g_2(\widetilde{x}_i)) = \frac{1}{2} \sum_{i=1}^n \widehat{w}_i f(g_1(\widehat{x}_i)).$$ This holds true if $$\widetilde{w}_i = \frac{\widehat{w}_i}{2}$$ and $$(b-a)\widetilde{x}_i+a = \frac{b-a}{2}\widehat{x}_i+\frac{b+a}{2} \Rightarrow \widetilde{x}_i = \frac{1}{2}\widehat{x}_i+\frac{1}{2}$$ for every $i\in\{1,\cdots,n\}$. In conclusion, we can get the quadrature $(\widetilde{x}_i,\widetilde{w}_i)$ for the domain $[0,1]$ from the quadrature $(\widehat{x}_i,\widehat{w}_i)$ for the domain $[-1,1]$ by using the formulae \left\{ \begin{aligned} \widetilde{w}_i &= \frac{\widehat{w}_i}{2}, \\ \widetilde{x}_i &= \frac{1}{2}\widehat{x}_i+\frac{1}{2}. \end{aligned} \right.