# Solve taking infinite time

I have a system of equations that should determine the real coefficients {b[1], c[1], d[1],, e[1], f[1], g[1], h[1], a[1], b[2], c[2], d[2], e[2], f[2], g[2], h[2]}. Writing some of the equations inside Solve and compiling

Solve[{b[1]*e[1] + b[1] + e[1] + c[2]*f[2] - d[1]/2 - a[1]/2 == 0,
c[1]*f[1] + c[1] + f[1] + b[2]*e[2] - d[1]/2 - a[1]/2 == 0,
g[1]*d[1] + g[1] + d[1] - a[1] == 0,
a[1]*h[1] + h[1] - d[1] + a[1] == 0,
a[1]*d[2] + a[2]*d[1] + a[2] + d[2] + d[1]/2 - a[1]/2 == 0,
b[1]*e[2] + c[2]*f[1] + e[2] + c[2] + d[1]/2 - a[1]/2 == 0,
b[2]*e[1] + c[1]*f[2] + b[2] + f[2] + d[1]/2 - a[1]/2 == 0,
g[1]*h[1] + h[1] + g[1] == 0,
a[1]*d[1] + d[1] + a[1] + 4*a[2]*d[2] + 2*d[2] - 2*a[2] ==
0}, {b[1], c[1], d[1], e[1], f[1], g[1], h[1],
a[1], b[2], c[2], d[2], e[2], f[2], g[2], h[2]}]


it takes about 5-10s to run. However, if I add one more equation to the system

Solve[{b[1]*e[1] + b[1] + e[1] + c[2]*f[2] - d[1]/2 - a[1]/2 == 0,
c[1]*f[1] + c[1] + f[1] + b[2]*e[2] - d[1]/2 - a[1]/2 == 0,
g[1]*d[1] + g[1] + d[1] - a[1] == 0,
a[1]*h[1] + h[1] - d[1] + a[1] == 0,
a[1]*d[2] + a[2]*d[1] + a[2] + d[2] + d[1]/2 - a[1]/2 == 0,
b[1]*e[2] + c[2]*f[1] + e[2] + c[2] + d[1]/2 - a[1]/2 == 0,
b[2]*e[1] + c[1]*f[2] + b[2] + f[2] + d[1]/2 - a[1]/2 == 0,
g[1]*h[1] + h[1] + g[1] == 0,
a[1]*d[1] + d[1] + a[1] + 4*a[2]*d[2] + 2*d[2] - 2*a[2] == 0,
b[1]*f[1] + b[1] + f[1] + c[2]*e[2] + d[2] - a[2] == 0}, {b[1],
c[1], d[1], e[1], f[1], g[1], h[1], a[1], b[2], c[2], d[2], e[2],
f[2], g[2], h[2]}]


it takes infinite time, and I still need to add more equations to determine all coefficients, so that the method I am trying to use seems inappropriate.

Is there something I can do to accelerate the process?

• may be because you have underdetermined systems (more variables than equations). There is no unique solution in this case. But I do not know exactly why it slows down when you added one more variable. It depends what algorithm Mathematica is using to solve undetermined system of equations. Feb 14 at 11:02
• FindInstance finishes very fast but only gives trivial solution. Feb 14 at 11:16
• @Nasser These equations should not determine all the variables, only after I add the remaining equations. However, they should still yield at least one solution where some of the variables are solved in terms of the others. Feb 14 at 11:42
• Including a[2] in the variables lists for Solve might provide more solutions but probably no faster. Feb 16 at 16:25
• I recommend that you post a new question with the complete set of equations you wish to solve. Adding equations one at a time is not the most efficient approach. Feb 17 at 11:52

Solving large systems of polynomial equations can be very difficult. The general approach involves using GroebnerBasis, which can be very slow. Here is an approach for obtaining solutions to the system of ten equations in the question, given that obtaining the solution for the first nine of those equations is easy. Designate the ten equations as eq and the corresponding variables as var. Then

s9 = Solve[Most@eq, var] // Simplify;
Length[s9]
(* 25 *)


is the result from the nine-equation system, which consists of 25 solutions. With a LeafCount of 2938, s9 is too long to display here. (The computation required abut 20 seconds on my 5.3 GHz PC.) Adding the tenth equation given in the question can be viewed as putting a constraint on those 25 solutions, which can be computed as follows:

Subtract @@@ Simplify[(Last@eq) //. # & /@ s9];
c10 = Simplify[Factor[Numerator[Together[#]]] & /@ %]


Here too, the result is much too long to be displayed. So, consider a particularly simple component,

s9[[25]]
(* {b[1] -> -1, c[1] -> -1, d[1] -> -2 (1 + a[2]), e[1] -> -1, f[1] -> -1,
g[1] -> 0, h[1] -> 0, a[1] -> -2 (1 + a[2]), d[2] -> -a[2],
e[2] -> (-1 - 2 a[2])/b[2],f[2] -> (-1 - 2 a[2])/c[2]} *)

c10[[25]]
(* (1 + 2 a[2]) (b[2] + c[2]) *)


Combine them to obtain

Solve[Join[Equal @@@ s9[[25]], {c10[[25]] == 0}]]
(* {{a[1] -> -1, a[2] -> -(1/2), b[1] -> -1, c[1] -> -1, d[1] -> -1, d[2] -> 1/2,
e[1] -> -1, e[2] -> 0, f[1] -> -1, f[2] -> 0, g[1] -> 0, h[1] -> 0},
{a[1] -> -2 (1 + a[2]), b[1] -> -1, b[2] -> -c[2], c[1] -> -1,
d[1] -> -2 (1 + a[2]), d[2] -> -a[2], e[1] -> -1, e[2] -> (1 + 2 a[2])/c[2],
f[1] -> -1, f[2] -> (-1 - 2 a[2])/c[2], g[1] -> 0, h[1] -> 0}} *)


which can be verified by substitution into the ten equations.

(And @@ Simplify[eq /. #] &) /@ %
(* {True, True} *)


This process can be applied to all 25 components of s9 and c10, although the computation takes a bit over an hour.

s10 = Union[Simplify[Flatten[Parallelize[
MapThread[Solve[Join[Equal @@@ #1, {#2 == 0}]] &, {s9, c10}],
Method -> "FinestGrained"], 1]]]
Length[%]
(* 67 *)


All 65 solutions can be verified by substitution into eq.

And @@ ((And @@ Simplify[eq /. #] &) /@ s10)
(* True *)


Whether this approach is generalizable to the still larger but unspecified equation set mentioned by the OP cannot be determined without seeing that set.

• bbgodfrey I need your help please for a numerical solution with FinRoot Mar 3 at 23:14
• @Gallagher Please tell me the question number on Mathematica where you need help. Mar 4 at 0:00