Mathematica Stack Exchange is a question and answer site for users of Mathematica. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am solving some equations in 4 variables, however, there are many solutions which are basically the same but changing relative signs of each other ... i.e. {x->-1,y->1} and {x->1,y->-1}. Nevertheless I am only interested in solutions with positive values for x and negative values for y. Is there anyway to implement this in NSolve? I was trying to add an additional equation

NSolve[eq1==a&&eq2==b ... &&y<0,{x,y}]

However, this is not working. Is it the wrong way tom implement it?

share|improve this question
Solve everything and then Select desired solutions? – BoLe May 24 '13 at 9:38
At this stage that wouldn't be a problem, however later conditions may get more involved and I was wondering whether there would be an automated way to do it ... – pablo May 24 '13 at 9:43
can you show more of your actual code? For me e.g. this is working: NSolve[(x + y)^2 + (x - y)^2 == 1 && (x + y)^4 + (x - y)^4 == 1 && x > 0 && y > 0, {x, y}] gives only the positive solution wheras NSolve[(x + y)^2 + (x - y)^2 == 1 && (x + y)^4 + (x - y)^4 == 1, {x, y}] gives all four solutions. – Thies Heidecke May 24 '13 at 9:45
Sorry, the equations are rather long to copy it here and with greek letters, superscript, etc.. so it woudl be a nightmare to copy. Then I guess for some reason, for this equation, implementing this kind of condition takes Mathematica a long time, so I will go with Select in the end I guess Thanks a lot! – pablo May 24 '13 at 9:47
@pablo You may switch to FindRoot. How would you specify x > 0 then? – BoLe May 24 '13 at 9:49
up vote 2 down vote accepted
solution = With[{n = 10, r := RandomReal[{-1, 1}]},
  Table[{x -> r, y -> r, z -> r, w -> r}, {n}]];

 With[{u = Apply[ArcTan, {x, y} /. #]}, -.5 Pi < u < 0] &]


Cases[solution, {x -> a_ /; a > 0, y -> b_ /; b < 0, __}]
share|improve this answer
This will do the job :) Thanks a lot! – pablo May 24 '13 at 9:56

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.