Re: extract only positive solutions
- To: mathgroup at smc.vnet.net
- Subject: [mg125020] Re: extract only positive solutions
- From: Bill Rowe <readnews at sbcglobal.net>
- Date: Sat, 18 Feb 2012 06:24:14 -0500 (EST)
- Delivered-to: l-mathgroup@mail-archive0.wolfram.com
On 2/17/12 at 6:23 AM, gbdomingo at gmail.com (Gabby Domingo) wrote:
>hi all! how do you extract only positive solutions to a solver, like
>NSolve?
>sol={{-.532,.932},{.34,23}}
>and extract {.34,.23}?
Here is an example of one way
In[3]:= p = (x + 3) (x - 4) (x - 5) // Expand;
In[4]:= Cases[Solve[p == 0, x], {_?(x > 0 /. # &)}]
Out[4]= {{x->4},{x->5}}