       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:= sol = {{b1 -> -2, a1 -> -1}, {b1 -> 0.5, a1 -> 3}};

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

Out= {{b1->0.5,a1->3}}

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

Out= {3}

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

Out= {{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