Re: Nestwhile
- To: mathgroup at smc.vnet.net
- Subject: [mg57229] Re: [mg57201] Nestwhile
- From: Pratik Desai <pdesai1 at umbc.edu>
- Date: Sat, 21 May 2005 02:40:01 -0400 (EDT)
- References: <EC9C79ED705B7D498CE6892836AA3CAABA6EF4@EAHQ-CSMB9.rws.ad.ea.com>
- Sender: owner-wri-mathgroup at wolfram.com
Barthelet, Luc wrote: >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 >Sent: Friday, May 20, 2005 1:44 AM >Subject: [mg57229] [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 > > > Hi Luc and Dr.Bob As you can probably tell I am not much of a coder. Since in most cases (hopefully)you turn to the group as a last resort I tried to compose the email as I was just stepping out and you can see the results :-[ . Regardless as Luc suggested I have imported my file on wiki Here is the link to the mathematica file: http://www.mathematica-users.org/mediawiki/images/d/d4/ihb1.nb Luc, Actually the incrementaion is for two variables e and dw , actually w=wo+dw, and I already assumed the value for wo . As far as I can see there are no other typos I am trying to solve the set of linear equations kdA=r+q*dw (here d stands for the Greek symbol Capital delta) where r and q are functions of e So I first symbolically calculate dA then rewrite r=kdA-q*dw try to minimize r based on the values of e and dw. The variables corresponding to the minimum of the norm of r will give me the coeficients dA...that was the general idea anyway Thank you for your quick response Best regards, Pratik -- Pratik Desai Graduate Student UMBC Department of Mechanical Engineering Phone: 410 455 8134