MathGroup Archive 1998

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

Search the Archive

Re: Getting Delayed rules from NSolve


Dennis Benjamin wrote in message <6vf5m5$dhn at smc.vnet.net>...
>Hi All:
>
> I am using NSolve to get numerical solutions from a setof simultaneous
>equations. The problem I am facing is extracting the physically
>reasonable solution from the supplied list of rules. For Example,
>
>In[199]:=
>Chop[NSolve[ Elim, {RP1,RP2}] /. P2t ->5 10^-6 ]
>
>Out[199]=
>{{RP2 -> -7.26519017625297269`*^-7,RP1 -> 2.36086513207038839`*^-6},
> {RP2 -> 0.0000102421050739988284`,RP1 -> 5.26971403312072794`*^-7},
> {RP2 -> 3.73302832515359561`*^-7, RP1 -> 2.23274575728650503`*^-7}}
>
>Only the third set is reasonable, given that RP1 and RP2 > 0 and RP1
>+RP2 < 1 10^-6.
>
>I would like to use Replace with a /; condition to select a  particular
>value. However, I can only use /; with delayed Rules (:> instead of
>->). Any ideas how to do this? Alternatively, a different approach to
>getting the pair of numbers
>
>3.73302832515359561`*^-7
>2.23274575728650503`*^-7
>
>from the above list of rules.
>
>Thanks!
>
>Dennis Benjami

Dennis:

rls={{RP2 -> -7.26519017625297269`*^-7,RP1 -> 2.36086513207038839`*^-6},
{RP2 -> 0.0000102421050739988284`,RP1 -> 5.26971403312072794`*^-7},
{RP2 -> 3.73302832515359561`*^-7, RP1 -> 2.23274575728650503`*^-7}};


Cases[rls, {_->x_,_->y_}/;And[10^-6>x>0,10^-6>y>0]]

                   -7                   -7 {{RP2 -> 3.73303 10  , RP1 ->
2.23275 10  }}

or


Cases[rls, {_->x_,_->y_}/;And[10^-6>x>0,10^-6>y>0]->{x,y}][[1]]

           -7            -7
{3.73303 10  , 2.23275 10  }


----------------------
Alllan Hayes
Mathematica Training and Consulting
www.haystack.demon.co.uk
hay at haystack.demon.co.uk
Voice: +44 (0)116 271 4198
Fax: +44 (0)870 164 0565



  • Prev by Date: Re: How to control the default plot size?
  • Next by Date: ListPlot
  • Previous by thread: Re: Getting Delayed rules from NSolve
  • Next by thread: Re: Getting Delayed rules from NSolve