MathGroup Archive 1998

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

Search the Archive

Re: Getting Delayed rules from NSolve

  • To: mathgroup at smc.vnet.net
  • Subject: [mg14261] Re: [mg14220] Getting Delayed rules from NSolve
  • From: Carl Woll <carlw at fermi.phys.washington.edu>
  • Date: Mon, 12 Oct 1998 13:51:43 -0400
  • Sender: owner-wri-mathgroup at wolfram.com

Hi Dennis,

Here is one idea. You can use Cases to select which of the rules
satisfies your conditions. Suppose soln is your list of rules. Then,

Cases[ soln, {_ -> a_,_ -> b_} /; (a>0 && b>0 && a b < 10^-6)]

will select the rule which satisfies your conditions. If you just want
the pair of numbers, then you could instead do

Cases[ soln, {RP2 -> a_,RP1 -> b_} /; (a>0 && b>0 && a b<10^-6) ->
{a,b}]

Carl Woll
Dept of Physics
U of Washington

On Wed, 7 Oct 1998, Dennis Benjamin wrote:

> 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
> 



  • Prev by Date: Re: Labeling graphs
  • Next by Date: Re: Simplify & $MaxExtraPrecision
  • Previous by thread: RE: Getting Delayed rules from NSolve
  • Next by thread: Re: Getting Delayed rules from NSolve