Mathematica 9 is now available
Services & Resources / Wolfram Forums / MathGroup Archive
-----

MathGroup Archive 2009

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

Search the Archive

Re: Solve problem

  • To: mathgroup at smc.vnet.net
  • Subject: [mg98029] Re: Solve problem
  • From: Bill Rowe <readnews at sbcglobal.net>
  • Date: Sat, 28 Mar 2009 05:43:28 -0500 (EST)

On 3/27/09 at 5:35 AM, BC at gmail.com (Bruno Campanini) wrote:

>I have a Solve[...] which gives me solutions like {{b1 -> -2, a1 ->
>-1 }, {b1 -> 0.5, a1 -> 3}} or like {{a1 -> 1, b1 -> 3}}

>How can I get the positive value for a1, which is  3 in the first
>case and  1  in the second one?

It isn't clear to me what you mean by "get" in these cases. But
here are three possibilities that might be close to what you want

In[1]:= sol = {{b1 -> -2, a1 -> -1}, {b1 -> 0.5, a1 -> 3}};

In[2]:= Cases[sol, _?(Positive[a1 /. #] &)]

Out[2]= {{b1->0.5,a1->3}}

In[4]:= Cases[a1 /. # & /@ sol, _?Positive]

Out[4]= {3}

In[5]:= Cases[{b1, a1} /. # & /@ sol, {_, _?Positive}]

Out[5]= {{0.5,3}}




  • Prev by Date: pick out an element from list
  • Next by Date: Re: How do I hide all input in a Mathematica notebook?
  • Previous by thread: Re: Solve problem
  • Next by thread: Re: Solve problem