RE: Using a Result from NMinimize

*To*: mathgroup at smc.vnet.net*Subject*: [mg49384] RE: [mg49367] Using a Result from NMinimize*From*: "David Park" <djmp at earthlink.net>*Date*: Sat, 17 Jul 2004 06:38:49 -0400 (EDT)*Sender*: owner-wri-mathgroup at wolfram.com

Greg, Let's say that you have saved the output of NMinimize in answer. answer = {0.0817747, {rp -> 0.0920851}}; Now all you have to do is use Part to extract the part of the answer that you want. For example, to extract and use the replacement rule(s)... rp /. Part[answer, 2] 0.0920851 Or to extract and save the replacement rule... rpsol = Part[answer, 2] {rp -> 0.0920851} You can now substitute in any expression. For example... rp^2 + Cos[rp]; % /. rpsol 1.00424 You could Set rp directly with rp = Part[answer, 2, 1, 2] and then any expressions will be automatically evaluated. rp^2 + Cos[rp] 1.00424 But then rp is no longer available as a manipulable symbolic variable. If you try to revaluate NMinimize, rp will now have a value and it won't work. So many people prefer to stay with the substitution rule and avoid using Set. David Park djmp at earthlink.net http://home.earthlink.net/~djmp/ From: Gregory Lypny [mailto:gregory.lypny at videotron.ca] To: mathgroup at smc.vnet.net Hello Everyone, When I use NMinimize, it gives the result as the minimum value of the function and the value of the argument that gets us there, for example, {0.0817747, {rp -> 0.0920851}}. How can I access the second element, that is, the value of the argument, so that I can use in other computations. In other words, I want get at 0.0920851 and strip away the rp ->. Regards, Greg