Add to Google Reader or Homepage |
~ pjvenda / blog
$home . blog . photography

12 June 2008

Simple puzzles and engineers

Recently, I've stumbled upon a mind puzzle suggested on etd's blog. It seemed pretty simple, so I gave it a little thought...

Just for the sake of completeness, here is the puzzle:

One morning, exactly at sunrise, a Buddhist monk began to climb a tall mountain. A narrow path, no more than a foot or two wide, spiraled around the mountain to a glittering temple at the summit. The monk ascended at varying rates of speed, stopping many times along the way to rest and eat dried fruit he carried with him. He reached the temple shortly before sunset. After several days of fasting and meditation he began his journey back along the same path, starting at sunrise and again walking at variable speeds with many pauses along the way. His average speed descending was, of course, greater than his average climbing speed. Prove that there is a spot along the path that the monk will occupy on both trips at precisely the same time of day.
Here is my go at it:
  • Considering that the path is an ascending spiral [from bottom to top of the mountain], it is possible to graph its height vs length as an injective function. This means that any point of height is occupied by a spot in the path, representing a single determined distance point from one of the ends of the path;
  • The monk will have to go through every point of height (or distance) to reach the top. He won't jump. This also means that height or distance can also be graphed against time as an injective and continuous function. At a given point of time, the monk cannot occupy two different height or distance spots;
  • The following sketch is my representation of the monk's distance covered along the day (distance vs time). I've superposed the graphs for the climb and descent.
  • Knowing that both climb and descend started at the same time, no matter how crazy the curves are (representing rests and different instant speeds along different bits of the path) they *have* to meet somewhere because they are continuous. The meeting place of the lines represents a single spot where the monk was at exactly the same time on both journeys.

After having conceived this analytical solution to the problem, I've realised this other one:
  • Both journeys are made on different days. So an equivalent situation would be to have two monks at the same time starting their journeys in opposite directions - one climbing and the other descending. They will meet along the way.
And this was just a quick (but rare) peek inside the mind of an engineer.

Cheers, PJ.

01 June 2008

Gnuplot in action

For us, mere humans, it is so much easier to understand technical data if it is presented in some form of graphical form - instead of tables filled with numbers. Coloured bars are easier to compare than two numbers side by side. In the same way, an analog voltmeter can, more clearly, show an abnormal condition, where the needle pointer moves too far than what we're expecting. But I stray from the subject...

So I like statistics, and I like graphs, and I blog about it. And then I'm suggested [by the author] an upcoming book about gnuplot: "Gnuplot in action".

You see, 'gnuplot' is a wonderful tool that takes data and draws (or plots) graphs to some output format (like an X window or an image file).
It's an incredibly compact unix-style tool that takes a configuration script and a text table of data (usually numbers and column names) to plot the graph into an image of some kind. It offers thousands of options and configuration parameters to produce pretty much every graph you might imagine [and beyond]. From useless to essential, from the very simple to mind-bogling complicated and elaborate. All for the sake of a better representation of "raw" data.

set term png
set output "sin_x.png"
plot sin(x)

The trivial script above makes gnuplot plot the graph shown in the image below:

Graphical plot of sin(x).

This slightly more elaborate script seen in plots the almost art-work graph shown below:

Graphical plot of a transfer function. This is the result of a complex gnuplot script.

The truth is that although gnuplot is does a superb job, it carries a pretty steep learning curve. Most of it I've learnt from examples, which obviously isn't enough.

And here is where "gnuplot in action" comes in. It's a book that tackles the depths of gnuplot, from the simple and straightforward all the way up to the very edge of its capabilities - the scripts of the gnuplot gods. It is also filled with reference material and examples.
The subject is introduced progressively. It says somewhere that the first few chapters alone cover pretty much every basic function of the program. The remaining are the meat of the book, the extra mile that makes it interesting. It's a great read and a really nice way to explore gnuplot, graphs and statistics (for those that, like me, have the little bug of statistics inside them).

I reckon that pretty much every unix-head sysadmin must have thought about using gnuplot, or at least uses a couple tools that produce graphics with it.

The book isn't ready just yet, you'll have to wait a couple more weeks, but if you do any work that does or may involve gnuplot, go on and buy this book. It's bloddy brilliant.

Here is the link again:

Cheers, PJ.