Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
2005
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*November
*December
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 2005

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Nestwhile

  • To: mathgroup at smc.vnet.net
  • Subject: [mg57234] Re: [mg57201] Nestwhile
  • From: DrBob <drbob at bigfoot.com>
  • Date: Sat, 21 May 2005 02:40:25 -0400 (EDT)
  • References: <EC9C79ED705B7D498CE6892836AA3CAABA6EF4@EAHQ-CSMB9.rws.ad.ea.com> <428E0483.1090906@umbc.edu>
  • Reply-to: drbob at bigfoot.com
  • Sender: owner-wri-mathgroup at wolfram.com

NestWhile still needs functions for its first and third arguments, Return is still a waste of keystrokes, you're still not nesting anything (so While is indicated), et cetera.

Sorting twice in defining c is pointless, and I wonder if Sort is doing what you think, at all; it sorts symbolic expressions when used this way (ditto for cpp, uo, uop, uopp, deltaA), not the numbers. Hence, the various vectors may not be consistently sorted in a way that matches your intentions. For instance, cpp isn't the derivative of cp, as you probably intended. You could have set

cpp[j_]=D[cp[j], t]

Similarly for uop and uopp (first and second derivative of a vector dotted with Ao). You have the first vector of the dot product wrong at least for uop, I suspect. In uopp things may accidentally sort properly, but you shouldn't count on it. (I'm guessing your true intentions and may be wrong, of course.)

I notice you're defining but not using deltaA[j_] and delA[j_]. Just as well, too, as they'd be hard to work with.

There's also no point in using Simplify on real numbers, as I think you're doing in several of the functions; numbers don't simplify.

Bobby

On Fri, 20 May 2005 11:38:43 -0400, Pratik Desai <pdesai1 at umbc.edu> wrote:

> 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: [mg57234] [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
>



-- 
DrBob at bigfoot.com


  • Prev by Date: Re: Nestwhile
  • Next by Date: Re: four approaches to do a simple sum
  • Previous by thread: Re: Nestwhile
  • Next by thread: Re: Nestwhile