Dear all,
I want to solve an intgeral of the following form
\int_0^1\int_x^1(x+y) dydx
using a self implemented Gauss quadrature.
The integral boundaries must be changed to [-1,1], which is done in the following way:
This code does not give the correct answer (the code is verified using the package QuadGK):
function f_example(x,y)
return x + y
end
function custom_gaussquad_change_of_variables(f, n)
nodes, weights = gauss_quadrature_nodes_2d(n)
integral = 0
for i in 1:size(weights)[1]
integral += weights[i] * f_example(1/2*nodes[i, 1]+1/2, (1-nodes[i,1])/2*nodes[i,2] + (1+nodes[i,1])/2) * 1/2 * (1-nodes[i,1])/2
end
return integral
end
When I only need to change the boundary of one integral variable I do not have any problems. Does anyone understand what I do wrong and how I can obtain the correct answer?
Thanks!