0

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?

pablo
  • 723
  • 1
  • 9
  • 17
  • 1
    Solve everything and then Select desired solutions? – BoLe May 24 '13 at 09: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 09:43
  • 1
    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 09: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 09:47
  • @pablo You may switch to FindRoot. How would you specify x > 0 then? – BoLe May 24 '13 at 09:49
  • @BoLe I was not using FindRoot, and looking in the documentation I haven't found such a possibility ... Thanks for your answer below! – pablo May 24 '13 at 09:55
  • @pablo With FindRoot you must provide starting values, seeds. You may want to automate that. See this answer which also links to such function FindAllCrossings2D[] in particular. – BoLe May 24 '13 at 10:02
  • @BoLe Ok, I see, that may be useful too, thanks for the info! – pablo May 24 '13 at 10:05

1 Answers1

2
solution = With[{n = 10, r := RandomReal[{-1, 1}]},
  Table[{x -> r, y -> r, z -> r, w -> r}, {n}]];

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

Or:

Cases[solution, {x -> a_ /; a > 0, y -> b_ /; b < 0, __}]
BoLe
  • 5,819
  • 15
  • 33