I want to construct a gauss integration for the weight function:

$$w(x) = x^{1/2}$$ $\in(0,1)$ of the form: $$\int_{0}^{1}x^{1/2}f(x)dx = w_{1}f(x_{1})+w_{2}f(x_{2})$$ \begin{align*} w_{1}+w_{2} =& \int_{0}^{1}x^{1/2}\cdot 1 dx = \frac{2}{3} \\ w_{1}x_{1}+w_{2}x_{2}=&\int_{0}^{1}x^{1/2}\cdot x dx =\frac{2}{5}\\ w_{1}x_{1}^2+w_{2}x_{2}^2=&\int_{0}^{1}x^{1/2}\cdot x^2 dx =\frac{2}{7}\\ w_{1}x_{1}^3+w_{2}x_{2}^3=&\int_{0}^{1}x^{1/2}\cdot x^3 dx =\frac{2}{9} \end{align*}

Solving the homogeneous system of 4 linear equations we get the solutions:

$$w_{1,2}=\frac{1}{3} \pm \frac{\sqrt{\frac{7}{10}}}{15}$$ $$x_{1,2}=\frac{5}{9} \pm 2 \frac{\sqrt{ \frac{10}{7} }}{9}$$

Therefore we have that : $$\frac{1}{3} + \frac{\sqrt{\frac{7}{10}}}{15} \cdot f \left(\frac{5}{9} + 2 \frac{\sqrt{ \frac{10}{7} }}{9}\right) + \frac{1}{3} - \frac{\sqrt{\frac{7}{10}}}{15} \cdot f \left(\frac{5}{9} - 2 \frac{\sqrt{ \frac{10}{7} }}{9}\right) = 0.54$$ but in R (pracma library)i get a different result:

f = function(x)  x^(1/3)
cc <- gaussLegendre(2, 0, 1);cc
Q <- sum(cc$w * f(cc$x))

Q = 0.75 with different values of $x_{1,2}$ and $w_{1,2}$ Why what I am doing wrong?


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.