My snake lemma


The title is a bait for algebraic topologists. Sorry for the bad joke!

Frequently I walk from my university to the nearby biggest population. In approximately 20 years I have seen only twice a snake and in both cases they were dead (to say the whole truth, recently I saw a baby snake alive but so small that it does not count).

Fortunately, this time I had my camera. The snake had passed away recently (no rigor mortis and I walked the same path few hours before). This is the photo in the original position:

snake1

After taking some pictures, I wondered if I could estimate the length of the snake. I moved the "tail" with a stick to make it visible. I noticed the absence of postmortem rigidity. The new position was:

snake2

I took a dry stick (yes, different from the previous one) and I cut it adjusting its length to the width occupied by the snake.

I brought the stick at home and measured it. The length was 56 cm. With the computer, I approximated on the photo the curve of the snake with a polygonal line picking with GIMP the coordinates of the vertexes. In the original image, larger than the one included here, the snake fitted in the band of pixels with first coordinate in [871,3760]. Hence the length of this interval in pixels corresponds to 56 cm. The previous photo completed with the line and the scale is:

snake3

With the data, I ran the sagemath code below to obtain my snake lemma: The estimated length is 109 cm. OK, it is not a green anaconda but I can promise that in my place it is very unusual to find snakes of this length near urban zones. In fact, it is difficult to see any snake.

I asked a biologist and, although he is not an expert, he told me that most probable the snake is this one and, against my impression, it is very common in Spain where it is called culebra bastarda. This link mentions that it appears even in populated areas.


Update: I saw the snake on April/04/2021. Approximately two month later, on May/21/2021. I saw an alive snake with the same aspect and apparently similar lenght. I could not take a picture because it quickly hid under some stones. This time the snake was in a remote part of the campus or rather on its boundary.




The code

This is the sage code that I employed to approximate the length. It also plots the polygonal line connecting the vertexes and save it in a file.


P = point([(871,-2600)], size=0)
P += arrow((871,-2551), (3760, -2551), width=4, arrowsize=9, color='red', head=2)

scale = 56/(3760-871)

snpoi = [
(886,2054),
(1142,2106),
(1306,2134),
(1466,2090),
(1604,1982),
(1988,1954),
################
(2090,1936),
(2522,2092),
(2780,2072),
(2920,1510),
(3090,1394),
(3208,1410),
################
(3320,1504),
(3398,1866),
(3484,1980),
(3598,1994),
(3666,1938),
(3682,1772),
################
(3622,1610),
(3384,1406),
(3094,1292),
(2810,1400),
(2366,1494),
(2238,1598)
]

leng = 0

for k in range( len(snpoi)-1 ):
  leng += norm( vector(snpoi[k+1]) - vector(snpoi[k]))
  
leng = scale*leng
print 'Estimated length in cm =',leng.n(digits=5)

snpoi = [(item[0],-item[1]) for item in snpoi]

P += line( snpoi, thickness=4)
P += points( snpoi, size=40)


P.set_aspect_ratio(1)
P.axes(False)
P.fontsize(25)
P.show()
P.save('polygonal.eps')