# FindInstance is very slow on an apparently simple problem

I wish to use FindInstance to find a set of solutions of this problem:

Sistema :=
With[{h = 0.605, A = 0.625, b0 = 1.21},
FindInstance[
A0 == 0.5 h0 (2 b0 - x0) &&
A1 == 0.5 h1 (b0 - x0 + b2) &&
A2 == 0.5 h2 (b2 + b3) &&
A3 == 0.5 (h - h0 - h1 - h2) (b4 + b3) &&
A0 + A1 + A2 + A3 == A && A0 > 0 && A1 > 0 && A2 > 0 && A3 > 0,
{A0, A1, A2, A3, b4, b2, h0, h1, h2, b3, x0}, Reals, 100]]


This code is terribly slow! I simply never received an answer, even if I set the number of points from 100 to 2. Why is this so? Is there a more efficient way to do this?

Since your system is overdetermined we can just randomly specify some of the parameters:

With[{h = 0.605, A = 0.625, b0 = 1.21, h1p = RandomReal[],
h2p = RandomReal[], h0p = RandomReal[], b4p = RandomReal[]},
FindInstance[
A0 == 0.5 h0p (2 b0 - x0) && A1 == 0.5 h1p (b0 - x0 + b2) &&
A2 == 0.5 h2p (b2 + b3) &&
A3 == 0.5 (h - h0p - h1p - h2p) (b4p + b3) &&
A0 + A1 + A2 + A3 == A && A0 > 0 && A1 > 0 && A2 > 0 &&
A3 > 0, {A0, A1, A2, A3, b2, b3, x0}, Reals][[1]]
~Join~{h2 -> h2p, h1 -> h1p, h2 -> h2p, h0 -> h0p, b4 -> b4p}]

• Your suggestion is very interesting. I've tried something like that, but I couldn't manage to make it work out! Thanks a lot. May I ask just one more thing? I would like to add the following conditions: b2 > 0 && x0 > 0 && b3>0, yet I'm finding problems doing this by changing your code. Perhaps because I still don't understand it. Also is it possible to output also A0, A1, A2, A3,b2,b3,x0? – Mirko Aveta May 16 '16 at 20:17

I came upon your problem while looking around and found that version 11.0 does your problem instantaneously.

With[{h = 0.605, A = 0.625, b0 = 1.21, h1p = RandomReal[],
h2p = RandomReal[], h0p = RandomReal[], b4p = RandomReal[]},
FindInstance[
A0 == 0.5 h0p (2 b0 - x0) && A1 == 0.5 h1p (b0 - x0 + b2) &&
A2 == 0.5 h2p (b2 + b3) &&
A3 == 0.5 (h - h0p - h1p - h2p) (b4p + b3) &&
A0 + A1 + A2 + A3 == A && A0 > 0 && A1 > 0 && A2 > 0 &&
A3 > 0, {A0, A1, A2, A3, b2, b3, x0}, Reals][[1]]
~Join~{h2 -> h2p, h1 -> h1p, h2 -> h2p, h0 -> h0p, b4 -> b4p}]

{A0 -> 0.02226445482629367, A1 -> 0.167461549280359,
A2 -> 0.1519477370823364, A3 -> 0.2833262588110109,
b2 -> 1.107998109202816, b3 -> -0.794105007328307,
x0 -> 1.378737701544065, h2 -> 0.9681495781521405,
h1 -> 0.3565817273141156, h2 -> 0.9681495781521405,
h0 -> 0.04276435411002422, b4 -> 0.05094993423987626}

• Its called progress :) – Mirko Aveta Nov 10 '16 at 10:17

Try Solve:

Solve[A0 == 0.5 h0 (2 b0 - x0) && A1 == 0.5 h1 (b0 - x0 + b2) &&
A2 == 0.5 h2 (b2 + b3) && A3 == 0.5 (h - h0 - h1 - h2) (b4 + b3) &&
A0 + A1 + A2 + A3 == A && A0 > 0 && A1 > 0 && A2 > 0 && A3 > 0, {A0,
A1, A2, A3, b4, b2, h0, h1, h2, b3, x0}, Reals]


It returns a lot of answers.