# Ask Mathematica if there exists a value that satisfies conditions

I would like to build a function that returns true if there exists even one value of xg1 such that having as inputs Mtot, PL, xg2, mac, xga, and defining

xgtot = (xg1 PL + xg2 Mtot)/(Mtot + PL);
stab = (xga - xgtot)/mac;


the following conditions are satisfied:

0.1<stab<0.4
xgtot<0.2;


I would like such a function to return only True or False.

I tried using AnyTrue, but it doesn't seam to work as I wanted:

    tests = {0.1<#1 < 0.4 &, #2 < 0.2 &};
AnyTrue[{stab, xg1} , TrueQ[tests] ]


Any suggestions?

• Perhaps you could write a function that uses FindInstance or Reduce, then if an answer is returned by those functions, it in turn returns True, otherwise False. – MarcoB May 18 '16 at 12:29
• It seams to work out with FindInstance. How may I make it return True or False? – Mirko Aveta May 18 '16 at 12:42
• To make it return True or False, just test whether its output is {} (False) or something else (True). The following would work: FindInstance[(*tests*), {(*variables*)}] =!= {} You may also want to know that =!= is a short for UnsameQ. – QuantumDot May 18 '16 at 12:54
• And if you reply to a comment, you should add a @MarcoB somewhere in your comment to send him a 'notification'. Otherwise he won't know you replied. – QuantumDot May 18 '16 at 12:59

Mainly just to see how Reduce@Exists[..] stacks up against FindInstance[]. I suspect the heuristics of FindInstance will often beat symbolic reduction, but apparently not in this case.

Clear[xg1, Mtot, PL, xg2, mac, xga, stab, xgtot];
xgtot = -(xg1 PL + xg2 Mtot)/(Mtot + PL);
stab = (xga - xgtot)/mac;
Reduce[
Exists[{xg1, Mtot, PL, xg2, mac, xga},
0.1 < stab < 0.4 && xgtot < 0.2]
] // RepeatedTiming
FindInstance[0.1 < stab < 0.4 && xgtot < 0.2,
{xg1, Mtot, PL, xg2, mac, xga}] =!= {} // RepeatedTiming
(*
{0.0081, True}
{0.0087, True}
*)


Following MarcoB's comments and QuantumDot's suggestion, a solution could be to simply use FindInstance:

    FindInstance[(xga - (xg1 PL + xg2 Mtot)/(Mtot + PL))/mac < 0.4 &&
xg1 > 0.3 && 0.1 < stab < 0.4, {xg1}] =!= {}


Thank you very much!