2

When one sets up an equation to solve one often needs to specify conditions on the variables such as

{ x>0 && y>0 && z>0 }

This is not a problem if only a few variables are involved. However, it is another matter when say, 50 are required. Is there a compact form one can use? Using

(...) && Table[x[[i]], {i,50}] > 0

within Reduce[] or Solve[] will not work.

Nasser
  • 143,286
  • 11
  • 154
  • 359
TC Jones
  • 207
  • 1
  • 3

1 Answers1

3

One approach:

eqs = {x^2 + 4 y^2 + 9 z^2 + 16 t^2 == 354};

vars = Variables @ Level[eqs, -1]

Reduce[eqs ~Join~ Thread[vars > 0], {}, Integers]
{t, x, y, z}

(t == 1 && x == 1 && y == 8 && z == 3) || (t == 1 && x == 7 && y == 4 && z == 5) || (t == 2 && x == 1 && y == 4 && z == 5) || (t == 2 && x == 5 && y == 8 && z == 1) || (t == 2 && x == 7 && y == 2 && z == 5) || (t == 4 && x == 1 && y == 2 && z == 3) || (t == 4 && x == 5 && y == 4 && z == 1)

Mr.Wizard
  • 271,378
  • 34
  • 587
  • 1,371