3
$\begingroup$

Last time I did any maths was A-Level (some time ago!).

This is a programming/layout problem where I need to display 7 items across a page, with 6 gaps between them. I have a fixed width, but need to determine values of x and y that are integers where x > y.

This 'feels' like something I could plot on a graph, hence solve with calculus but I need a pointer in the right direction. Ideally I'd like to solve it programatically but I need an understanding of how to solve it first. Further down the line, I'd like to be able to vary the number of items to get different values.

Thanks

2 Answers 2

4

First, find one solution. Here you can say 700 = 7*100 + 6*0, or 700 = 700*1 = 700*(7-6) = 7*700 + 6*(-700).

One you have one solution $(x_1,y_1)$, another solution $(x_2,y_2)$ has to satisfy $7x_1+6y_1 = 700 = 7x_2+6y_2$, so $7(x_1-x_2) + 6(y_1-y_2) = 0$.

Here this means that $7(x_1-x_2) = 6(y_2-y_1)$. Since 6 and 7 are coprime, this number is a multiple of 42, so $7(x_1-x_2) = 6(y_2-y_1) = 42k$.

Now you get $x_2 = x_1 - 6k, y_2 = y_1+7k$, and that gives you the set of solutions $S = \{(100-6k, 0+7k), k \in \mathbb{Z}\}$. If you only want to have solutions with positive $0, this means you get constraints on $k$ : $0 < k$ and $k < 100/13$, which means $k \in \{1, 2, \ldots 7 \}$

Edit :

If you want to solve $a = nx + (n-1)y$, since $n$ and $n-1$ are coprime, the same method works : start with the particular solution $a = a*1 = n*a + (n-1)*(-a)$, so $(x=a, y= -a)$. the solutions in $\mathbb{Z}^2$ are $\{(x=a-k(n-1), y= kn-a)), k \in \mathbb{Z}\}$. Then you write the constraints $0 in terms of $k$ and you get $a/n < k < 2a/(2n-1)$

  • 0
    have you looked at this question http://math.stackexchange.com/questions/20906/how-to-find-an-integer-solution-for-general-diophantine-equation-ax-by-cz-d ?2011-02-25
1

If you want integer solutions, you have a linear diophantine equation. You can start by observing that $y$ must be a multiple of $7$, then simplify the equation using this.