Skip to main content

Solving Linear Diophantine Equations for all integer solutions Using Python

   What is a linear Diophantine Equation?

The simplest linear Diophantine equation takes the form ax + by = d, where ab and c are given integers. The solutions are described by the following theorem:
This Diophantine equation has a solution (where x and y are integers) if and only if c is a multiple of the greatest common divisor of a and bMoreover, if (xy) is a solution, then the other solutions have the form (x + kvy − ku)where k is an arbitrary integer, and u and v are the quotients of a and b(respectively) by the greatest common divisor of a and b. (source: wiki)


To know whether a linear diophantine equation has integer solutions,  we use the principles of Bézout's identity which states that in a linear diophantine equation ax+by=d, if a and b are nonzero integers and d their greatest common divisor,there exists integer solutions for both x and y.

Linear diophantine equations can be solved using substitution or more preferably Extended Euclidean Algorithm. Solving a linear diophantine equation is fairly easy by computer too. Here's a code in python that I made recently,the steps are described in the comments with the code.

Here's a sample output















Comments

Post a Comment

Popular posts from this blog

Using Python, Quadratic approximation of sine function without the idea of limits or infinitesimal quantities (Mini Research Paper)

The question that I actually I started out was, Is there any way to express transcendental functions using polynomials avoiding the idea of limits or infinitesimal quantities?   Origin of the Question Nowadays,we learn about the Cauchy-Weierstrass interpretation of limits in our calculus classes.Although I genuinely think that it works and it’s more convenient but I thought there would be creative other ways to do this without the idea of estimating infinitesimal quantities.I found one paper named “ The Lost Calculus ”[1],it avoids the idea of abstract limits but fails when it comes to transcendental functions.I knew that if I broke down the sine function to be humble polynomials I could than use something like Descartes’s method[1] of Tangents to that polynomial to get the derivative without using the idea of limits. That’s when I was stumbled upon this question. First thing that came to my mind was a sine function,I was thinking if there was any way to represen...

Bohmian Mechanics(Pilot Wave theory) - A more deterministic approach towards Quantum Mechanics

Quantum mechanics had many interpretations for ages. The most accepted ones are the ones most experimentally proven ones. Bohmian mechanics is one of the less probabilistic and more conventional deterministic approach towards quantum mechanics. Bohmian theories can be formulated by introducing a privileged foliation of space-time. This introduction of a completely new foliation of space-time  would contradict with the theory of relativity,this is the reason of Bohmian mechanics not being so wide-spread or worked on. My research would be to work on Bohmian mechanics,trying to show a relativistic approach can be made to work for all inertial reference frames and pilot-wave theory can help solving the age long debate of the difference between Macroscopic and Microscopic world and if the spooky actions of the microscopic world is completely random or seems random because of the ignorance of pre-existing local variables. Bohmian mechanics or pilot wave theory is base...