# How to compute Double Integral of highly oscillating function?

2 views (last 30 days)
Junxian on 21 Nov 2013
Answered: Mike Hosea on 21 Nov 2013
I encountered a problem of computing double integral of highly oscillating function such as:
integrate sin(a*(x-y)) where a is constant (i.e. 10) x and y are variables, the lower and upper bound for x and y are the same from 0 to 100
I tried the built-in function 'integral2', which gives me large error.
Can anyone please share some MATLAB scripts or ideas that accurately compute the above quadrature?

Mike Hosea on 21 Nov 2013
So I assume you saw this:
>> a = 10;
>> f = @(x,y)sin(a*(x-y))
f =
@(x,y)sin(a*(x-y))
>> integral2(f,0,100,0,100,'method','tiled')
Warning: Reached the maximum number of function evaluations (10000). The
result fails the global error test.
> In funfun\private\integral2Calc>integral2t at 129
In funfun\private\integral2Calc at 9
In integral2 at 106
ans =
-2.655339166047913
The warning just tells you that the integration was never completed, so the answer is not really an answer. You could divide the region into smaller regions, but instead try the iterated method.
>> integral2(f,0,100,0,100,'method','iterated')
ans =
-3.013333361769528e-12