2
$\begingroup$

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.

$\endgroup$
  • 2
    $\begingroup$ Can you please format your question properly? Read this here which you find when you click on the question mark of the editor window. $\endgroup$ – halirutan Aug 5 '13 at 22:10
  • $\begingroup$ Try (...) && (And @@ Table[...]) $\endgroup$ – rm -rf Aug 5 '13 at 23:52
  • $\begingroup$ The second solution to this answer:How to find lattice points on a line segment? is another example like one can use Solve. Perhaps you could see also this Solve an equation in R+ $\endgroup$ – Artes Aug 6 '13 at 14:09
3
$\begingroup$

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)
$\endgroup$
  • $\begingroup$ This works for me. Thanks. $\endgroup$ – TC Jones Aug 10 '13 at 22:02
  • $\begingroup$ @TCJones You're welcome. Please consider voting for posts you find helpful and Accepting those that are fully satisfactory. $\endgroup$ – Mr.Wizard Aug 10 '13 at 23:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.