Take the 2-minute tour ×
Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. It's 100% free, no registration required.

Given an equation of a straight line of form $Ax + By = C$. where $A,B,C$ are integers. How could we check if this passes through any lattice point or not?

Please suggest me a suitable algorithm.

share|improve this question
2  
What is the lattice? –  Fabian Apr 10 '11 at 19:13
2  
Assuming you mean the integer lattice in $\mathbb{R}^2$, it might be instructive to consider Euclid's Algorithm, since there are always integer solutions to the equation $Ax+By=GCD(A,B)$. So if $GCD(A,B)\vert C$ then you definitely have integer solutions. I'm not sure about the converse, i.e. if GCD isn't a factor. –  Jon Beardsley Apr 10 '11 at 19:19
    
i assume $\mathbb{Z}^2$. $Ax+By=C$ has solutions iff $(A,B)|C$ ($C$ would have to be in the ideal generated by $A,B$) –  yoyo Apr 10 '11 at 19:19
1  
@JBeardz Your argument is an if and only if statement. –  Adrián Barquero Apr 10 '11 at 19:22

2 Answers 2

up vote 2 down vote accepted

Assuming you mean the lattice of integers, that is equivalent to checking if the equation has integer solutions.

Assume that $k\times GCD(A,B)=C$. Then by Euclid's algorithm, there are $X,Y$ such that $AX+BY=GCD(A,B)$, so $AkX+BkY=C$, where $kX$ and $kY$ must be integers.

On the other hand, assume $Ax+By=C$ has a solution. Then $GCD(A,B)\left(\frac{A}{GCD(A,B)}X+\frac{B}{GCD(A,B)}Y\right)=C$ so $GCD(A,B)$ divides $C$.

share|improve this answer

I assume the lattice you are using is $\mathbb{Z}^2$, consisting of all integer pairs $(x,y)$. What you have is an example of a linear diophantine equation, meaning that you are looking for integer pairs $(x,y)$ satisfying this equation. The key here is to see whether or not $C$ is divisible by $gcd(A,B)$. If so, there are infinitely many solutions (this is known as Bezout's identity).

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.