Mosaic in the bathroom and Diophantine equations

It was in the evening, before going to bed. I brushed my teeth and looked tiredly at the mosaic in the bathroom. For some reason, I was interested in such a simple fact: if a rectangle of 2 × 3 cells is surrounded by cells on both sides, then the area of ​​the stroke will be the same as the area of ​​the rectangle: There are exactly as many blue squares as yellow ones. And then I suffered.

I wondered if there are still such configurations. That is, to make the rectangle circle with a contour on both sides, and the area of ​​the contour coincides with the area of ​​the rectangle. Of course and must be integer: It seems that such cases should no longer be. The area of ​​the blue part and yellow . It can be seen that if or unit, then there will be no matches, and if you increase them more then the blue will clearly grow faster. So this configuration is one.

Bored, said the brain. We must weaken the task. So to speak: But now the task is too weak. In fact, you need to select two rectangles with integer sides, so that their areas differ exactly by half. And the restriction on rectangles is only that one can be thrust into the other. There are too many of them, too boring. Let's do this: Fix the width of the border. How many are there? Hm. It looks more interesting. Yellow Square is , and we want her to equal just . That is, we (me and my brain, which dragged me into this) need to solve the equation: Or, the same thing: By this time, I had finished with my teeth and started pouring powder into the dishwasher. Yeah, the brain said, not a bad challenge. It is necessary to solve, of course, in integers, that is, this is the Diophantine equation . We did not go through the Diophantine equations at the university, but I remembered something about them from popular articles. Namely:

• If we have a homogeneous equation, then we are lucky.
• It is easy to turn a homogeneous equation on integers into an equation on rational ones, reducing the number of variables by one.
• If, using the method of peering, to find some root of the quadratic equation on rational numbers, then it is easy to find all the others.
• Any straight line with rational coefficients passing through a known root will go through another root. Twisting this line, you can get all the rational roots.

In this way, for example, the general formula for all the Pythagorean triples is easily found . By the way, as with the Pythagorean triples, in our problem any number of multiple solutions. For example, a rectangle can be expanded with a border in two small squares and so on. Of course, we are only interested in multiple solutions.

Will I be able to do all this in my mind, I thought, picking up a moisturizer. An algebra without a piece of paper and a computer is a rather insidious thing: mixed up a plus with a minus or forgot some member, and further calculations are in vain. Programmers know what to do to reduce the likelihood of an error - they need to be surrounded by unit tests. Fortunately, we already know one solution: . We will check it at every step. So far, so good. So, we have a homogeneous equation - all terms are included in the second degree. Divide the equation by (happening we are not interested, so you can share): Making a replacement: and we get an equation with two rational variables: In our unit test , the test passes. Now we need to draw a straight line. In principle, it can be drawn just through the point but it’s hard to keep in the brain. But by the method of peering, we can easily find another point that satisfies the equation: . This corresponds to zero area and again, as a solution, it’s not very interesting, but for a direct one just right. It’s quite simple to notice that all the lines (except one) passing through are described by an explicit equation (yes, for some reason the brain gave out the Greek letter, although the Latin ones did not end yet). One missing line is She is also not very interesting to us. Of course, any rational point where consistent rational . For example, for a point value . We substitute the equation of the line into our equation and get: Or Or Or It becomes difficult to bring members in the head, the brain desperately asks for a piece of paper. But I lull the baby in my arms, there’s no time for a piece of paper. Run the unit test ( ): Fuf, so far so good. Now we have a quadratic equation for which should actually give a rational root for any rational . How can this be, there is discriminant and all that? Okay, let's try: Oooh, good, how, a full square came out. Endorphin went to the brain. He, a freak addict, seems to have sought this. Here it is the magic of mathematics: a rational number should have come out and it came out. Recall the formulas for the roots: Or in our notation:   Is our reference point It’s not interesting for us. Our solution is . Substituting it in we get the answer: That is, you just need to sort out all the rational fractions as , and for them we get all rational solutions of the equation (well, except for some that are not very interesting to us).

Of course, it’s easier to sort through integers, not rational ones. Soldering a baby a simethicone preparation, I substitute and get:  (God, brain, why did you choose exactly and ? They are so easily confused in the head! Are there few letters?) In our unit test, if then fit and it’s easy to make sure the test passes.

How do we get back to integers? Remember that we replaced . So, we must take for any number that is a multiple of the common denominator from the formulas above. In particular, it just fits . As a result, we have: It can be seen that if and are not mutually simple, then the solution will be a multiple of their common divisor, so we are only interested in mutually simple and . A multiple solution is also obtained if will be even. In fact let . Then If you divide everything into two, we get This solution is symmetric to the first, which is quite logical: the problem is symmetric with respect to and . Thus, we are interested in mutually simple and , and odd.

Conveniently, the expression for it turned out so simple. So, we have a simple way to find all non-multiple solutions for a given edging width : these are such rectangles where any odd divisor mutually simple with . The next rectangle will be for : Both the blue and yellow parts contain exactly 30 cells!

Let's see what else there are solutions for small ( and I rearranged in some places to go in ascending order):

x n m square without fringing edged area
1 1 1 2 × 3 = 6 3 × 4 = 12
2 1 2 3 × 10 = 30 5 × 12 = 60
3 1 3 4 × 21 = 84 7 × 24 = 168
3 3 1 5 × 12 = 60 8 × 15 = 120
4 1 4 5 × 36 = 180 9 × 40 = 360
five 1 five 6 × 55 = 330 11 × 60 = 660
five five 1 7 × 30 = 210 12 × 35 = 420
6 1 6 7 × 78 = 546 13 × 84 = 1092
6 3 2 14 × 15 = 210 20 × 21 = 420

By counting these works in the head, the brain again achieved a dose of endorphin. How beautiful and wonderful divisors flow from one number to another! Take for example : the first is divided by 6, and the second is 11. We add a five to both numbers, and a miracle - now the first is divided by 11, and the second - by 6. And there are such tricks in each line! And here, and the son seemed to calm down. Eleven in the evening, you can go to bed.

Perhaps all this can be counted easier. Perhaps my reasoning was somewhere inaccurate. Perhaps these numbers and works have some special name. I do not know - did not look. I’m more interested in this: I’m the only nonsense to occupy my consciousness, or you too suffer are you enjoying Will they treat us?