# Diophantine problems for garden gnomes

Suppose you are asked to solve the equation

There are two unknowns and only one equation, so you’ll get infinitely many solutions. Rearranging, you get

so you know what shape these solutions take.

"How many bricks do I need?"

But now suppose you're asked to find a particular solution such that both and are positive whole numbers and their sum is as small as possible. You could use trial and error to find the solution (if it exists), but this is mathematics, and in mathematics we like a bit of method and order. Fortunately, one method for integer solutions came out of Alexandria in about 250 AD. But, before we get into that, let's add a little context to make things more interesting.

Mr and Mrs Magnus are a happy gnome couple. Unfortunately, foreseeing that they will be unable to keep up with their rising mortgage repayments, they've been forced to move into my back garden (where salaries are much higher). However, they have been presented with some trouble in building their new home. Gnome by-laws state that the total number of bricks used in any construction project must be 177 or planning permission will not be granted.

As gnome houses form roughly the shape of a triangular prism and one wall (namely the garden fence) is already in place, only two walls need to be built. The plot of land they have acquired is shown below with all dimensions measured in bricks.

The question is, what is the smallest number of bricks they have to buy to comply with the local council, yet not waste any money?

Luckily, Mr and Mrs Magnus’ son, Zurich, knows a thing or two about numbers. As his parents discuss their dilemma over tea, Zurich writes out an equation:

where and are the height in bricks of the two respective walls. Chuffed with himself, he shows his parents and receives a solemn "that’s nice dear".

Duly encouraged, Zurich sits and thinks about how to solve this equation. The secret here is that you cannot have half a brick: and must be integers. (This, by the way, rules out that the two walls have the same height, ie that , because

gives that , which isn’t a whole number.)

Now, Zurich has recently been reading Euclid’s Elements before he goes to bed and so has just found out about a nifty trick called Euclid’s algorithm, which finds the highest common factor of two numbers, and . We assume . First divide by and take the remainder, calling it . Then divide by , and take the remainder, calling it . Keep repeating this process and eventually you get a remainder of zero. The last non-zero remainder is the highest common factor of the original two numbers.

So, Zurich lets and from our previous equation. He then performs the algorithm with some zest. At each step, he keeps track of the calculation by writing Here is the number that's being divided at that step, is the number it's being divided by and is the corresponding remainder:

This tells him that the highest common factor is 1 (if he goes any further he will reach zero). Fortunately this is what we would expect, as 11 is a prime number. Now he uses the equations that he has just generated to write out a true statement equal to 1 that involves 25 and 11.

He keeps 25 and 11 as separate factors, so:

Collecting terms:

Let’s compare that to the original:

So, Zurich rewrites his sum as:

Now, that’s all very well and good, but it needs to equal 177 not 1, so still treating 25 and 11 as terms, he multiplies the whole equation by 177:

Some quick multiplication leaves him with:

This is a perfectly legitimate answer, but sadly it is very difficult to come by negative bricks these days, and it certainly doesn't look like the smallest answer. So, Zurich ponders how to make positive without changing the sum of the equation from 177. To make the coefficient of 11 positive, he needs to add some multiple of 11, say , to the left hand side of the equation. To keep the equation true, he needs to take this multiple away again:

To get the equation into the required form, he writes Since must be a whole number, he nows that must be a multiple of . Say for some . This gives So now Zurich only needs to find a number so that is greater than zero but as small as possible. Dividing 1593 by 25 using long division he gets:

Therefore, the number he is looking for is , giving

Zurich compares this to the original problem and finds that the solution is and The problem is solved just as his parents finish their tea.

### Diophantine equations

Generally, equations of the form

where the variables and are only allowed to be whole numbers are called linear Diophantine equations after the great Greek arithmetician Diophantus, who dealt with many such problems in his works.

If is a multiple of the greatest common divisor of and , then an equation of this form has an infinite number of solutions. This is the case in our example equation, where , and , with the greatest common divisor of and being 1. The further constraint that the solutions must be positive and their sum as small as possible then gave us the particular result. If isn’t a multiple of the highest common factor of and , then the equation has no integer solutions at all.

There are also diophantine equations of higher degree, for example

where , and are the variables and is a constant. The statement that no integer solutions exists when is Fermat’s famous last theorem, which remained unproved for over 400 years.

(It was in the margin of his copy of Diophantus' book Arithmetica that Fermat wrote his renowned lines. See the Plus article Fermat's last theorem and Andrew Wiles for more information.)

In terms of practical applications, being able to solve this sort of problem is surprisingly useful even in the modern world. The classic example is working out how many men, women and children attended a show given only the price of each ticket and the final takings. Plus, if you are that way inclined, certain types of puzzles in magazines and newspapers can suddenly become a whole lot simpler with this under your belt. From business to coffee breaks, exploring number theory to building your house, it's definitely a technique worth knowing!

P.S. In his excitement, Zurich forgot to make an allowance for the front door in one of the walls. Luckily, his skilled father was able to make a chimney out of the extra bricks at the same time as close the gap that must be created where the two walls and the roof join.

### About the author

Emily Woodhouse is in her final year at Devonport High School for Girls in Plymouth. Her favourite day at school is triple maths, double chemistry and she thinks anyone who doesn't like numbers is absolutely mad. Most likely to be found in the depths of Dartmoor, hiking and discussing numbers with its resident gnomes are among her favourite pastimes. Unsurprisingly, she is applying to read mathematics at university. One of her aims in life is to be called a mathematician.