Math behind “Rope around the globe”

Some people will know the mathematical problem:

Take a rope and tie it around a tennis ball very tightly. Cut the rope and add an extra meter of length. If you lay the rope around the tennis ball in a circle again, you will get a distance of 16 cm between the rope and the ball.

Now consider the same for the earth. Assuming a perfect globe with an equator of 40 000 km and an additional meter for the rope: What will the distance between earth and the rope be?

Tennis ball (3.35 cm radius):

U1 = 2 × 0.0335 × π
U2 = U1 + 1
r2 = U2 / 2π
r2 = ~0.19265 m
r2 – r1 = 0.19265 – 0.0335 = +0.15915m

Globe (40 000 m radius):

U1 = 2 × 40000 × π
U2 = U1 + 1
r2 = U2 / 2π
r2 = ~40000.1591 m
r2 – r1 = 40000.1591 – 40000 = +0.15915m

Conclusion

The distance is always about 16cm for an additional meter. This comes from the formula r = U / 2π. You can separate the constant from the variables: r2 = U1 / 2π + 1 / 2π. So the 16cm is actually parameter / 2π.

My PHP Rant

Writing a lot of PHP source code in the last years, I got more and more annoyed by PHP recently. I assumed it would be a good idea to sum up my thoughts and collect all the stuff that annoyed me while writing source code. I ended up writing an article about PHP called Why I dislike PHP and introduced the snippets section at my website.

Whoever is too lazy to read the whole article, just check out the linked code snippets. It might give you a feeling about my rationale. I’m happy for some feedback whoever has some experience with PHP.

Fun fact: I thought some of the examples—like list() in foreach—were pretty weird ideas by myself. But after writing the article and searching for discussions about PHP, I found discussions about these aspects by core developers.

Associated with this document, I have to announce that I want to discard most PHP projects I am currently working on. I am looking forward to developing with python in the web and I think this might work out (I might be interested in ruby on rails and node.js too; some day). As far as projects are concerned I am the only developer, I will mostly try to get the remaining source code running stable and reliable, but I am looking for a future without PHP.

Ich wäre gern ein Löwe…

“Ich wäre gern ein Löwe! Bumsen, Fressen, Geile Frisur”

:-D

via Roman, thx

Python wants to become one-based?

Yesterday (or today in my timezone) Guido wrote a reply, which indicated that he wants python to become one-based. I have written recently about my WTF-situation when I realized that SQL is one-based (and also Lua which comes up in the python’s mailing list discussion). Personally speaking I think that python is that damn intuitive because it’s based on mathematical principles (which Guido as mathematician is aware of). But math is not that consistent and beautiful that it solves all problems.

A sequence of numbers is a range of numbers from x to y with x included but y excluded. To get all indizes of a list, you can use range(0, len(seq)). This is damn readable and does not include a nasty -1 like in most other languages. Well… life is not that beautiful. If we change to a one-based numbering system, what will happen? range(1, len(seq)+1)? Seriously? Lua does not exclude y and therefore does not have a nasty +1.

Lists start with 0, because 0 is the firstzeroth number. In a decimal system, the firstzeroth number with two digits is 10. Three digits: 100. The least-significant number is always zero. The firstzeroth number with one digit is 1? This only comes from an exception in mathematics (102..0).

If I want to have all numbers in a list at 2*n indizes in python I will use …

>>> a = [1, 2, 3, 4, 5, 6, 7, 8, 9, 0]
>>> [a[2 * index] for index in xrange(0, len(a) / 2)]
[1, 3, 5, 7, 9]

Again: No nasty +1. Just like Wikipedia points out, it’s about congruence.

I understand that in certain situations it can be useful. If you want to get all numbers at 2n indizes, you probably want to have the mathematical base0=1 and you would be fine with one-based systems. You probably want to get the real firstzeroth number:

>>> import math
>>> a = [0, 1, 1, 2, 3, 5, 8, 13, 21, 34]
>>> [a[2 ** index - 1] for index in xrange(0, int(math.log(len(a), 2)) + 1)]
[0, 1, 2, 13]

For Lua it just says:

a = {0, 1, 1, 2, 3, 5, 8, 13, 21, 34}
for index=1,math.log(#a+1, 2)+1 do
  print(a[2 ^ index])
end

I have shown only mathematical examples, but science is want I consider to be one of the most important fields for python. Other (especially old-school) languages really suck at this and it’s one of python’s strengths to be fine with scientists from other fields. In a mathematical context one-based systems it might be okay (see MATLAB), but for me a list starting with 1 is unpythonic and not useful. Yes, just like the Lua community I can live with a one-based languages, but I generally consider it to be a design fault.

Thanks to Bruce Leban for this awesome funny reply.

Update: Guido, you got me. It was a joke ;-)

How not to argue

Am 02.04.11, schrieb zensierter Name:

Ist aber extrem gefährliches Halbwissen das den Studierenden als richtig suggeriert wird, jedoch grundlegend falsch ist….. und damit hier eigentlich nichts verloren hat.

Danke, aber die Entscheidungen, was “hier” etwas verloren hat oder nicht treffen wir gerne selbst. Da es sich um eine *einführende* Lehrveranstaltung handelt (die für Anfänger aufgrund des Themas ohnehin schon mehr als komplex ist) ist hier eine sehr “naive” und grundlegende Herangehensweise durchaus angebracht, wobei auch hier in keinster Weise behauptet wurde, dass dies die “richtige” sei, sondern dass sie innerhalb unseres Gesamtkonzeptes akzeptabel ist.

via tu-graz Newsgroup

20 times around the Wörthersee

ToDo List summer11 Item #1: 20 times biking around the Wörthersee ☑. Last Friday was my last ride and I finished my first ToDo Item :-) Spontaneous pics following:

The distance is about 54 km from my home place. It’s about 45 kilometers around the lake. My approximate average speed was between 18 and 21 kmh-1; well, most of the time I was tired after work. 20 times means twice a week. In the middle, I incremented the number to 3 to end earlier and have some space for other projects. 2/3 times I rode my bike in the rain.

One time I saw a free rabbit in the lawn. I have also met some strange chicken next to road 2 times.

I checked out 5 ice cream shops next to the roads, I was riding along. 2 are expensive. One of those did not manage to give me the correct flavor (banana and vanilla have similar, but not equal colors) and it did not taste very good. I have to admit that “Aqua” in Velden had the most delicious cream (not watery and not viscous), the best cone and the price was average (2€ for 2 scoops of ice cream). Actually it’s the ice cream shop where a old school mate served me some ice cream 3 times. Recommendation. ;-)

And again: please stop telling me that driving in the dark or in the rain cannot be beautiful.

Gastronomy #fail

A pizza delivery man is handing me in some “Pizza San Daniele” instead of the requested “Pizza Primavera”. He excuses himself by telling me, that I did not have to pay the price of the first pizza (which is a few cents more expensive). Well… but I am vegetarian?!

A ice cream boy handed me in banana instead of vanilla. Well… almost the same color.

In the bakery I was asking for some Poppy Seed Snail (Mohnschnecke [DE]). They gave me some Snail with nuts (Nussschnecke [DE]).

What’s up with the gastronomy industry? :-(

When MySQL substr does not work

So let’s start with a simple MySQL setup:

mysql> CREATE TABLE example (prefix VARCHAR(50),
domain VARCHAR(30), PRIMARY KEY(prefix, domain));
Query OK, 0 rows affected (0.02 sec)

mysql> INSERT INTO example VALUES
("hello", "world.org"), ("foo", "bar"),  ("Foot","ball");
Query OK, 3 rows affected (0.00 sec)
Records: 3  Duplicates: 0  Warnings: 0

Alright… so we have some sort of “split up” email addresses. It’s not a problem to combine them together on the fly as far as MySQL provides basic string operations.

mysql> SELECT CONCAT(prefix, "@", domain) as email_addr FROM example;
+-----------------+
| email_addr      |
+-----------------+
| foo@bar         |
| Foot@ball       |
| hello@world.org |
+-----------------+
3 rows in set (0.00 sec)

So now let’s say, we want to remove the Top Level Domain from the domain (“world” instead of “world.org”) [1].

mysql> SELECT SUBSTR(domain, 0, LOCATE('.', domain)-1) as tld FROM example;
+-----+
| tld |
+-----+
|     |
|     |
|     |
+-----+
3 rows in set (0.00 sec)

What? Let’s slow down… take a substring of domain starting at position zero and with length of the position of the “.” (dot character) minus 1 (before that dot character). Okay… so something has to be wrong about it.

mysql> SELECT domain as tld FROM example;
+-----------+
| tld       |
+-----------+
| bar       |
| ball      |
| world.org |
+-----------+
3 rows in set (0.00 sec)

A quarter of an hour later I realized the problem with the help of a colleague:

mysql> SELECT SUBSTR(domain, 1, LOCATE('.', domain)-1) as tld FROM example;
+-------+
| tld   |
+-------+
|       |
|       |
| world |
+-------+
3 rows in set (0.00 sec)

SQL (and therefore the substr function) is one-based. So to address the first character you have to specify it using “1″. MySQL uses 0 to tell “no match”.

Stupid world. Why do we have conventions? To break them? I was aware that MATLAB sucks in this regard too, but I was shocked, when I heard about Lua (both languages one-based).

Note [1]. If you really have such an usecase, please refer to SUBSTRING_INDEX.

Hochstuhl Klettersteig Bewanderung

Heute habe ich einmal den Hochstuhl bestiegen. Ich hatte erstmalig ein Geschirr beim Klettersteig ausprobiert (an manchen unguten Stellen kann eine Sicherung sehr vorteilhaft sein ;-) ). Der Aufstieg über den Klettersteig war das schönste. Am Gipfel war es höllisch stürmisch und der Abstieg dauerte verdammt lang. Am Ende konnte ich aber keine ausgeprägten Blasen an den Füßen bemerken. Anbei finden sich die Photos:

Hochstuhl Besteigung Kar beim Zustieg Blickrichtung Gipfel

Hochstuhl Abstieg mit sehr unangenehme Untergrund

Hochstuhl Abstieg Blickrichtung Gipfel

Hochstuhl Abstieg

Plötzlich grünes Gras beim Hochstuhl Abstieg

A bad example of university work

Just a small rant about bad work at university.

In this course all materials we had to learn was transcribed in the slides itself. Learning got really annoying. Sometimes we did not even know what the author intended to express with some word as far as it is used in a different context in difference to eg. Wikipedia. Yes, I attended all (except one) lectures and yes, I did not recognize that this word on the slide will raise some question in future times. However, the thing I am most annoyed at: The only thing the professors have to care about are the slides and they still suck. In conclusion, there were 10 lectures with 617 slides. Following is a list of errors excluding errors with capitalization and “BE vs AE”:

  • “the ability of employees to use their knoweldge for actions”
  • “Fore each Knowledge Area:”
  • “How much of this in Internet?”
  • “Needs of the Information Scociety”
  • “Effect of data errors? sensitiv / insensitiv”
  • “Knowledge spaces represent common characteristis of a set…”
  • “Models based on Set Theory: Boolian Retrieval”
  • “Formulation of a the need for information”
  • “struktur, layout, content”
  • “Imput with a microphone”
  • “Intuitiv & easy to understand”
  • “Transitivity? Assymetrie?”
  • “… better enbaling computers and people to work in cooperations”
  • “Publikation of data together with underlying structures”
  • “Bottom-up approch”
  • “What are the differences Tags and Semantic Annotations?”
  • “Semantic Web für Social Software”
  • “How do organizational sturctures fit together?”
  • “Properties/Capabilities of particular von learners and goals.”
  • “Learning methods to achieve the goald”
  • “Core of adaptiven systems”
  • “implicit wiht log-data only”
  • “about the design of adaptiven learning systems”
  • “Work-integrated larning is part of knowledge management”
  • “Web-bases learning environments”
  • “administration of examiniation tools”
  • “Is learning itself really in the forground?”
  • “Resource that can be used”
  • “Spectrum of properties (e.g. file formats, color sprectrum)”
  • “requires access to a wider range of ongoing activitiey”

</rant> Sorry.