Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.soft-sys.math.mathematica > #8622

Re: extract only positive solutions

From Helen Read <readhpr@gmail.com>
Newsgroups comp.soft-sys.math.mathematica
Subject Re: extract only positive solutions
Date 2012-02-19 11:35 +0000
Organization Steven M. Christensen and Associates, Inc and MathTensor, Inc.
Message-ID <jhqmqt$fbf$1@smc.vnet.net> (permalink)
References <jhldd0$oql$1@smc.vnet.net>

Show all headers | View raw


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

Back to comp.soft-sys.math.mathematica | Previous | Next — Previous in thread | Find similar | Unroll thread


Thread

extract only positive solutions Gabby Domingo <gbdomingo@gmail.com> - 2012-02-17 11:24 +0000
  Re: extract only positive solutions andres <jarosham@gmail.com> - 2012-02-18 11:34 +0000
  Re: extract only positive solutions Helen Read <readhpr@gmail.com> - 2012-02-19 11:35 +0000

csiph-web