MathGroup Archive 2012

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

Search the Archive

Re: extract only positive solutions

  • To: mathgroup at smc.vnet.net
  • Subject: [mg125047] Re: extract only positive solutions
  • From: Helen Read <readhpr at gmail.com>
  • Date: Sun, 19 Feb 2012 06:32:53 -0500 (EST)
  • Delivered-to: l-mathgroup@mail-archive0.wolfram.com
  • References: <jhldd0$oql$1@smc.vnet.net>

On 2/17/2012 6:24 AM, 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}?
>


You can restrict the domain in Solve.

For example:

f[x_]:=150 - 15 x - 50 x^2 + 2 x^3 - 6 x^4 + x^5 + 2 x^6

Solve[f[x]==0,x]

Solve[f[x]==0,x,Reals]

Solve[f[x]==0,x,Rationals]

Solve[f[x]==0,x,Integers]

Solve[f[x] == 0 && x > 0, x]


So if I understand what you are trying to do, something like this:


{x, y} /.
  Solve[{y == x^2 - 2 x - 5, y == 7 - x, x > 0, y > 0}, {x, y}]


-- 
Helen Read
University of Vermont



  • Prev by Date: Re: multiple selection control
  • Next by Date: How to convert recurrence into generating function?
  • Previous by thread: Re: extract only positive solutions
  • Next by thread: parallel computations with Mathematica