4

I want to use Mathematica to solve the problem:

Find the maximum $k$ such that $6x+9y+20z=k$ does not have a non-negative solution.

I tried FrobeniusSolve. But what is the elegant way to find the maximum?

I know the theoretical background of this problem, and I know other ways of getting the solution. But I want to see how this can be done elegantly in Mathematica.

Artes
  • 57,212
  • 12
  • 157
  • 245
Qiang Li
  • 1,121
  • 10
  • 19
  • I'm not sure I understand this. If positive x, y, z are a solution for a given k, then nx, ny and nz are a solution for nk. So it seems to me there is no maximum k. – Sjoerd C. de Vries May 28 '13 at 20:35
  • @SjoerdC.deVries it is expected that there are infinitely many k that have a solution. In fact the question seem to assume that for some N, all k>N have solutions. We wish to find the smallest such N. That is the same as to say, we wish to find the largest k that does not have a solution. I think. – Jacob Akkerboom May 28 '13 at 20:43
  • 2
    The short answer to this question is to use FrobeniusNumber[{6, 9, 20}]. – Jacob Akkerboom May 28 '13 at 20:53
  • http://mathworld.wolfram.com/CoinProblem.html if you want to implement something yourself. There is a downloadable notebook. – Jacob Akkerboom May 28 '13 at 20:56
  • @JacobAkkerboom I guess we're reading different things in the question and I'm afraid I don't see any grounds for your interpretation based on the literal text of the question. The question asks for a maximum k and I feel it's pretty clear there can generally not be a maximum k. – Sjoerd C. de Vries May 28 '13 at 20:58
  • @SjoerdC.deVries I feel the question has been stated almost the same in both the docs and on mathworld. – Jacob Akkerboom May 28 '13 at 21:02
  • @JacobAkkerboom I guess the double negatives were getting at me. BTW Do you understand why FrobeniusSolve[{12, 16, 20, 27}, 88] and FrobeniusSolve[{12, 16, 20, 27}, 90] both find non-negative solutions whereas the Frobenius number of this series is supposed to be FrobeniusNumber[{12, 16, 20, 27}]==89? – Sjoerd C. de Vries May 28 '13 at 21:27
  • Can be set up as follows. Resolve[Exists[n, n >= 1 && ForAll[k, Implies[k > n, Exists[{x, y, z}, x >= 0 && y >= 0 && z >= 0 && {6, 9, 20}.{x, y, z} == k]]]], Integers]. I would not be surprised if it takes around infinitely long to resolve this though. – Daniel Lichtblau May 28 '13 at 21:43
  • @JacobAkkerboom You are right, consider switching your comment to an answer. – Artes May 28 '13 at 21:50
  • @SjoerdC.deVries The double negatives also get to me :). I had to really think about your last comment. Maybe evaluate Table[ {iiii, FrobeniusSolve[{12, 16, 20, 27}, iiii, 1]}, {iiii, 500}] // Column. The point is that for iiii>89, there is always a solution. We may also not have a solution for iiii=85, but 89 is the largest number for which we have no solution. – Jacob Akkerboom May 28 '13 at 22:17

1 Answers1

4

You should use FrobeniusNumber instead of FrobeniusSolve, since it serves this purpose

The Frobenius number of $a_{1}, ... a_{n}$,.is the largest integer b for which the Frobenius equation $a_{1} x_{1}+ ... a_{n} x_{n} = k$ has no non-negative integer solutions. The $a_{i}$ must be positive integers.

FrobeniusNumber[{6, 9, 20}]
43

Nevertheless you can still get the result playing with FrobeniusSolve, there might be many possible ways, let's point out one of them using Cases with an appropriate replacement rule e.g.

Max @ Cases[ Table[{ k, FrobeniusSolve[{6, 9, 20}, k] != {}}, {k, 100}], {a_, False} -> a]
43

In case of not knowing FrobeniusNumber, one can get an idea also with Reduce or Solve although these ways are not recommended for diophantine equations, see e.g. Finding the number of solutions to a diophantine equation.

Artes
  • 57,212
  • 12
  • 157
  • 245