2
$\begingroup$

I'm trying to solve self-consistent equations of the form

RecurrenceTable[{d[n] == NIntegrate[(d[n - 1]/Sqrt[((1/3) + (2/9) (Cos[kx] + Cos[(kx + Sqrt[3] ky)/2] + Cos[(kx - Sqrt[3] ky)/2]))^2 + d[n - 1]^2]), {kx,0,4}, {ky,0,4}], d[0] == 1}, d, {n, 1, 10}]

However the above expression, when evaluated, produces the following error: enter image description here enter image description here enter image description here enter image description here

and the output:

{NIntegrate[d[(1 + 0) - 1]/
  Sqrt[(1/3 + 
     2/9 (Cos[kx] + Cos[(kx + Compile`$53) Compile`$56] + 
        Cos[(kx - Compile`$53) Compile`$56]))^2 + 
   d[(1 + 0) - 1]^2], {kx, 0, 4}, {ky, 0, 4}], 
 NIntegrate[d[(1 + 1) - 1]/
  Sqrt[(1/3 + 
     2/9 (Cos[kx] + Cos[(kx + Compile`$53) Compile`$56] + 
        Cos[(kx - Compile`$53) Compile`$56]))^2 + 
   d[(1 + 1) - 1]^2], {kx, 0, 4}, {ky, 0, 4}]}

Any help would be greatly appreciated, thank you!

$\endgroup$
  • 2
    $\begingroup$ This doesn't use RecurrenceTable but d[0]=1; d[n_]:=d[n]=NIntegrate[d[n-1]/Sqrt[(1/3 +2/9(Cos[kx]+Cos[(kx+Sqrt[3] ky)/2]+Cos[(kx-Sqrt[3]ky)/2]))^2+d[n-1]^2],{kx,0,4},{ky,0,4}]; Table[d[i],{i,1,10}] instantly gives you your table of results without any errors. $\endgroup$ – Bill Mar 18 at 4:49
4
$\begingroup$

Define NIntegrate... as a numerical function:

nint[uu_?NumericQ] := 
    NIntegrate[(uu/Sqrt[((1/
       3) + (2/9) (Cos[kx] + Cos[(kx + Sqrt[3] ky)/2] + 
        Cos[(kx - Sqrt[3] ky)/2]))^2 + uu^2]), 
{kx, 0, 4}, {ky, 0,4}]

RecurrenceTable[{d[n] == nint[d[n - 1]], d[0] == 1}, d, 
    {n, 1, 10}]

(*   {15.1676, 15.9952, 15.9957, 15.9957, 15.9957, 
      15.9957, 15.9957, 15.9957, 15.9957, 15.9957}   *)

The same as @Bill got in his comment.

| improve this answer | |
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.