# Improving FindInstance efficiency

I am relatively new to Mathematica and my function has been running for over a month now. I am beginning to think I may never get a solution or that there is a mistake in the code, which means a solution will never be found. I have tried a simpler version of the code though, which seems to yield a solution within minutes.

I am trying to run FindInstance.

Here is the code:

FindInstance[((M^2 + R^2)*μm  +  a^2 * M^4)/(em^2 * (M^2 + R^2)  + a^2 *
M^2 * R^2) + ((M^2 + R^2)*μr  + a^2*R^4)/(er^2 * (M^2 + R^2)  + a^2*M^2
* R^2)  - (μm + M^2)/(em^2) -  μr/(R^2 + er^2) >= 0 && ((M^2 +
R^2)*μm  +  a^2 * M^4)/(em^2 * (M^2 + R^2)  + a^2 * M^2 * R^2) + ((M^2 + R^2)*μr  + a^2*R^4)/(er^2 * (M^2 + R^2)  + a^2*M^2 * R^2)   - (μr + R^2)/(er^2) -  μm /(M^2 + em^2) >= 0 && a>0.71 && 0 < M && 0 < R && 0 <
em && 0 < er && 0<μr && 0< μm, {M,R, em, er, μr, μm, a}]


Am I doing something wrong? What can I do to speed up the process? Would, for example, normalizing most square terms help? Many variables appear only in squares without a linear component and could easily be substituted with another variable.

• Might just be a hard problem. – Daniel Lichtblau Nov 17 '18 at 21:02
• Well, the hardware might matter. Are you running on a low end laptop or something? If so, there's obvious room for efficiency in finding a more powerful machine to do the computation on. – ktm Nov 18 '18 at 0:59

Is this enough?

Do[{M,R,em,er,μr,μm,a}=RandomReal[{0,10},7];
If[((M^2 + R^2)*μm + a^2*M^4)/(em^2*(M^2 + R^2) + a^2*M^2*R^2) +
((M^2 + R^2)*μr + a^2*R^4)/(er^2*(M^2 + R^2) + a^2*M^2*R^2) -
(μm + M^2)/(em^2) - μr/(R^2 + er^2) >= 0 &&
((M^2 + R^2)*μm + a^2*M^4)/(em^2*(M^2 + R^2) + a^2*M^2*R^2) +
((M^2 + R^2)*μr + a^2*R^4)/(er^2*(M^2 + R^2) + a^2*M^2*R^2) -
(μr + R^2)/(er^2) - μm /(M^2 + em^2) >= 0 &&
a>0.71,
Print[{M,R,em,er,μr,μm,a}]]
,{100}]


which instantly prints out lots of satisfying tuples.

Perhaps I've misunderstood or made a mistake.

It is possible to find a set of values that satisfies the conditions. There are two expressions in the question

exp1 = ((M^2 + R^2)*\[Mu]m + a^2*M^4)/(em^2*(M^2 + R^2) +
a^2*M^2*R^2) + ((M^2 + R^2)*\[Mu]r + a^2*R^4)/(er^2*(M^2 + R^2) +
a^2*M^2*R^2) - (\[Mu]m + M^2)/(em^2) - \[Mu]r/(R^2 + er^2)


and

exp2 = ((M^2 + R^2)*\[Mu]m + a^2*M^4)/(em^2*(M^2 + R^2) +
a^2*M^2*R^2) + ((M^2 + R^2)*\[Mu]r + a^2*R^4)/(er^2*(M^2 + R^2) +
a^2*M^2*R^2) - (\[Mu]r + R^2)/(er^2) - \[Mu]m/(M^2 + em^2)


Run FindInstance on each of them separately

FindInstance[
exp1 >= 0 && a > 0.71 && 0 < M && 0 < R && 0 < em && 0 < er &&
0 < \[Mu]r && 0 < \[Mu]m, {M, R, em, er, \[Mu]r, \[Mu]m,
a}] // AbsoluteTiming

(* {0.816593, {{M -> 0.375, R -> 1., em -> 1., er -> 1., \[Mu]r -> 1., \[Mu]m -> 1., a -> 1.}}} *)

FindInstance[
exp2 >= 0 && a > 0.71 && 0 < M && 0 < R && 0 < em && 0 < er &&
0 < \[Mu]r && 0 < \[Mu]m, {M, R, em, er, \[Mu]r, \[Mu]m,
a}] // AbsoluteTiming

(* {15.8912, {{M -> 2., R -> 1., em -> 1., er -> 1., \[Mu]r -> 1., \[Mu]m -> 1., a -> 1.}}} *)


Substituting the common values and plotting the resulting expressions against a range of M values shows that the conditions exp1 >= 0 && exp2 >=0 cannot be satisfied. Looking at the plots and examining the equations it seems like changing R and a is the best way to find a solution so I made a guess.

exp1 /. {M -> 0.5, R -> 2.0, em -> 1.0,
er -> 1.0, \[Mu]r -> 1.0, \[Mu]m -> 1.0, a -> 2.0}

(* 7.36818 which is >= 0 *)

exp2 /. {M -> 0.5, R -> 2.0, em -> 1.0,
er -> 1.0, \[Mu]r -> 1.0, \[Mu]m -> 1.0, a -> 2.0}

(* 3.01818 which is >= 0 *)


This is rather ad-hoc and may not be the solution you are looking for. But perhaps with your knowledge of the domain of this problem it is possible to come up with a better solution.

• +1. Thank you very much! It indeed solves my problem and is a good approach. Nevertheless, I have accepted the other answer as the solution there seems more generalizable for future readers. Thank you. – Bob Nov 18 '18 at 14:36