Re: Re: Weird NMinimize behaviour
- To: mathgroup at smc.vnet.net
- Subject: [mg97571] Re: [mg97556] Re: [mg97518] Weird NMinimize behaviour
- From: Bob Hanlon <hanlonr at cox.net>
- Date: Mon, 16 Mar 2009 04:21:35 -0500 (EST)
- Reply-to: hanlonr at cox.net
I am running version 7.0.1.0 on a Mac and get 21.159 I restricted your function definitions to numeric arguments. $Version 7.0 for Mac OS X x86 (64-bit) (February 19, 2009) F2[n1_?NumericQ,k1_?NumericQ,n2_?NumericQ,k2_?NumericQ]:= (-1)^(n1+k1+n2+k2)/(360 \[Pi]^4) (8 \[Pi]^4-60\[Pi]^2 Mod[-Subscript[z,k1]+Subscript[z,n1]- Subscript[z,k2]+Subscript[z,n2],2 \[Pi]]^2+60 \[Pi] Mod[-Subscript[z,k1]+Subscript[z,n1]- Subscript[z,k2]+Subscript[z,n2],2 \[Pi]]^3-15 Mod[-Subscript[z,k1]+Subscript[z,n1]- Subscript[z,k2]+Subscript[z,n2],2 \[Pi]]^4) R2[s_?NumericQ]:= (1-1/\[Pi] Sum[(-1)^(n1+1) Subscript[z,n1], {n1,1,2s-1}])^4 j[s_?NumericQ]:=Sum[F2[n1,k1,n2,k2], {n1,0,2s-1},{k1,0,2s-1},{n2,0,2s-1}, {k2,0,2s-1}]+R2[s] vars=Table[Subscript[z,n],{n,7}]; Subscript[z,0]=0; NMaximize[{1/j[4],Less@@Flatten@{0,vars,2Pi}},vars] {21.159,{Subscript[z, 1]->0.280611,Subscript[z, 2]->0.551814,Subscript[z, 3]->1.03005,Subscript[z, 4]->1.39244,Subscript[z, 5]->1.91189,Subscript[z, 6]->2.70526,Subscript[z, 7]->5.49529}} I also get 21.159 on version 6.0.3.0 on this Mac Bob Hanlon ---- Filippo Miatto <miatto at gmail.com> wrote: ============= woops sorry i didn't see that! F2[n1_,k1_,n2_,k2_]:=(-1)^(n1+k1+n2+k2)/(360 \[Pi]^4) (8 \[Pi]^4-60 \ [Pi]^2 Mod[-Subscript[z, k1]+Subscript[z, n1]-Subscript[z, k2]+Subscript[z, n2],2 \[Pi]]^2+60 \[Pi] Mod[-Subscript[z, k1]+Subscript[z, n1]-Subscript[z, k2]+Subscript[z, n2],2 \[Pi]]^3-15 Mod[-Subscript[z, k1]+Subscript[z, n1]-Subscript[z, k2]+Subscript[z, n2],2 \[Pi]]^4) R2[s_]:=(1-1/\[Pi] Sum[(-1)^(n1+1) Subscript[z, n1],{n1,1,2s-1}])^4 j[s_]:=Sum[F2[n1,k1,n2,k2],{n1,0,2s-1},{k1,0,2s-1},{n2,0,2s-1}, {k2,0,2s-1}]+R2[s] there is also the condition Subscript[z, 0]=0 For example if I try: NMaximize[{1/j[4],0<Subscript[z, 1]<Subscript[z, 2]<Subscript[z, 3]<Subscript[z, 4]<Subscript[z, 5]<Subscript[z, 6]<Subscript[z, 7]<2\ [Pi]},{Subscript[z, 1],Subscript[z, 2],Subscript[z, 3],Subscript[z, 4],Subscript[z, 5],Subscript[z, 6],Subscript[z, 7]}] I get a result of 23.517 on the mac and a result <23 on windows, although everything is the same. Now i don't know if the result of my mac is correct (since the one of windows isn't, and actually the values should be linear with respect to s, and 23.517 is a little too low) and i'm sure i can't rely on the win machine to go up and maximize 1/j[s] for high values of s. if i could understand the reason of this discrepancy i could possibly fix things, either in the form of the equations or in the parameters of NMaximize (or NMinimize). Thank you Filippo On Mar 15, 2009, at 1:39 AM, DrMajorBob wrote: > =CF=80 > > ??? > > Post readable code. Use Edit>Copy As>Plain Text and paste into e-mail. > > Bobby > > On Sat, 14 Mar 2009 18:13:15 -0500, Filippo Miatto > <miatto at gmail.com> wrote: > >> Dear all, >> i'm working in the quantum optics group of the university of Leiden, >> and i use mathematica 7 a lot. >> we have both windows machines and macs. On a mac i was trying to >> minimize the function >> >> j[s_] := Sum[F2[n1, k1, n2, k2], {n1, 0, 2 s - 1}, {k1, 0, 2 s - 1}, >> {n2, 0,2s - 1}, {k2, 0, 2s - 1}] + R2[s] >> >> Where >> R2[s_] := (1 - 1/=CF=80 Sum[(-1)^(n1 + 1) Subscript[z, n1], {n1, 1, >> 2 s - >> 1}])^4 >> >> and >> F2[n1_, k1_, n2_, k2_] := (-1)^(n1 + k1 + n2 + k2)/(360 =CF=80^4) >> (8 =CF=80^4 - >> 60 =CF=80^2 Mod[-Subscript[z, k1] + Subscript[z, n1] - Subscript[z, >> k2] + >> Subscript[z, n2], 2 =CF=80]^2 + 60 =CF=80 Mod[-Subscript[z, k1] + >> Subscript[z, >> n1] - Subscript[z, k2] + Subscript[z, n2], 2 =CF=80]^3 -15 Mod[- >> Subscript[z, k1] + Subscript[z, n1] - Subscript[z, k2] + >> Subscript[z, >> n2], 2 =CF=80]^4) >> >> (sorry for the mess, on the screen the subscripts simply appear as >> subscripts...) >> >> and i get certain results for s=1,2,3,4,5,etc.. >> on the windows machine though, i get worse results! the version of >> mathematica is the same, machineprecision value is the same, even >> the .nb file is the same! (the processor is different: a dualcore2duo >> on the mac and a quad core xeon on the windows machine) >> The mac can work well until s=6, the windows machine can go on to >> greater values, but still giving less good results. >> Do you have any idea how i can solve this issue? >> Thank you in advance! >> Filippo= >> > > > > -- > DrMajorBob at bigfoot.com