Re: NSolve keeps on running forever
- To: mathgroup at smc.vnet.net
- Subject: [mg82707] Re: [mg82681] NSolve keeps on running forever
- From: DrMajorBob <drmajorbob at bigfoot.com>
- Date: Mon, 29 Oct 2007 05:35:26 -0500 (EST)
- References: <18342578.1193602902297.JavaMail.root@m35>
- Reply-to: drmajorbob at bigfoot.com
Here's an initial look at the size of your problem: Cases[{\!\( \*UnderoverscriptBox[\(\[Sum]\), \(h = 2\), \(Length[y]\)]\(hca[A, c, h, y, \[Beta]0, \[Beta]1, \[Beta]2, \[Beta]3, \[Sigma], \[Gamma]]\)\),(\!\( \*UnderoverscriptBox[\(\[Sum]\), \(s = 2\), \(Length[y]\)]\(hca[A, c, s, y, \[Beta]0, \[Beta]1, \[Beta]2, \[Beta]3, \[Sigma], \[Gamma]] . Transpose[hca[A, c, s, y, \[Beta]0, \[Beta]1, \[Beta]2, \[Beta]3, \[Sigma], \[Gamma]]]\)\))},_Symbol,Infinity]; %//Length %%//Union//Length 95139 43 That's 95,139 mentions of 6 variables and 37 unknown parameters. In addition, you've equated matrices... which isn't legal syntax in NSolve, AFAIK. (Correct me if I'm wrong.) I'm surprised NSolve even tries. On top of that, the following: Sum[hca[A, c, h, y, \[Beta]0, \[Beta]1, \[Beta]2, \[Beta]3, \[Sigma], \[Gamma]], {h, 2, Length[y]}] when evaluated, involves terms such as 2[{1, 2, 3, 2, 1, 4, 5, 3, 2, 1}, 2, \[Beta]0, \[Beta]1, \[Beta]2, \[Beta]3, \[Sigma], \[Gamma]] 3[{1, 2, 3, 2, 1, 4, 5, 3, 2, 1}, 3, \[Beta]0, \[Beta]1, \[Beta]2, \[Beta]3, \[Sigma], \[Gamma]] and so forth. Probably that's not what you intended, right? Fix that, change the matrix equations into scalar equations (Thread might help), and try again. Bobby On Sun, 28 Oct 2007 04:03:50 -0500, Nabeel Butt <nabeel.butt at gmail.com> wrote: > Hi Guys, > I have a system of equations that I want to solve.It has a > solution but NSolve seems to keep on running forever.I am pasting the > code > over here: > h[y_,t_,\[Beta]0_,\[Beta]1_,\[Beta]2_,\[Beta]3_,\[Sigma]_,\[Gamma]_]:={{v[y,t,\[Beta]0,\[Beta]1,\[Beta]2,\[Beta]3,\[Sigma],\[Gamma]]},{(y[[t-1]])*v[y,t,\[Beta]0,\[Beta]1,\[Beta]2,\[Beta]3,\[Sigma],\[Gamma]]},{((y[[t-1]])^2)*v[y,t,\[Beta]0,\[Beta]1,\[Beta]2,\[Beta]3,\[Sigma],\[Gamma] ]},{(((v[y,t,\[Beta]0,\[Beta]1,\[Beta]2,\[Beta]3,\[Sigma],\[Gamma]])^2)-\[Sigma]^2*((y[[t-1]])^3))},{(((v[y,t,\[Beta]0,\[Beta]1,\[Beta]2,\[Beta]3,\[Sigma],\[Gamma]])^2)-\[Sigma]^2*((y[[t-1]])^3))*y[[t-1]]},{(((v[y,t,\[Beta]0,\[Beta]1,\[Beta]2,\[Beta]3,\[Sigma],\[Gamma]])^2)-\[Sigma]^2*((y[[t-1]])^3))*((y[[t-1]])^3)}}; > v[y_,t_,\[Beta]0_,\[Beta]1_,\[Beta]2_,\[Beta]3_,\[Sigma]_,\[Gamma]_]:=y[[t]]-y[[t-1]]-\[Beta]0-\[Beta]1*y[[t-1]]-\[Beta]2*((y[[t-1]])^2); > hca[A_,c_,t_,y_,\[Beta]0_,\[Beta]1_,\[Beta]2_,\[Beta]3_,\[Sigma]_,\[Gamma]_]:=( > A.h > [y,t,\[Beta]0,\[Beta]1,\[Beta]2,\[Beta]3,\[Sigma],\[Gamma]])*w[A,c,t,y,\[Beta]0,\[Beta]1,\[Beta]2,\[Beta]3,\[Sigma],\[Gamma]]; > w[A_,c_,t_,y_,\[Beta]0_,\[Beta]1_,\[Beta]2_,\[Beta]3_,\[Sigma]_,\[Gamm= a]_]:= > Min[1,c/Norm[A.h > [y,t,\[Beta]0,\[Beta]1,\[Beta]2,\[Beta]3,\[Sigma],\[Gamma]]]]; > *c=5.85; > A={{a11,a12,a13,a14,a15,a16},{a21,a22,a23,a24,a25,a26},{a31,a32,a33,= a34,a35,a36},{a41,a42,a43,a44,a45,a46},{a51,a52,a53,a54,a55,a56},{a61,a6= 2,a63,a64,a65,a66}}; > y={1,2,3,2,1,4,5,3,2,1}; > NSolve[{\!\( > \*UnderoverscriptBox[\(\[Sum]\), \(h = 2\), \(Length[y]\)]hca[A, c, = h, y, > \[Beta]0, \[Beta]1, \[Beta]2, \[Beta]3, \[Sigma], > \[Gamma]]\)=={{0},{0},{0},{0},{0},{0}}, > 1/Length[y]*(\!\( > \*UnderoverscriptBox[\(\[Sum]\), \(s = 2\), \(Length[y]\)]hca[A, c, = s, y, > \[Beta]0, \[Beta]1, \[Beta]2, \[Beta]3, \[Sigma], \[Gamma]] . > Transpose[hca[A, c, s, y, \[Beta]0, \[Beta]1, \[Beta]2, \[Beta]3, = > \[Sigma], > \[Gamma]]]\))=={{1,0,0,0,0,0},{0,1,0,0,0,0},{0,0,1,0,0,0},{0,0,0,1= ,0,0},{0,0,0,0,1,0},{0,0,0,0,0,1}}},{\[Beta]0,\[Beta]1,\[Beta]2,\[Beta]3= ,\[Sigma],\[Gamma]}] > > regards, > > Nabeel* -- = DrMajorBob at bigfoot.com