20201115

Love hate Python

There was Visual Basic 6 (VB6)... and then there was Python.  Both are interpreted languages (i.e. they run from a high-level script rather than being compiled into machine code). Both claim to be easy to program with and both have a huge following. Python is current whereas VB6 is no longer supported.  Python is free whereas Microsoft have made VB6 neither free nor available but say that it is superseded by VB.NET.  But these are very different languages. Having sharpened my teeth on plain BASIC (e.g. BASIC PLUS in college days, QuickBASIC running under MSDOS) I progressed to VB6 which I used extensively for creating test software to exercise electronics I have designed in the course of my work.

In case I ever have the privilege of helping homeschoolers here with teaching computer science, I figured I ought to learn a current language. I did a bit in C# a few years back for a work project and, whilst C# is a very powerful language (meaning you can do certain complex things with minimal coding), I found its syntactical gamut too much for my poor brain. So, what more suitable to up-and-coming programmers than Python, or so I have been told?

Many years ago I authored some QuickBASIC code that would display prime numbers in a square spiral.  The essential part took a mere 20 lines of script, and here's the output, limited to the VGA 640x480 screen resolution of the day with each integer represented by a single pixel. You can click on each image to zoom in.



The point of the program, apart from being an exercise in graphical output and being cool, is to highlight the mainly diagonal line patterns that prime numbers arranged in this way make. Anyway, this became my first Python challenge.

Here's the output of my Python code - a bit prettier because now each integer is represented by a 4 x 4 pixel square. Value 1 is plotted as a blue square, otherwise primes are red and non-primes grey. The essential part was almost 100 lines of code and took a long time to code. OK, so I am a novice but even so...  I tested it with three different algorithms for finding the primes - the fastest involved saving the primes in a Python list.


And here's the same in VB6.  It was so much easier to do the graphics part in VB6.  Python graphics is anything but intuitive and seems to employ the longest path to achieve the least credible results, whereas in VB6 you simply drag and drop graphic widgets and then click on them to open their respective code space. That they are event driven is taken for granted unlike Python.



Oh, and although no-one on ever claimed VB6 was fast, without pausing to do animated screen redraws I found my VB6 code ran about twice as fast as with Python.  I tried different prime algorithms but found the VB6 code ran fastest by dividing each integer numerator by all the denominators from 2 up to the square root of the numerator, which for large integers involves many more test divisions than did my Python code. That VB6 was still significantly faster says something in its favour.

And then, although Python is an interpreted language like VB6 or QuickBASIC, it has no native integrated development environment (IDE) so testing and debugging entails constant swapping between your chosen text editor (I used Notepad++) and the command line.  Although there are 3rd party IDE's and I am currently investigating Microsoft "Visual Studio Code" which, surprisingly, is free.

So do I love Python? Well, not yet, certainly! 


Face masks forever

It's not that I think face masks are totally ineffective in preventing the spread of Covid-19. But probably they are more of a statement of conformity and a reminder for others to "keep their distance" than having any real benefit. It's pretty clear that they do not stop all emanation of droplets from the wearer's nose or mouth but arguably they might direct airflow to the sides and thus away from... well that depends on where the objects of contamination are standing...

And then there is the argument that a mask will harbour nasties and thus exacerbate the problem. I've spoken to a qualified nurse involved on the front line and she pointed out that medics should replace their mask every 2 hours to mitigate this effect, thus clearly admitting this problem. Meanwhile the rest of us indefinitely re-use our single-use masks.

There is a considerable degree of absurdity about the whole issue of face masks.  There is also a deal of misunderstanding like a neighbour I noticed mowing her rear lawn whilst wearing a face mask. Or a cyclist passing me wearing a face mask. Presumably they mistakenly think it will protect them? But I reckon the following examples take the absurdity ticket.

I happened upon a Youtube video of Gustavo Dudamel conducting Mahler's Adagietto from Symphony No. 5. to an empty outside auditorium. All the musicians were not only socially distanced but also wearing face masks! In that video there were only strings and a harp but take a look at these pictures below that I grabbed from the internet. An apt comment on one web site was: How useless , ridiculous and humiliating for the poor musicians who are ready to accept these inhuman conditions in order to keep their job and continue their passion.



Note some but not all examples seek to cover all the exit holes as well as nose and mouth. You have to at least give these ones 10/10 for effort, even if there is little chance of any efficacy. 











20201114

Turkey Tail

We are in Willand again and I have been set the task of collecting Turkey Tail fungus (TT) which, I am told, has desirable medical properties and is plentiful. So I added this task to my existing tendency to go for runs, barefoot. Having visited the pop-up cafe in Bridwell Park to buy cake from their Covid-19 takeaway service and finding that at present they welcome folk to exercise in their private grounds (hoping it will increase sales of cake), I added this place to my run-list and discovered the seemingly one and only instance of Turkey Tail in the whole of this part of Devon. 


nicely rotted timber, but no TT

remains of Culm Valley light railway

rotten wood, fungus, but I think it's not TT

An ideal habitat, but could not find TT

Beautiful, dead, inaccessible, no TT

Ha! Some bracket fungus, but not TT

A stag in Bridwell Park

My former swimming place, note the noose

Noose from other side (how did I get there?)

Could this be TT?  Apparently not

or this?

wrong shape

might be, but we erred on side of caution

certainly not

Ha! At last! We harvested this

Strange pyramid in Bridwell Park

This monument was strange, ugly and out of keeping IMHO. My research yielded only one hit which claims that some 250m east of the house stands a pyramid composed of stalagmites, which incorporates a trefoiled piscina. I reckon the piscina (a shallow basin placed near the altar of a church) had been removed and there was no sign of a church nearby either. Mysterious.  The marquee in the background was part of the "pop-up cafe" before Covid-19 came along.


The lake at Bridwell

More TT


20201018

Please don't let me miss Autumn this year

 

Beech avenue, Manor Kilbride

Last year I apparently missed it. So even though it was overcast (contrary to the weather forecast) I ventured out with the intent of making it to the Sally Gap and the two Bray Loughs (far left in map below). Alas I ran out of time and was cold anyway so took my photos and hurried home. To lamb chops and apple pie (not together) courtesy of my beloved daughter (one of them).  Here's a link to more photos.

33 miles, elevation gain 720m



20201013

The end is nigh

 Moore's Law is the empirical observation that the number of transistors in a dense integrated circuit doubles about every two year and it has approximately held true since it was proposed in 1965.


It is driven by the economics of the insatiable demand for ever increasing electronics complexity and the steady reduction in feature size in the fabrication of silicon chips (integrated circuits).

In 2013 Robert Calwell vowed the end would come in 2022, maybe even 2020, with the herald of 7nm and even 5nm feature size.

And today the BBC has announced that Apple's new flagship iPhone 12 will incorporate the "A14" processor with 5nm feature size - the chip's transistors have been shrunk down - the tiny on-off switches are now only about 25 atoms wide - allowing billions more to be packed in.

These electronic chips use "solid state" technology, i.e. they have no moving parts which makes it sound like they can never wear out, will last forever short of physical damage. Alas, such is a dream. I am well used to using Flash and other types of non-volatile solid state memory (chips) in my work and I am all too aware that the specification documents mention a lifetime of sometimes as little as 100,000 re-write cycles. When software is running at GHz speeds this many can clock up quite fast!

Chips are made by first growing a very pure silicon crystal, slicing it into wafers, and then diffusing into it a photographic pattern of known amounts of certain impurities that give the silicon its required special electrical properties. Diffusion (the intermingling of substances by the natural random movement of their particles) is both the essential mechanism and Achilles' heel of solid state chips.

Back in college days I was told that the lifetime of a solid state circuit was limited by diffusion - what can be diffused in to make it work can, by the same token, diffuse out and self destroy it. OK, it is diffused in at high temperature where the particles are in much stronger random movement, so what may take seconds to diffuse in might take many years to diffuse out at room temperature. But the smaller the feature size, the more likely that diffusion defects can occur - the particles have less distance to move.

The aging problem is discussed in this paper - so I am not just imagining it!  Many people regard their cell-phone as a consumable item, with expectation that it be replaced after a year or so. Those people may have limitless bottoms to their purses but I, for one, am happy enough with my Pixel 2 and have no desire to shell out to upgrade it. So I'm hoping that all those billions of transistors inside will not diffuse into randomness too soon. All are of the dust, and all turn to dust again.


20201011

Sorrel Hill


My track 22.5 miles part cycle part hike

OpenTopo map

Sunday afternoon again, and mild at 12'C and the mountains were calling again. Or "hills" if you insist. The last time I climbed (hiked) up Sorrel Hill was many years ago and with my daughter S. It was one of those father-daughter times. Our route back then was different from mine today.

So I started by deciding to cycle around the Lake Drive, but stopped at Lacken to inspect the tourist map they have erected and which informed me that just a few yards to the left I would find access to the "MASSPATH", and so I did and, oh my - I have to apologise for maligning Ireland's lack of well maintained footpaths! This end in particular but the whole trail was well maintained. I could not resist such a temptation so I rested my bike against a handy post, removed shoes and helmet and set off. I met perhaps a dozen other people - I think Covid has encouraged folk to get outdoor exercise. There were the usual comments on my lack of shoes, but all very friendly.

If you look closely you might notice the hang-gliders, even a powered one, and a bi-plane













 

Elegance

Elegance - the beauty of an idea characterised by minimalism and intuitiveness while preserving exactness and precision.

Complex - not simple, easy or straightforward. A Complex system is one that has multiple paths to multiple answers.

So now I've learnt how to make Julia sets.  Using the same colour palette as for my Mandelbrots here are a couple of my home made images. Of course there are far better ones on the internet, but I'm pretty pleased that I have even got this far. 




The Julia and Mandelbrot sets are mathematically very similar, so my program can generate either. The maths is so very simple - elegant indeed. But the resulting fractal images are complex, anything but simple. And there's the rub - the conjunction, the juxtaposition, the synergy of elegance and complexity. We see it again and again - the human body for one - such complexity from relative simplicity of DNA. The 90 or so naturally occurring chemical elements that are each made up of so few elementary particles (the periodic table and all that) giving rise to such diversity of materials and, indeed, life. How such a vast assortment of vividly coloured flowers are created from dirt, water and sunlight. Water gushing over a precipice: any student can calculate its maximum rise in temperature as it falls, but how to predict its impact as you swim beneath its fall?. And of course the much maligned "butterfly effect".

For those interested but too idle to google for themselves, the Mandelbrot set is the set of points c on the complex plane (aka Argand diagram) for which the iteration formula is bounded (z does not fly off to infinity), starting with z = 0.  There is a Julia set for every point c in the Mandelbrot set and it is the set of points z on the complex plane for which the same iteration formula is bounded, starting with z = that point. It can be proved (so I am told) that if, during the iteration, the modulus of  z exceeds 2, then z is bound to be unbounded: we need iterate no further. For cases that never or are slow to reach that stage, the iteration ought to go on ad infinitum - in practice such a requirement is onerous, and instead one sets an arbitrary limit of the number of iterations, for example 500.


Here's two of my favourite Mandelbrot zooms:

A trip to infinity - 2 hours 

The deepest hard zoom at 100,000,000 iterations - zoom depth 10^2126

The guys who create such videos (God bless them) have access to better software than mine but even so take perhaps a month or more of computer time to do the job. Not for the faint hearted or those of us with other more pressing calls on our time!

My brain still has problems understanding how so much complexity is bound up in so simple an equation.

This, my interest in Mandelbrot et al, started when reading an article about deep learning. Deep learning is AI (artificial intelligence) on steroids. The mechanics is based on a neural network (i.e. that tries to mimic how the human brain works). Faced with a complex task, for example recognising a particular face in a picture of a crowd, rather than trying to figure out software code that analyses the face you "simply" show the deep-learning-thing (DLT) zillions of pictures of the face in question from many angles and in many circumstances and with varying expressions.  Then when faced with the picture to be analysed, the DLT does a sort of mathematical correlation with all the pictures it has been shown and comes up with a score, a likelihood of each face in the picture being the one. Etc. A very different way of approaching software and clearly akin to what goes on in the brain (for those of use lucky enough to have one). Deep learning is the in-thing at the moment.  If you are young and mentally supple enough to get a grasp of all this, I'd imagine that designing these DLT's is the way to go. Or if interested in investing your fortunes, investing in DLT's might prove profitable. 

Deeping learning, complex systems, AI, chaotic systems, fractals (e.g. the Koch snowflake which has infinite perimeter and yet a finite area.  Plenty here to keep me amused for many a let's-avoid-Covid evening.


20200930

More Mandels

 Reference my last post, the standard Mandelbrot iteration formula is


So I wondered - what if I play with this formula a bit?  So I found the following. 









Not so nice as the original flavour maybe... 

Googling shows I'm not alone 😧 for example see here.