Problems with quadratures

55 Views Asked by At

I'm having issues when computing quadrature, and probably there is something I do not get theoretically. I looked everywhere, but no one seems to explain in a good way the problem

I have a simple triangle, with coordinates [[(0, 0); (1, 0); (0, 1)]]

Over this domain I want to compute the integral of $x^2$.

Doing it by hand and wolfram, the result is $0.16$. With quadrature is half the value. I tried different points and weights but the result is always the same. I use the following:

p = [(0.16666666666667, 0.16666666666667),
     (0.16666666666667, 0.66666666666667),                                    
     (0.66666666666667, 0.16666666666667)]
w = [1/6, 1/6, 1/6]

The formula I use is

res = 0;

for i = 1:size(p,1)

$res = res + f(p_i) * f(p_i) * w_i;$

end

value = res;  

where $f(x,y) = x$

1

There are 1 best solutions below

7
On BEST ANSWER

For the constant integrand one, the weights sum to $\dfrac12$, which is the correct area.


The true integral is

$$\int_0^1\int_0^{1-x}x^2\,dy\,dx=\int_0^1 x^2(1-x)\,dx=\frac1{12}.$$

The numerical estimate,

$$\frac16\left(\frac1{36}+\frac1{36}+\frac4{9}\right)=\frac1{12}.$$