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: [mg14318] Re: Getting Delayed rules from NSolve
  • From: "Allan Hayes" <hay at haystack.demon.co.uk>
  • Date: Tue, 13 Oct 1998 01:21:31 -0400
  • References: <6vs1eh$8du$3@dragonfly.wolfram.com>
  • Sender: owner-wri-mathgroup at wolfram.com

The following is the outcome of a short correspondence with Dennis in
which he asked for the size to be extendabel

Dennis:
The following may generalise to what you need (change the 2 in {x,2}):

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,
    Table[
        _ -> ToExpression["foo"<>ToString[x]<>"_"],
        {x, 2}
    ]/;


luate[ 
        Apply[
            And,
            Table[
                10^(-6) > 
                ToExpression["foo"<> ToString[x]] > 
                0,
                {x, 2}
            ]
        ]
    ]
   
]

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

NOTES:
1) name in name_  and similar must be a symbol. 2) Evaluate is necessary
to constructing the condition since Condition has the attribute
HoldAll.

Allan

>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 th
e above list of rules.
>>
>> Thanks!
>>
>> Dennis Benjami
>>




  • Prev by Date: Mathematica 3 speed on a Sun Ultra1/200e ?
  • Next by Date: Mathmatica Problem...
  • Previous by thread: Re: Getting Delayed rules from NSolve
  • Next by thread: x == x^1.2/(2*x^3+y^0.7+4*z^2.5)