Problem Statement
I have a linear equation of the form $m*x - n*y = 0$, where $m, n$ are known rational numbers (integers, terminating decimals, and repeating decimals). How to find the values of $x, y$ that solves the above equation such that they are strictly integers.

Research Effort
If $m = 10, n = 2$, then it is very easy to find $x, y$ whose values will be 1 & 5 respectively. But I don't know how to solve this equation for large numbers, fractional numbers. I used matlab to write a small code to find this using trial & error

length = 100;  
m = 1440;  
n = 115.2;  
x = 1:1:length;
mx = m*x;
y = mx/n;  

Then i look through y array to find the first integer number & that becomes my solution. But how do i do solve it mathematically without this matlab trial & error

  • 1
    $\begingroup$ Multiply by the $\operatorname{lcm}$ of the denominators of $\,m,n\,$ and you get an equation in integers. Then it's obvious. $\endgroup$ – dxiv Sep 29 '18 at 5:29

This is a question at the very beginning of Linear Algebra. Several cases have to be considered. 1) $n=0$ and $m=0$. Then the equation is satisfied for all $x,y$. 2) If $n\not=0$ you may choose $x$ arbitrarily and calculate $y$ from the equation as $y=\frac{mx} n$.

The remaining case $n=0$ and $m\not=0$ is treated similarily.

Edit according to modified question: We may assume that both $m$ and $n$ are integer s by multiplying the the equation with some suitable integer. Then in the first case above $x,y$ are arbitrary integers. In the second case $x$ is arbitrary up to the condition that $n$ must be a divisor of $mx$. The Thier case again is of a similar taste.

It seems that the added condition makes the question one belonging to the theory of numbers. A tag would be linear congruences.

  • $\begingroup$ Sorry, I forgot to include the detail that x & y solution have to be an integer only. $\endgroup$ – KharoBangdo Sep 29 '18 at 5:22
  • $\begingroup$ Thanks for the edited answer but as mentioned in my OP, m, n are rational numbers. They can be integers or fractions. Also, I could not find the linear-congruences tag & I can't create new tags $\endgroup$ – KharoBangdo Sep 29 '18 at 5:45
  • $\begingroup$ If $m,n$ are rational, there are integers $a,b,c,d$ such that $m=a/b,n=c/d$ (and $b,d\not=0$). Then you may multiply the original equation with $bd$ to get the equation $(mab)x-(nab)y=0$ with integer coefficients $mab$ and $nab$. Another tag would be diophantine equation. You also may look at Wikipedia, or so, with both tags. $\endgroup$ – Jens Schwaiger Sep 29 '18 at 6:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.