1

Here's a minimal working example of a problem I'm having:

FindInstance[#, {a, b}] & @@@ {{a + b > 1, a + b < 2}, {a + b > 2, a + b < 3}}
(*{{{a -> 0, b -> 2}}, {{a -> 0, b -> 3}}}*)

Obviously this is not what I'm after, as $a+b<2$ is not satisfied in the first and $a+b<3$ is not satisfied in the second case. Individually they work fine:

FindInstance[{a + b > 1, a + b < 2}, {a, b}]
(*{{a -> 0, b -> 3/2}}*)

And:

FindInstance[{a + b > 2, a + b < 3}, {a, b}]
(*{{a -> 0, b -> 5/2}}*)

I'm guessing my issue is something to do with the evaluation order. Or maybe it's only reading the first inequality in each constraint list? What am I missing here?

EDIT: I've changed the title to reflect the error in my understanding.

J. M.'s missing motivation
  • 124,525
  • 11
  • 401
  • 574
Shane
  • 1,003
  • 1
  • 6
  • 18
  • @Mr.Wizard Should I delete the question? – Shane Mar 23 '15 at 18:25
  • 1
    Shane, unless things have changed the existence of a positively-voted answer means you will be unable to delete your own question. But there is no need for that. For the most part duplicates are not deleted; they serve as useful entry points from search engines that redirect to the original. Incidentally it is probably best not to think of @@@ as "Map Apply" as Map is not involved. Either function (Map or Apply) can be specified to operate at any level or contiguous range of levels within an expression. @@@ is Apply with a levelspec of {1}. – Mr.Wizard Mar 24 '15 at 03:35

1 Answers1

3

Use this instead:

FindInstance[#, {a, b}]& /@ {a + b > 1 && a + b < 2, a + b > 2 && a + b < 3}

or, in fact, this:

FindInstance[#, {a, b}]& /@ {{a + b > 1, a + b < 2}, {a + b > 2, a + b < 3}}
Taiki
  • 5,259
  • 26
  • 34
  • You're right. I'm just getting confused between Map and Apply like an idiot! I can keep my constraints in list form, though, and just use /@ in place of @@@. Thanks! (I'll accept when it lets me) – Shane Mar 23 '15 at 16:28
  • Yeah you're right. Just edited the answer to reflect this. – Taiki Mar 23 '15 at 16:30