TransWikia.com

Using NIntegrate inside RecurrenceTable

Mathematica Asked by e.g on March 8, 2021

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!

One Answer

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.

Correct answer by Akku14 on March 8, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP