MathGroup Archive 2007

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

Search the Archive

Re: How to choose real positive solutions only?

  • To: mathgroup at smc.vnet.net
  • Subject: [mg74563] Re: How to choose real positive solutions only?
  • From: siewsk at bp.com
  • Date: Mon, 26 Mar 2007 02:08:02 -0500 (EST)
  • References: <eu1pip$evs$1@smc.vnet.net>

On Mar 24, 9:58 am, bsyeh... at gmail.com wrote:
> let sol={{x->3},{x->4+I},{x->4-I}} be such solution then
> Cases[sol,{x->y_}/;Positive[y]] does the filtering
>
> On 3/22/07, Terry <thar... at attglobal.net> wrote:
>
>
>
> > Manfred,
>
> >     Let's say that your complex answers are in a variable called 'ans'
> > that is a list of the form a-> x + iy
> > Then do something like
>
> > realAns := ans a/. Select[ans,(FreeQ[#,Complex])&]
>
> > HTH
> > .....Terry
>
> > Dix, Manfredo A wrote:
>
> > >Hello,
> > >this question probably came up before, but anyway:
>
> > >suppose I have a system of 3 equations and 3 unknowns,
> > >which I want to solve numerically with NSolve.
> > >They are polynomial of degree "n" so that I get n solutions.
>
> > >Is there a way to tell Mathematica to just return the
> > >real positive solutions, and dismiss the imaginary and negative
> > >ones?
>
> > >thank you so much for any help,
> > >cordially,
>
> > >Manfred
> > >m... at tulane.edu

SelectPositive[soln_] := Select[soln, And @@ (Abs[#1[[2]]] == #1[[2]]
& ) /@ #1 & ]

eqns = {x^5 - y^2 + 3*z == 1, 7*x + y - 7*z == -2, x - 1*y + z ==
-3};

NSolve[eqns, {x, y, z}] // SelectPositive
Out[67]=  {{x -> 2.38598, y -> 9.40062, z -> 4.01464}}



  • Prev by Date: Re: Suggestion for direct commands ParametricPlot22 and ParametricPlot33
  • Next by Date: Self-teaching snag
  • Previous by thread: Re: Re: How to choose real positive solutions only?
  • Next by thread: Boundary Conditions in PDE