3

Given two functions of the form $y = m_1x + c_1$ and $y = m_2x + c_2$ where $m_1,m_2,c_1,c_2$ are positive integers. How to find the absolute minimum difference between the two functions for positive integral values of $x$?

e.g. for $y_1=10x+1$ and $y_2=3x+5$ the absolute minimum difference is $0$ for $x_1=1$ and $x_2=2$ where $x_1$ and $x_2$ corresponds to $y_1$ and $y_2$ respectively.

1 Answers1

1

You are basically asking whether you can find positive integers $x_{1,2}$ such that $$m_1x_1+c_1=m_2x_2+c_2$$ which is the same as $$m_1x_1-m_2x_2=c_2-c_1.$$ If such positive integers exist, then the minimum is zero.

If not, you want to find smallest $d$ (smallest in absolute value) such that $$m_1x_1-m_2x_2=c_2-c_1+d$$ has a solution.

The equation of the form $$m_1x_1-m_2x_2=A$$ is a linear Diophantine equation and there is a simple way of saying whether there is a solution: It is true if and only if $\gcd(m_1,m_2)\mid A$. Solutions can be found using extended Euclidean algorithms.

This only gives you a solution $x_{1,2}\in\mathbb Z$. But since $m_{1,2}>0$, the solutions will be in fact non-negative.

See also:

The example you gave in the question leads to the Diophantine equation $$10x_1-3x_2=4,$$ which indeed has solution $x_1=1$, $x_2=2$.