       Re: Diophantic equations

• To: mathgroup at smc.vnet.net
• Subject: [mg32777] Re: [mg32746] Diophantic equations
• From: Daniel Lichtblau <danl at wolfram.com>
• Date: Sat, 9 Feb 2002 05:11:52 -0500 (EST)
• References: <200202080849.DAA11925@smc.vnet.net>
• Sender: owner-wri-mathgroup at wolfram.com

```Max Ulbrich wrote:
>
> Hi,
>
> I try to solve equations where only integers are allowed, like
>
> a + b + 10 c = 100
> 5 a + 2 b + c = 100
>
> a, b, c should be integers and positve.
>
> How can I do this?
>
> Max

There is a method for handling these by Groebner bases, due to
Conti and Traverso. Nice expositions may be found in

W. Adams and P. Loustaunau (1994). An Introduction to Gröbner Bases.
Graduate Studies in Mathematics 3, American Mathematical Society.
D. Cox, J. Little, and D. O'Shea (1998). Using Algebraic Geometry.
Graduate Texts in Mathematics 185, Springer-Verlag

The idea is as follows. We form two new sets of variables, one for
rows and one for columns. We show rows first. We will use x[j] for
row j and raise x[j] to a power given by each side of the jth
equation. For the example given we have:

x^(a+b+10*c) == x^100
x^(5*a+2*b+c) == x^100

Now multiply these left hand sides and right hand sides together
to obtain

x^(a+b+10*c)*x^(5*a+2*b+c) == x^100*x^100

We regroup so that our original variables are exponents of
certain bases.

(x*x^5)^a * (x*x^2)^b * (x^10*x)^c ==
x^100*x^100

We now bring in the other set of variables. Specifically, we equate
them to the "bases" that appear on the left hand side above.

y == (x*x^5)
y == (x*x^2)
y == (x^10*x)

Here is where Groebner bases enter. The idea is that we form a basis
for the polynomials

polys = {y - (x*x^5), y - (x*x^2), y -
(x^10*x)}

with respect to a term ordering that places the x[j]'s higher than
the y[k]'s (we will use lexicographic).

gb = GroebnerBasis[polys, {x,x,y,y,y}];

If there is a nonnegative integer combination that works for
{a,b,c} in order to satisfy the original system, then it will show
up when we reduce the right hand side, x^100*x^100, in terms
of that basis and the same term ordering. Specifically, if an
answer exists, then we will get a reductum entirely in terms of
the y[k]'s. If you require strict positivity, replace your original
variables with aprime==a-1, etc., and rewrite the equations in terms
of these.

InputForm[Last[
PolynomialReduce[x^100*x^100, gb, {x,x,y,y,y}]]]

Out//InputForm= y^11*y^19*y^7

Our exponents {11,19,7} comprise a solution for the original
variables {a,b,c}. Note that such solutions need not be unique,
and others might be obtained by changing the term order used in
the computations. For example, if we make the original right hand
sides both 1000 then we can obtain:

In:= gb = GroebnerBasis[polys, {x,x,y,y,y}];

In:= InputForm[Last[
PolynomialReduce[x^1000*x^1000, gb,
{x,x,y,y,y}]]]
Out//InputForm= y^15*y^435*y^55

In:= gb = GroebnerBasis[polys, {x,x,y,y,y}];

In:= InputForm[Last[
PolynomialReduce[x^1000*x^1000, gb,
{x,x,y,y,y}]]]
Out//InputForm= y^167*y^43*y^79

The latter was performed alot faster, I might add (this sort of
thing is quite sensitive to term ordering).

To handle situations where we have negative coefficients one
may adapt by using extra variables and relations that in essence
force variables to be reciprocals.

The Groebner basis approach is more generally used in linear
integer programming. Details are in the references. One uses
the objective function cost to impose an appropriate term order.
A package to do this has been written by Devendra Kapadia here at
Wolfram Research (dkapadia at wolfram.com). I might add that it
demostrated some bottlenecks. Based on this I made modifications
to GroebnerBasis in our development version that are specific to
this sort of polynomial input (these are known as toric ideals).
I will also point out that the state of the art for this
general approach has advanced to ways that eradicate the
second set of variables and are in other respects specific to
toric ideals.

There are other methods, generally much faster, for attacking both
diophantine systems. There are also quite different methods for
handling linear integer programming. The former may be addressed
in a future release of Mathematica. The latter is also a topic of
some interest. One might see preliminary work in this direction at

http://library.wolfram.com/conferences/devconf2001/#numerics

The first bullet item discusses a heuristic approach to discrete
optimization.

Daniel Lichtblau
Wolfram Research

```

• Prev by Date: Re: FullSimplify doesn't simplify
• Next by Date: Has the Mathematica/Adobe Acrobat 5.0 Math1 Font Screwup Been Fixed Yet?
• Previous by thread: Diophantic equations
• Next by thread: Re: Diophantic equations