πŸ“œ ⬆️ ⬇️

Solving linear diophantine equations with any number of unknowns.

image

Hello, dear readers! Continuing a series of amateurish articles on mathematics.


Today I propose to reflect on some interesting mathematical problem.
Namely, let's solve the following linear equation for warm-up:

5a+8b+3c+2d=17


β€œWhat is difficult?” - you ask. Indeed, only one equation and as many as four unknowns. Consequently, three variables are free, and the latter depends on these. So let's express it soon! For example, through the variable a , then the set of solutions is as follows:

 begincases displaystylea= frac17βˆ’8bβˆ’3cβˆ’2d5b,c,d in mathbbR endcases


Where  mathbbR - the set of any real numbers.

Well, the solution really turned out to be too trivial. Then we will complicate our task and make it more interesting.
')
Recall the linear equations with integer coefficients and integer roots , which, in fact, are a kind of Diophantine equations . Specifically, we impose on our equation a corresponding restriction on the integer coefficients and roots. Odds for unknowns are integers ( 5;eight;3;2;$1 ), but the unknowns themselves must be limited to the following:

a,b,c,d in mathbbZ


Where  mathbbZ - set of integers.

Now, the solution obtained at the beginning of the article β€œdoes not go away”, since we risk getting a as a rational (fractional) number. So how to solve this equation exclusively in integers?

Interested in the decision of the given problem I ask under kat.

And we continue. Let's try to make some elementary transformations of the desired equation:

5a+8b+3c+2d=17 Leftrightarrow5a+8b+2(c+d)+c=17


The task still looks incomprehensible; in such cases, mathematicians usually make some kind of replacement. Let us and her bahney with you:

c+d=t Rightarrow5a+8b+2(c+d)+c=17 Leftrightarrow5a+8b+2t+c=$1


Oops, we have achieved an interesting result! Coefficient of c we are now equal to one , which means that you and I can express this unknown through the remaining unknowns in this equation without any divisions (which we sinned at the very beginning of the article). Let's do it:

5a+8b+2t+c=17 Leftrightarrowc=17βˆ’5aβˆ’8bβˆ’2t


Let me note that this tells us that whatever a,b,t (within the framework of Diophantine equations), anyway c will remain an integer, and that's fine.

Remembering that c+d=t fair to say that d=tβˆ’c . And substituting instead c the result obtained above will be obtained:

d=tβˆ’c=tβˆ’(17βˆ’5aβˆ’8bβˆ’2t)=3t+5a+8bβˆ’17


Here we also see that what would not be a,b,t , does not matter d will remain an integer, and it is still beautiful.

Then a brilliant idea comes to mind: so let's a,b,t declare as free variables, and c,d will express through them! In fact, we have already done it. It remains only to record the answer in the system solutions:

 begincases displaystylea,b,t in mathbbZc=17βˆ’5aβˆ’8bβˆ’2td=3t+5a+8bβˆ’17 endcases


Now it is possible to contemplate that there is no division anywhere in the system of solutions, which means that decisions will always be integers. Let's try to find a particular solution to the original equation, for example, putting a=1;b=2;t=3 :

 begincases displaystylea=1b=2t=3c=17βˆ’5 cdot1βˆ’8 cdot2βˆ’2 cdot3=βˆ’10d=3 cdot3+5 cdot1+8 cdot2βˆ’17=13 endcases


Substitute in the original equation:

5 cdot1+8 cdot2+3 cdot(βˆ’10)+2 cdot13=17 Leftrightarrow17=17


Identical, cool! Let's try one more time on another example?

3a+7bβˆ’11c=1


Here we see a negative coefficient, it can give us a lot of problems, so let's get rid of sin by replacing it cβ€²=βˆ’c , then the equation will be as follows:

3a+7b+11cβ€²=1


As we remember, our task is to make such transformations so that in our equation there is an unknown with a unit coefficient for it (to then express it through the others without any division). To do this, we must again take something out of the box, the fastest is to take the coefficients from the equation that are closest to one. However, you need to understand that you can take only the number that necessarily is some coefficient of the equation (no more, no less), otherwise we run into a tautology / contradiction or fractions (in other words, it is impossible for free variables to appear somewhere except in the last replacement). So:

3a+7b+11cβ€²=1 Leftrightarrow3(a+b)+4b+11cβ€²=1


We introduce a replacement a+b=t1 , then we get:

3(a+b)+4b+11cβ€²=1 Leftrightarrow3t1+4b+11cβ€²=1


Again, we take the bracket and finally we get in the equation the unknown with the unit coefficient:

3t1+4b+11cβ€²=1 Leftrightarrow3(t1+b)+b+11cβ€²=1


We introduce a replacement t1+b=t2 , then:

3(t1+b)+b+11cβ€²=1 Leftrightarrow3t2+b+11cβ€²=1


Express from here our lonely unknown b :

3t2+b+11cβ€²=1 Leftrightarrowb=1βˆ’11cβ€²βˆ’3t2


From this it follows that whatever cβ€²,t2 we didn't take b still be an integer. Then we find t1 from the ratio t1+b=t2 :

t1+b=t2 Leftrightarrowt1=t2βˆ’b=t2βˆ’(1βˆ’11cβ€²βˆ’3t2) Leftrightarrowt1=4t2+11cβ€²βˆ’1


Similarly, we find a from the ratio a+b=t1 :

a+b=t1 Leftrightarrowa=t1βˆ’b=4t2+11cβ€²βˆ’1βˆ’(1βˆ’11cβ€²βˆ’3t2) Leftrightarrowa=7t2+22cβ€²βˆ’2


This is where our decision system has matured - we have expressed absolutely all unknowns, without resorting to division, thereby showing that the solution will definitely be integer. Also do not forget that cβ€²=βˆ’c , and we need to introduce a reverse replacement. Then the final decision system is as follows:

 begincases displaystylea=7t2βˆ’22cβˆ’2b=βˆ’3t2+11c+1c,t2 in mathbbZ endcases



Thus, it remains to answer the question - is it possible to solve any such equation? The answer is no, if the equation is in principle unsolvable. This occurs in those cases where the free member is not divided completely into the GCD of all coefficients with unknowns. In other words, having the equation:

a1b1+a2b2+..+anbn=N


To solve it in integers, the following condition is sufficient:

N modGCD(a1,a2,..,an)=0


(Where GCD - the greatest common divisor ).
Evidence
The proof in the framework of this article is not considered, since this is the reason for a separate article. You can see it, for example, in the wonderful book of V. Sierpinski β€œOn solving equations in whole numbers” in Β§2.


Summarizing the above, we will write out an action algorithm for solving linear Diophantine equations with any number of unknowns:

  1. We check if the equation can be solved at all (using the above described property N modGCD(a1,a2,..,an)=0 ). If the answer is yes, go to the next item.
  2. To speed up the process, we divide all coefficients (including the free term) into their GCD .
  3. We get rid of negative coefficients in the equation by replacing aβ€²n=βˆ’an
  4. We carry out a series of substitutions (breaking up some terms of the equation into sums and combining them into brackets) so that in the end one of the terms of the equation has unit coefficients, and we can derive it without any division. Remembering that only one number can be taken as a bracket, which is necessarily some coefficient of the equation (no more, no less), otherwise we run into a tautology / contradiction or fractions (in other words, it is impossible for free variables to appear somewhere except as in the last replacement). Finally, we declare all the variables through which it is expressed as free.
  5. We deduce the rest of the variables through the above (we deduce from all our replacements), not forgetting also about reverse replacements.
  6. We combine everything into a single solution system.

In conclusion, it should be said that it is also possible to add restrictions on each term of the equation in the form of inequality on it (then the system of inequalities is added to the system of solutions, according to which you will need to correct the answer), and also add something interesting. Another thing to keep in mind is that the solution algorithm is strict and can be recorded in the form of a computer program.

Peter was with you
Thanks for attention.

Source: https://habr.com/ru/post/330632/


All Articles