Re: Nestwhile
- To: mathgroup at smc.vnet.net
- Subject: [mg57226] Re: [mg57201] Nestwhile
- From: "Barthelet, Luc" <lucb at ea.com>
- Date: Sat, 21 May 2005 02:39:52 -0400 (EDT)
- Sender: owner-wri-mathgroup at wolfram.com
I am not sure NestWhile is really what you need here. I create a notebook for your function. There are a couple of typos in the function below I think. (w rather than dw?) there are also a lot of terms equal to 0. You function is d[e,dw]=... it probably needs to be d[e_,de_]:=... You can see the html version of the notebook at: http://www.mathematica-users.org/webMathematica/wiki/wiki.jsp?pageName=N otebook:functionMathgroup57201.nb and you can download the notebook at: http://www.mathematica-users.org/mediawiki/images/8/83/functionMathgroup 57201.nb I suggest you upload your notebook at http://www.mathematica-users.org and that would give us more information to help you quickly. Cheers, Luc -----Original Message----- From: Pratik Desai [mailto:pdesai1 at umbc.edu] To: mathgroup at smc.vnet.net Subject: [mg57226] [mg57201] Nestwhile Hi, I am having problem with using NestWhile in a code which basically boils down to finding values for the variables (e,dw) for which a function d[e, dw] is "minimized" while one variable (e) goes up to 1. I have been using the following approach, which unfortunately loops for 1 iteration..There is definitely a better probably a simpler way to do this...Thanks in advance for your help Here is the attempt : d[ e, dw] = Abs[0. + 1143.8189785870038/((-2.0224920432639264 + e)*(22.50249204326393 + e)) + (e^3*(-2.3561944901923435 - 1.3322676295501878*^-15*w))/((-2.0224920432639264 + e)*(22.50249204326393 + e)) - 56.548667764616276*w - (2573.5927018207585*dw)/((-2.0224920432639264 + e)*(22.50249204326393 + e)) + (e^2*(-73.38760438785755 + 56.54866776461624*dw))/((-2.0224920432639264 + e)*(22.50249204326393 + e)) + (e*(-407.4855111216201 + 1158.1167158193412*dw))/((-2.0224920432639264 + e)*(22.50249204326393 + e))] + 8.*Abs[0. + 0./((-2.0224920432639264 + e)*(22.50249204326393 + e)) + (0.*dw)/((-2.0224920432639264 + e)*(22.50249204326393 + e)) + e^2*(0./((-2.0224920432639264 + e)*(22.50249204326393 + e)) + (0.*dw)/((-2.0224920432639264 + e)* (22.50249204326393 + e))) + e*(0. + 0./((-2.0224920432639264 + e)*(22.50249204326393 + e)) + (0.*dw)/((-2.0224920432639264 + e)*(22.50249204326393 + e)))] + Abs[0. + (e*(-107.23302924253159 - 7.105427357601*^-14*dw))/((-2.0224920432639264 + e)*(22.50249204326393 + e)) + (e^3*(2.3561944901923453 - 4.440892098500626*^-16*dw))/((-2.0224920432639264 + e)*(22.50249204326393 + e)) + e^2*(48.25486315913923/((-2.0224920432639264 + e)*(22.50249204326393 + e)) + (0.*dw)/((-2.0224920432639264 + e)*(22.50249204326393 + e)))] Module[{e = 0.05, dw = 0.04}, NestWhile[{e += 0.01,dw += 0.1}, d[ e, dw],10^-2 <d[ e, dw] <0&&e==1 ]; Print[dw,d[ e, dw],e]; Return[d[j, e, dw], Module]] 0.14 25.415 -- Pratik Desai Graduate Student UMBC Department of Mechanical Engineering Phone: 410 455 8134