Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.soft-sys.math.mathematica > #8580 > unrolled thread
| Started by | Gabby Domingo <gbdomingo@gmail.com> |
|---|---|
| First post | 2012-02-17 11:24 +0000 |
| Last post | 2012-02-19 11:35 +0000 |
| Articles | 3 — 3 participants |
Back to article view | Back to comp.soft-sys.math.mathematica
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
| From | Gabby Domingo <gbdomingo@gmail.com> |
|---|---|
| Date | 2012-02-17 11:24 +0000 |
| Subject | extract only positive solutions |
| Message-ID | <jhldd0$oql$1@smc.vnet.net> |
hi all! how do you extract only positive solutions to a solver, like
NSolve?
sol={{-.532,.932},{.34,23}}
and extract {.34,.23}?
[toc] | [next] | [standalone]
| From | andres <jarosham@gmail.com> |
|---|---|
| Date | 2012-02-18 11:34 +0000 |
| Message-ID | <jho2c6$5v2$1@smc.vnet.net> |
| In reply to | #8580 |
I don't fully understand, NSolve (or any solver) gives the solutions
as a set of rules, not as a list of numbers.
>From your example I guess you want to extract the pairs whose first
element is > 0. If that's the case I'd use Select:
Select[sol, #[[1]] > 0 &]
Andr=E9s
On Feb 17, 6:24 am, Gabby Domingo <gbdomi...@gmail.com> wrote:
> hi all! how do you extract only positive solutions to a solver, like
> NSolve?
>
> sol={{-.532,.932},{.34,23}}
>
> and extract {.34,.23}?
[toc] | [prev] | [next] | [standalone]
| From | Helen Read <readhpr@gmail.com> |
|---|---|
| Date | 2012-02-19 11:35 +0000 |
| Message-ID | <jhqmqt$fbf$1@smc.vnet.net> |
| In reply to | #8580 |
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
[toc] | [prev] | [standalone]
Back to top | Article view | comp.soft-sys.math.mathematica
csiph-web