Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

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

140 views
Skip to first unread message

tarun dutta

unread,
Jan 9, 2011, 2:17:21 AM1/9/11
to
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

Daniel Lichtblau

unread,
Jan 10, 2011, 2:34:36 AM1/10/11
to

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


Sjoerd C. de Vries

unread,
Jan 10, 2011, 2:36:45 AM1/10/11
to
As far as I can see your definition of conj doesn't include a stop
condition so you always get infinite recursions

Cheers -- Sjoerd

On Jan 9, 8:17 am, tarun dutta <tarundut...@gmail.com> wrote:
> 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,Metho=

DrMajorBob

unread,
Jan 10, 2011, 2:37:43 AM1/10/11
to
It helps if you put ";" after "conj[a_] := ComplexExpand[Conjugate[a]]".

Bobby

On Sun, 09 Jan 2011 01:17:19 -0600, tarun dutta <tarun...@gmail.com>
wrote:

> 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
>


--
DrMaj...@yahoo.com

0 new messages