**From New Scientist #2173, 13th February 1999** [link]

Pussicato, the great artist, is starting his new commission. The canvas is a horizontal line, 6 metres long, and he has to paint parts of it red according to a rule he has been given. He selects a point *P* on the line and measures its distance, *x* metres from the left hand end.

He then works out the number:

1/(x – 1) + 2/(x – 2) + 3/(x – 3) + 4/(x – 4)

If the number is 5 or more then he paints the point *P* red, otherwise he leaves it unpainted.

For example when *x* = 2.1 he gets the number 15.47… , which is more than 5, and so he paints *P* red. And when *x* = 1.7 he gets –9.28…, which is less than 5, and so he leaves *P* unpainted.

Pussicato repeats this for every point of the line, except those with *x* = 1, 2, 3 or 4, which he has been told to leave unpainted.

When he has finished he finds that four parts of the line are painted red and their total length is a while number of metres. (Pussicato could have worked all that out without doing the painting).

What is the total length of the red parts?

[enigma1017]

### Like this:

Like Loading...

If we consider the function:

One way to solve this problem is to divide the line into segments, and then colour each segment according to the value of

f(x)at some point in the segment.In this Python program we divide the line into 1 million segments, and give an answer to the nearest millimetre. It runs in 413ms.

Run:[ @repl.it ]Solution:The total length of the red parts is 2 metres.The program finds that 333,333 of the 1,000,000 segments are coloured red, which is almost exactly a third.

We can divide the line into segments of length 1 micrometre, and consider 6 million segments, and we would expect exactly 2 million of them to be coloured red. This takes a little longer (1.2s), but gives us the answer we expect:

To get a faster numerical solution we can consider the graph of

f(x).The function is undefined at x = 1, 2, 3, 4. So we consider the segments (0, 1), (1, 2), (2, 3), (3, 4), (4, 6), where the function is defined.

In the (0, 1) segment all the fractions are negative, and as

xapproaches 1, thenf(x)approaches –∞, so in this segment the value of the function is always less than 5. So this segment contributes no red to the finished work.In the (1, 2) segment, when

xis only a tiny bit larger than 1, then the first fraction give a large positive value, and the remaining fractions contribute much smaller negative values. So the function starts at +∞ atx = 1and asxapproaches 2 the function approaches –∞. Somewhere in the middle of the segment the function will have the value 5. We call this value(1 + x1), and in the interval(1, 1 + x1]the function will have a value greater than or equal to 5. So this segment will contribute a length orx1of red to the finished work.Similarly in the (2, 3) segment, the function goes from +∞ to –∞, and so takes on the value 5, at

(2 + x2). So this contributes a value ofx2to the finished work.Likewise, in the segment (3, 4) will contribute

x3to the finished work.In the segment (4, 6), the function starts at +∞, and as

xincreases the fractions will get smaller and smaller, so the value of the function would eventually approach 0. If it reaches the value of 5 in the segment (4, 6) thenx4will be less than 2, if not the entire segment will contribute red to the finished work andx4will be 2.So if we find when the function takes on the value 5 in the appropriate segments we can find the total length of red in the finished work.

The graph actually looks like this: (

f(x)in blue, the areas wheref(x) ≥ 5indicated in red)We can use the following program to calculate the total length of the red segments. It uses the [[

find_value()]] function from theenigma.pylibrary and runs in 74ms.The four places where the function have has a value of 5 are: (to 6 dp)

These are the roots of the equation:

which are also the roots of:

Wolfram Alphacan work out the exact values of these: [ link ].The graph shows that the red parts of the line are each between a pole and the next root of the polynomial. Their total length is hence sum(roots) – (1 + 2 + 3 + 4) = sum(roots) – 10. And since the sum of the roots is the inverse of the coefficient of x^3 in its expansion, we immediately obtain the total length of the red parts as 2 metres..

@Brian: That’s neat. I wondered if there was a simpler way to arrive at the answer. The exact form of the roots found by

Wolfram Alphais not pretty.I hadn’t come across the result for the sum and product of polynomial roots before. Namely:

Here’s a Python program using this approach Brian describes above (and the [[

Polynomial()]] class fromenigma.py) to provide an exact answer:I remember the the ‘sum of roots of a polynomial’ from my maths A levels some 60+ years ago!

Here is a version of this puzzle that uses matplotlib and sympy with Python to produce the graph and the solution.