MathGroup Archive 2007

[Date Index] [Thread Index] [Author Index]

Search the Archive

NIntegrate and FindRoot error


I have to perform a double integral. To evaluate the integrand I have to use 
FindRoot and this seems to work as I can evaluate the integrand at 
specific points and even make a 3D plot over the whole range. However, when 
I try to use NIntegrate I get a FindRoot::"nlnum" error message:

Here is a simplified version of my code:

Ly = 3;
w = 5;
t2 = 1;
t1[kx_] := 2 t2 Cos[kx/2];

py[kx_, m_ /; m >= 1 && m <= Ly] := p/. FindRoot[(2 Ly + 1) p +ArcTan[ Tan
[p] (t1[kx] - t2)/(t1[kx] + t2)]==m Pi,{p,1}]

WG[kx1_, kx2_] := Sum[Sum[py[kx1, m1] py[kx2, m2],{m1,1,Ly-1}],{m2,1,Ly-1}]

Plot3D[Re[Exp[ I w (a2 - a1)] WG[a1, a2]], {a2, -Pi, Pi}, {a1, -Pi, Pi}]
Plot3D[Im[Exp[ I w (a2 - a1)] WG[a1, a2]], {a2, -Pi, Pi}, {a1, -Pi, Pi}]

NIntegrate[Exp[ I w (a2 - a1)] WG[a1, a2], {a2, -Pi, Pi}, {a1, -Pi, Pi}]

The NIntegrate command fails. It appears to be objecting to my Cos[2 kx] 
function in the FindRoot command. I don't understand why it would object as 
Plot3D over the same integrand worked.

Thanks a lot,
Judy Bunder

  • Prev by Date: Re: Fourier and InverseFourier
  • Next by Date: Re: [Mathematica 6] Format->Magnification does not work on notebook
  • Previous by thread: Re: question
  • Next by thread: Re: NIntegrate and FindRoot error