ASKSAGE: Sage Q&A Forum - Individual question feedhttp://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Wed, 08 Feb 2012 04:21:06 -0600Solving multilinear integer equationshttp://ask.sagemath.org/question/8699/solving-multilinear-integer-equations/I'd like to explore the solutions of a multilinear diophantine equation like $12(yz) + 6(y+z) +2 -4xw -2(w+x) = 0$. In particular I'd like to generate instances of solutions. I tried the function solve like:
(x,y,z,w) = var('x,y,z,w')
assume(x, 'integer'); assume(y, 'integer')
assume(z, 'integer'); assume(w, 'integer')
solve([12*(y*z) + 6*(y+z) +2 -4*x*w -2*(w+x) == 0, y==y], x)
which gives me the not particularly useful output:
[[x == (3*(2*r1 + 1)*r2 + 3*r1 - r3 + 1)/(2*r3 + 1), y == r1, z == r2, w == r3]]
I'd like to generate some actual quadruples that solve this equation or possibly investigate the structure more. Is there some systematic way to do this? In particular, when playing around with coefficients, is there a test of existence of an integer solution?
**Edit**: I had typos in the first version, I edited the equation.
Mon, 06 Feb 2012 02:06:08 -0600http://ask.sagemath.org/question/8699/solving-multilinear-integer-equations/Comment by achrzesz for <p>I'd like to explore the solutions of a multilinear diophantine equation like $12(yz) + 6(y+z) +2 -4xw -2(w+x) = 0$. In particular I'd like to generate instances of solutions. I tried the function solve like: </p>
<pre><code>(x,y,z,w) = var('x,y,z,w')
assume(x, 'integer'); assume(y, 'integer')
assume(z, 'integer'); assume(w, 'integer')
solve([12*(y*z) + 6*(y+z) +2 -4*x*w -2*(w+x) == 0, y==y], x)
</code></pre>
<p>which gives me the not particularly useful output:</p>
<pre><code>[[x == (3*(2*r1 + 1)*r2 + 3*r1 - r3 + 1)/(2*r3 + 1), y == r1, z == r2, w == r3]]
</code></pre>
<p>I'd like to generate some actual quadruples that solve this equation or possibly investigate the structure more. Is there some systematic way to do this? In particular, when playing around with coefficients, is there a test of existence of an integer solution?</p>
<p><strong>Edit</strong>: I had typos in the first version, I edited the equation.</p>
http://ask.sagemath.org/question/8699/solving-multilinear-integer-equations/?comment=20337#post-id-20337Is this helpful?
sage: maxima('solve(12*(y*z) + 6*(y+x) +2 -4*x*y -2*(w+x) = 0, [x,y,z,w])').sage()
[[x == r1, y == r2, z == r3, w == -(2*r1 - 3)*r2 + 6*r2*r3 + 2*r1 + 1]]Mon, 06 Feb 2012 04:51:41 -0600http://ask.sagemath.org/question/8699/solving-multilinear-integer-equations/?comment=20337#post-id-20337Comment by kcrisman for <p>I'd like to explore the solutions of a multilinear diophantine equation like $12(yz) + 6(y+z) +2 -4xw -2(w+x) = 0$. In particular I'd like to generate instances of solutions. I tried the function solve like: </p>
<pre><code>(x,y,z,w) = var('x,y,z,w')
assume(x, 'integer'); assume(y, 'integer')
assume(z, 'integer'); assume(w, 'integer')
solve([12*(y*z) + 6*(y+z) +2 -4*x*w -2*(w+x) == 0, y==y], x)
</code></pre>
<p>which gives me the not particularly useful output:</p>
<pre><code>[[x == (3*(2*r1 + 1)*r2 + 3*r1 - r3 + 1)/(2*r3 + 1), y == r1, z == r2, w == r3]]
</code></pre>
<p>I'd like to generate some actual quadruples that solve this equation or possibly investigate the structure more. Is there some systematic way to do this? In particular, when playing around with coefficients, is there a test of existence of an integer solution?</p>
<p><strong>Edit</strong>: I had typos in the first version, I edited the equation.</p>
http://ask.sagemath.org/question/8699/solving-multilinear-integer-equations/?comment=20336#post-id-20336Hmm, but those are *real* solutions, not integer, though in this case it looks like it will work if you use all integers. Mon, 06 Feb 2012 07:19:02 -0600http://ask.sagemath.org/question/8699/solving-multilinear-integer-equations/?comment=20336#post-id-20336Answer by Volker Braun for <p>I'd like to explore the solutions of a multilinear diophantine equation like $12(yz) + 6(y+z) +2 -4xw -2(w+x) = 0$. In particular I'd like to generate instances of solutions. I tried the function solve like: </p>
<pre><code>(x,y,z,w) = var('x,y,z,w')
assume(x, 'integer'); assume(y, 'integer')
assume(z, 'integer'); assume(w, 'integer')
solve([12*(y*z) + 6*(y+z) +2 -4*x*w -2*(w+x) == 0, y==y], x)
</code></pre>
<p>which gives me the not particularly useful output:</p>
<pre><code>[[x == (3*(2*r1 + 1)*r2 + 3*r1 - r3 + 1)/(2*r3 + 1), y == r1, z == r2, w == r3]]
</code></pre>
<p>I'd like to generate some actual quadruples that solve this equation or possibly investigate the structure more. Is there some systematic way to do this? In particular, when playing around with coefficients, is there a test of existence of an integer solution?</p>
<p><strong>Edit</strong>: I had typos in the first version, I edited the equation.</p>
http://ask.sagemath.org/question/8699/solving-multilinear-integer-equations/?answer=13256#post-id-13256You can divide by $2$ and solve for $w$. So the set of all solutions is parametrized by $(x,y,z)\in\mathbb{Z}^3$ arbitrary.Mon, 06 Feb 2012 11:46:07 -0600http://ask.sagemath.org/question/8699/solving-multilinear-integer-equations/?answer=13256#post-id-13256Comment by Thomas for <p>You can divide by $2$ and solve for $w$. So the set of all solutions is parametrized by $(x,y,z)\in\mathbb{Z}^3$ arbitrary.</p>
http://ask.sagemath.org/question/8699/solving-multilinear-integer-equations/?comment=20326#post-id-20326Well, I have a typo even in the first example :( My starting point was $4nyz + 2n(y + z) + n - 4wx - 2(w + x) ? 1 = 0$ for odd $n$.
Wed, 08 Feb 2012 04:21:06 -0600http://ask.sagemath.org/question/8699/solving-multilinear-integer-equations/?comment=20326#post-id-20326Comment by kcrisman for <p>You can divide by $2$ and solve for $w$. So the set of all solutions is parametrized by $(x,y,z)\in\mathbb{Z}^3$ arbitrary.</p>
http://ask.sagemath.org/question/8699/solving-multilinear-integer-equations/?comment=20331#post-id-20331Well, Thomas did say equations *like* that one, not just that one...Mon, 06 Feb 2012 13:40:03 -0600http://ask.sagemath.org/question/8699/solving-multilinear-integer-equations/?comment=20331#post-id-20331Answer by kcrisman for <p>I'd like to explore the solutions of a multilinear diophantine equation like $12(yz) + 6(y+z) +2 -4xw -2(w+x) = 0$. In particular I'd like to generate instances of solutions. I tried the function solve like: </p>
<pre><code>(x,y,z,w) = var('x,y,z,w')
assume(x, 'integer'); assume(y, 'integer')
assume(z, 'integer'); assume(w, 'integer')
solve([12*(y*z) + 6*(y+z) +2 -4*x*w -2*(w+x) == 0, y==y], x)
</code></pre>
<p>which gives me the not particularly useful output:</p>
<pre><code>[[x == (3*(2*r1 + 1)*r2 + 3*r1 - r3 + 1)/(2*r3 + 1), y == r1, z == r2, w == r3]]
</code></pre>
<p>I'd like to generate some actual quadruples that solve this equation or possibly investigate the structure more. Is there some systematic way to do this? In particular, when playing around with coefficients, is there a test of existence of an integer solution?</p>
<p><strong>Edit</strong>: I had typos in the first version, I edited the equation.</p>
http://ask.sagemath.org/question/8699/solving-multilinear-integer-equations/?answer=13254#post-id-13254This is NOT a 'real' answer - achrzesz had the real idea. Maybe he should post it for credit. This is just it in Sage.
sage: (x,y,z,w) = var('x,y,z,w')
sage: solve([12*(y*z) + 6*(y+x) +2 -4*x*y -2*(w+x) == 0,y==y], x,y,z,w)
[[x == r6, y == r7, z == r8, w == -(2*r6 - 3)*r7 + 6*r7*r8 + 2*r6 + 1]]
You may ask why we need the dummy equation `y==y`. See [this Trac ticket](http://trac.sagemath.org/sage_trac/ticket/10750).
This does *not* answer the question of how to treat this as a non-linear Diophantine equation. I seem to recall that this is [undecidable](http://en.wikipedia.org/wiki/Diophantine_set#Application_to_Hilbert.27s_Tenth_problem), but maybe I'm misinterpreting your question. You can always just do something really naive like loop through all integers. I don't know that we have anything more efficient that that for integers.Mon, 06 Feb 2012 07:29:24 -0600http://ask.sagemath.org/question/8699/solving-multilinear-integer-equations/?answer=13254#post-id-13254