Message Boards Message Boards

Keep only positive and real solutions from Solve?

Posted 6 years ago

Hi people,

I have a problem where I get four solutions to an equation system. Two imaginary, one negative and one positive. Can I somehow automatically tell Mathematica to only keep the real and positive answer?

Sort of:

Solve[equation1==equation2, x]//Real//Positive

Thanks! //Freddy, Sweden

POSTED BY: Fredrik Erling
5 Replies

It would be useful to have a complete self-contained example. Anyway, could try equation1==equation2 && x>0 as first argument to Solve.

POSTED BY: Daniel Lichtblau

Try:

Solve[equation1==equation2&& x > 0, x, Reals] 

or:

 Solve[{equation1==equation2, x > 0}, x, Reals] 

Regards,MI

POSTED BY: Mariusz Iwaniuk

Thanks a bunch, people! =D

POSTED BY: Fredrik Erling
Posted 3 years ago

Hi everybody, I have the same question, but I have hundreds of variables in my system of equations.

In my large system of equations including numerous variables, I use the following structure:

Solve[eq1==eq2&&
      eq3==eq4&& ....]

and I do not specify any variable, so the solver tries to solve the system for all the variables.

Now the question is instead of this format:

Solve[eq1==eq2&&
      eq3==eq4&& ....&&, x1>0,x2>0,..., Reals] 

How can I ask the solver to return a non-zero positive solution for all the variables? Thanks

POSTED BY: AMIN sol
soln = Solve[eq1==eq2&& eq3==eq4&& ....&&, {x1, x2,..., xn}, Reals] ;
Pick[soln, And @@@ (Positive /@ soln)]
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract