[Math] Finding integer solutions to a system of linear equations

diophantine equationsintegerslinear algebrasystems of equations

Given the following system of linear equations:

$$ a_1−a_2−b_1+b_2=x $$
$$ a_1+a_2=n_1 $$
$$ b_1+b_2=n_2 $$
$$ a_1+b_1=n_1 $$
$$ a_2+b_2=n_2 $$

For a given positive non-zero integer value of $n_1$ and $n_2$ , e.g. $n_1=33$,$n_2=27$, find:

1. if the system has any solution in the positive natural numbers including 0

2. if 1. is true, find the values of $x$,$a_1$,$a_2$,$b_1$,$b_2$, for which the system has a solution

3. find the smallest value of $x$ -> $min(x)$ , for which the system has a solution

For example for: $n_1=31$,$n_2=23$ one solution is $x=2=min(x)$,$a_1=18$,$a_2=13$,$b_1=13$,$b_2=10$.

4. is it possible to find a formula that relates $n_1$ and $n_2$ to $x$, i.e. $min(x)=f(n_1,n_2)$

By playing around a bit with different values for $n_1$ and $n_2$, I found that if $n_1$ and $n_2$ are both equal and even numbers, there exist a solution where $x=0$. But I'm not sure if this is true for all even values and combinations of $n_1$ and $n_2$ and I'm not sure how to formally prove this. So

5. prove that for even and equal numbers of $n_1$ and $n_2$, there always exist a solution where $x=0$

I'm no mathematician and my linear algebra is a bit rusty, so I was hoping for some tips how to approach this problem.

Best Answer

We have $$ a_1−a_2−b_1+b_2=x $$ $$ a_1+a_2=n_1 $$ $$ b_1+b_2=n_2 $$ $$ a_1+b_1=n_1 $$ $$ a_2+b_2=n_2 $$

Noting that $$a_2=n_1-a_1=b_1$$ and letting $a_2=k$, we see that we have $$(a_1,a_2,b_1,b_2,x)=(n_1-k,k,k,n_2-k,n_1+n_2-4k)\tag1$$ for some $k$.

For 1., 2. :

The system has a solution in non-negative integers if and only if we have $$n_1-k\ge 0\quad\text{and}\quad k\ge 0\quad\text{and}\quad n_2-k\ge 0\quad\text{and}\quad n_1+n_2-4k\ge 0\quad\text{where}\quad k\in\mathbb Z,$$ i.e. $$0\le k\le \min\left\{n_1,n_2,\left\lfloor\frac{n_1+n_2}{4}\right\rfloor\right\}\quad\text{where}\quad k\in\mathbb Z$$

For 3., 4. :

From 1., 2., $$x_{\text{min}}=n_1+n_2-4\min\left\{n_1,n_2,\left\lfloor\frac{n_1+n_2}{4}\right\rfloor\right\}$$

For 5. :

Since $k=n_1/2$, from $(1)$, $$(a_1,a_2,b_1,b_2,x)=\left(\frac{n_1}{2},\frac{n_1}{2},\frac{n_1}{2},\frac{n_1}{2},0\right)$$ is a solution.

Related Question