Mathematica 9 is now available
Services & Resources / Wolfram Forums / MathGroup Archive
-----

MathGroup Archive 2011

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

Search the Archive

Re: how to remove $RecursionLimit::reclim: and $IterationLimit::itlim:

  • To: mathgroup at smc.vnet.net
  • Subject: [mg115387] Re: how to remove $RecursionLimit::reclim: and $IterationLimit::itlim:
  • From: Daniel Lichtblau <danl at wolfram.com>
  • Date: Mon, 10 Jan 2011 02:34:39 -0500 (EST)

----- Original Message -----
> From: "tarun dutta" <tarunduttaz at gmail.com>
> To: mathgroup at smc.vnet.net
> Sent: Sunday, January 9, 2011 1:17:19 AM
> Subject: [mg115363] how to remove $RecursionLimit::reclim: and $IterationLimit::itlim:
> Do[Print[n = 5;
> q = 1;
> Print["P= ", p, " Q=", q];
> d[n + 1] = 0; g[n + 1] = 0;
> d[i_] = re[i] + I*im[i];
> g[i_] = ree[i] + I*imm[i];
> conj[a_] := ComplexExpand[Conjugate[a]]
> f1 = Together[
> Sum[6*p*Sqrt[i + 1]*d[i]*
> conj[d[i + 1]]*(Sum[
> Sqrt[i]*g[i]*conj[g[i - 1]], {i, 0, n}]) +
> 6*p*Sqrt[i]*d[i]*
> conj[d[i - 1]]*(Sum[
> Sqrt[i + 1]*g[i]*conj[g[i + 1]], {i, 0, n}]) + (-q*i +
> i (i - 1))* d[i]*conj[d[i]], {i, 0, n}]];
> f2 = Together[
> Sum[6*p*Sqrt[i + 1]*g[i]*
> conj[g[i + 1]]*(Sum[
> Sqrt[i]*d[i]*conj[d[i - 1]], {i, 0, n}]), {i, 0, n}] +
> Sum[6*p*Sqrt[i]*g[i]*
> conj[g[i - 1]]*(Sum[
> Sqrt[i + 1]*d[i]*conj[d[i + 1]], {i, 0, n}]) + (-q*i +
> i (i - 1)) g[i]*conj[g[i]], {i, 0, n}]];
> f = Plus[f1, f2];
> c = Expand@
> ComplexExpand[
> Sum[d[i]*conj[d[i]] + g[i]*conj[g[i]], {i, 0, n}]] == 1;
> v = Join[Array[re, n + 1, 0], Array[im, n + 1, 0],
> Array[ree, n + 1, 0], Array[imm, n + 1, 0]];
> Timing[NMinimize[{f, c}, v,
> Method -> {"RandomSearch", Method -> "InteriorPoint"}]]], {p, 0,
> 2/10, 1/1000}]
> (*table=Table[Block[{p=pi,q=qi},min=First[NMinimize[{f,c},v,Method->{\
> "RandomSearch",Method->"InteriorPoint"}]];
> Print[p,Tab,q,Tab,min];{p,q,min}],{pi,0,2},{qi,0,2}];*)
> 
> P= 0 Q=1
> 
> $RecursionLimit::reclim: Recursion depth of 256 exceeded. >>
> 
> $RecursionLimit::reclim: Recursion depth of 256 exceeded. >>
> 
> $RecursionLimit::reclim: Recursion depth of 256 exceeded. >>
> 
> General::stop: Further output of $RecursionLimit::reclim will be
> suppressed during this calculation. >>
> 
> $IterationLimit::itlim: Iteration limit of 4096 exceeded. >>
> 
> $IterationLimit::itlim: Iteration limit of 4096 exceeded. >>
> 
> $IterationLimit::itlim: Iteration limit of 4096 exceeded. >>
> 
> General::stop: Further output of $IterationLimit::itlim will be
> suppressed during this calculation. >>
> 
> 
> 
> my problem is that how will I remove this kind of error?
> give some valuable insight
> regards,
> tarun

If you delimit your definitions with semicolons, in this case placing one prior to "f1=" then the recursion/iteration issue will disappear.

Replacing NMinimize by FindMinimum will make the code substantially faster, with no loss in quality. I believe I may have made this observation in prior responses.

You have been asking substantially similar questions since early October. It rather seems that one day's worth of code+debug has become nearly 100 days for getting the code in order (or not). If this is largely your own cost, or a project that is usually on back-burner, then no big deal. But I have to hope you are not working against an employer's deadline. Or worse (for someone else), on a time-plus-expenses contract.

Daniel Lichtblau
Wolfram Research



  • Prev by Date: Re: Summed Area Table / Integral Image
  • Next by Date: Re: How to change the directory for the docs?
  • Previous by thread: how to remove $RecursionLimit::reclim: and $IterationLimit::itlim:
  • Next by thread: Re: how to remove $RecursionLimit::reclim: and $IterationLimit::itlim: