When I evaluate the following expression in Mathematica, it takes so much time that I don't want to wait for the evaluation to complete. So I think that there must be a better approach.
wewint[lx_?NumericQ, ly_?NumericQ] := NIntegrate[
Cos[lx]*Cos[qx] + Sin[lx]*Sin[qx], {qx, -Pi, Pi}, {qy, -Pi, Pi},
Method -> Automatic];
NIntegrate[wewint[lx, ly], {lx, -Pi, Pi}, {ly, -Pi, Pi}, Method -> Automatic]
If I use Cos[lx-qx] instead of (Cos[lx]*Cos[qx] + Sin[lx]*Sin[qx]), the effect is the same. In reality, the expression I am working with is much more complicated and it couldn't be calculated analytically.
Cos[lx]*Cos[qx] + Sin[lx]*Sin[qx]orCos[lx]*Cos[qx] + Sin[ly]*Sin[qy]? If the former, than you are performing two unnecessary integrations. Also, as each point evaluated in the second integral requires a full evaluation of the first integral, it will take longer as there is a full init and tear down stage per evaluation. Can they be combined into one? This will eliminate the extra overhead. – rcollyer Dec 10 '12 at 16:48