Equation for integer exponents

I'm trying to solve some equations regarding power expansions, but Mathematica doesn't seem to find any solutions (it runs for an arbitrary long time). For example, I have the equation:

x1^-n[1, 1] (x1 - x2)^(-2 + n[1, 1] + n[1, 2] + n[1, 3]) x2^(
1 - n[1, 2]) (x1 + x2)^-n[1, 3] sgn[1] +
x1^(1 - n[2, 1]) (x1 - x2)^(-2 + n[2, 1] + n[2, 2] + n[2, 3])
x2^-n[2, 2] (x1 + x2)^-n[2, 3] sgn[2] == 0;


for integers n[i,j] and sgn[i] being either 0,1 or -1. For the second condition, I just add the equation sgn[1]==Sign[sgn[1]] and so on for sgn[2] and sgn[3]. I thought that Mathematica would have the least problems if I substituted x1 and x2 by random numerical values and repeated that enough times instead of leaving them as arbitrary variables, but neither Solve nor Reduce seem to do the job. However, I know that e.g.

{sgn[1]->1, sgn[2]->-1, sgn[3]->0, n[1,1]->0, n[1,2]->1, n[1,3]->1, n[2,1]->1, n[2,2]->0, n[2,3]->1}


is a valid solution for this equation. Is there a way to efficiently ask Mathematica so that it provided the general solution? Thanks in advance.

The code I'm using is:

signList = sgn /@ Range[4];
sgnEq = Table[sgn[ii] == Sign[sgn[ii]], {ii, Length@signList}];
powerList = Table[n[ii, jj], {ii,4}, {jj, 3}];
x2Num = {Rule[x1, RandomInteger[{10, 1000}]], Rule[x2, RandomInteger[{10, 1000}]]};
eqDep = Join[sgnEq, Table[entireEq /. x2Num, {jj, 100}] // Flatten];
sol = Reduce[eqDep, {signList, powerList} // Flatten, Integers];


where entireEq is just the first equation in my post.

• Plugging your known solution into EntireEq, i.e., EntireEq /. {sgn[1] -> 1, sgn[2] -> 2, sgn[3] -> 0, n[1, 1] -> 0, n[1, 2] -> 1, n[1, 3] -> 1, n[2, 1] -> 1, n[2, 2] -> 0, n[2, 3] -> 1} evaluates to 3/(x1 + x2) == 0 rather than True. Something appears to be missing/incorrect. Commented Jul 18, 2023 at 15:40
• @BobHanlon that's right, my mistake. sgn[2] should be -1, not 2. I've corrected the post. Commented Jul 18, 2023 at 15:45

\$Version

(* "13.3.0 for Mac OS X ARM (64-bit) (June 3, 2023)" *)

Clear["Global*"]

entireEq =
x1^-n[1, 1] (x1 - x2)^(-2 + n[1, 1] + n[1, 2] + n[1, 3]) x2^(1 -
n[1, 2]) (x1 + x2)^-n[1, 3] sgn[1] +
x1^(1 - n[2, 1]) (x1 - x2)^(-2 + n[2, 1] + n[2, 2] + n[2, 3]) x2^-n[2,
2] (x1 + x2)^-n[2, 3] sgn[2] == 0;

vars = {sgn[1], sgn[2], sgn[3], n[1, 1], n[1, 2], n[1, 3], n[2, 1], n[2, 2],
n[2, 3]};

sol = Thread[vars -> #] & /@
Select[Tuples[{-1, 0, 1}, {9}], entireEq /. Thread[vars -> #] &];


Verifying all of the solutions,

And @@ (entireEq /. sol)

(* True *)


Number of solutions:

Length@sol

(* 2259 *)


First few examples

sol[[1 ;; 5]]

(* {{sgn[1] -> -1, sgn[2] -> 1, sgn[3] -> -1, n[1, 1] -> -1, n[1, 2] -> 0,
n[1, 3] -> -1, n[2, 1] -> 0, n[2, 2] -> -1, n[2, 3] -> -1}, {sgn[1] -> -1,
sgn[2] -> 1, sgn[3] -> -1, n[1, 1] -> -1, n[1, 2] -> 0, n[1, 3] -> 0,
n[2, 1] -> 0, n[2, 2] -> -1, n[2, 3] -> 0}, {sgn[1] -> -1, sgn[2] -> 1,
sgn[3] -> -1, n[1, 1] -> -1, n[1, 2] -> 0, n[1, 3] -> 1, n[2, 1] -> 0,
n[2, 2] -> -1, n[2, 3] -> 1}, {sgn[1] -> -1, sgn[2] -> 1, sgn[3] -> -1,
n[1, 1] -> -1, n[1, 2] -> 1, n[1, 3] -> -1, n[2, 1] -> 0, n[2, 2] -> 0,
n[2, 3] -> -1}, {sgn[1] -> -1, sgn[2] -> 1, sgn[3] -> -1, n[1, 1] -> -1,
n[1, 2] -> 1, n[1, 3] -> 0, n[2, 1] -> 0, n[2, 2] -> 0, n[2, 3] -> 0}} *)


Verifying that your known solution is in sol

MemberQ[sol, {sgn[1] -> 1, sgn[2] -> -1, sgn[3] -> 0, n[1, 1] -> 0,
n[1, 2] -> 1, n[1, 3] -> 1, n[2, 1] -> 1, n[2, 2] -> 0, n[2, 3] -> 1}]

(* True *)

• That is very good! I can definitely use this to start with my problem. The only downside is that it has to go through the space of possible solutions. Do you know of a way that gives a general answer, meaning some of the n[i,j]` in terms of the other ones? Commented Jul 18, 2023 at 16:38