Archive for March 2010
But to remember her my heart is sad, To see her is to know Bewildered thoughts, and touching driveth mad — How is she dear that worketh only woe? (P.E. More, 1899) The thought of her is saddening, The sight of her is fear, The touch of her is maddening— Can she be really dear? (Ryder, 1910)
These are both translations of Sanskrit poems, and quite obviously of the same one.1 The difference in style is not entirely due to the 10 years between them. :-)
Following the previous post, which egregiously violated “Show, don’t tell” — with a whole lot of telling and nothing to show for it — here are a couple more random examples of short verses that I feel are successful in translation. [As I started gathering examples, this post started turning into a tribute to Ryder, so I’ve cut that off for another time. What I like is obviously subjective, and I’m easily delighted by a simple rhyme. :-) Of course, most good poems can be translated into prose or free verse and still remain beautiful; the below are merely examples of translations being cleverly coerced into the verse forms of English.] I avoided commentary on the poems — for attempting it would be futile — and only touch on the translation.
This is from Amaru:
SHE ONLY LOOKED She did not redden nor deny My entrance to her room; She did not speak an angry word; She did not fret and fume; She did not frown upon poor me, Her lover now as then; She only looked at me the way She looks at other men.
The core of the poem, its sting, is in the last two lines, and it may owe more to the inherent rhythms of the English language than to the skill of the translator that the natural way of expression fits so neatly into metre, but few other translators would have exploited it so well.
Also from Amaru:
WHEN MY LOVE DRAWS NIGH When my love draws nigh, When his voice I hear, Why am I all eye? Why am I all ear?
How simple! As is the next one:
SIMPLE JUSTICE If, maiden of the lotus eye, Your anger hurts you so, 'Tis right you should not let it die, You hardly could, you know. But once I gave you an embrace, To keep it would be pain; And once I kissed your willing face, Give me that kiss again.
Translating Sanskrit poetry into English presents unique difficulties. To be sure, translation is always tricky. Passing to a different language invariably loses some nuances and overtones. What can be naturally expressed in one language may require more effort in another.
With Sanskrit, though, even essential features are often untranslatable to a native English audience.
[Disclaimer: Before going further, I must point out that I am an amateur. Everything below is probably wrong, they are banal and pointless observations, anyway, and I amaze myself by my ability to take something interesting and make it boring. I thought I had something to say, but it took writing it out to realise I didn't.]
Procrastinators seldom do absolutely nothing; they do marginally useful things, like gardening or sharpening pencils or making a diagram of how they will reorganize their files when they get around to it. Why does the procrastinator do these things? Because they are a way of not doing something more important. If all the procrastinator had left to do was to sharpen some pencils, no force on earth could get him do it.
— John Perry, in his brilliant essay Structured Procrastination
Am I the only one who finds the last sentence above not a joke at all? Who has tried for months to send a single email?
(Prof. Perry’s short humorous essay is a true classic of our times, and one I have found much insight from. The trick of being able to do X simply by thinking of a more important Y has helped me many times, whenever I have remembered to apply it, and the essay helps one avoid the wrong tack of minimising commitments. Still, sometimes, there are things X to be done for which no more important Y comes to mind, and it is not clear what to do in that case.)
The “standard” way to plot data used to be gnuplot, but it’s time to start using matplotlib which looks better and easier to use. For one thing, it’s a Python library, and you have the full power of a programming language available when you’re plotting, and a full-featured plotting library available when you’re programming, which is very convenient: I no longer find it necessary to use a horrible combination of gnuplot, programs, and shell scripts. For another, it’s free software, unlike gnuplot which is (unrelated to GNU and) distributed under a (slightly) restrictive license. Also, the plots look great. (Plus, I’m told that matplotlib will be familiar to MATLAB users, but as an assiduous non-user of MATLAB, I can’t comment on that.)
matplotlib is simple to start using, but its documentation makes this fact far from clear. The documentation is fine if you’re already an expert and want to draw dolphins swimming in glass bubbles, but it’s barely useful to a complete beginner. So what follows is a short tutorial. After this, you (that is, I) should be able to look at the gallery and get useful information, and perhaps even the documentation will make a bit of sense. (If matplotlib isn’t already present on your system, the easiest way to install it, if you have enough bandwidth and disk space to download a couple of gigabytes and you’re associated with an academic installation, is to get the Enthought Python distribution. Otherwise, sudo easy_install matplotlib should do it.)
The most common thing you want to do is plot a bunch of (x,y) values:
import matplotlib.pyplot as plot xs = [2, 3, 5, 7, 11] ys = [4, 9, 5, 9, 1] plot.plot(xs, ys) plot.savefig("squaremod10.png")
import matplotlib.pyplot as plot import math xs = [0.01*x for x in range(1000)] #That's 0 to 10 in steps of 0.01 ys = [math.sin(x) for x in xs] plot.plot(xs, ys) plot.savefig("sin.png")
That is all. And you have a nice-looking sine curve:
If you want to plot two curves, you do it the natural way:
import matplotlib.pyplot as plot import math xs = [0.01*x for x in range(1000)] ys = [math.sin(x) for x in xs] zs = [math.cos(x) for x in xs] plot.plot(xs, ys) plot.plot(xs, zs) plot.savefig("sin-2.png")
Perhaps you don’t find it so nice-looking. Maybe you want the y-axis to have the same scale as the x-axis. Maybe you want to label the x and y axes. Maybe you want to title the plot. (“The curves sin x and cos x”?) Maybe you want the sine curve to be red for some reason, and the cosine curve to be dotted. And have a legend for which curve is which. All these can be done. In that order —
import matplotlib.pyplot as plot import math xs = [0.01*x for x in range(1000)] ys = [math.sin(x) for x in xs] zs = [math.cos(x) for x in xs] plot.axis('equal') plot.xlabel('$x$') plot.ylabel('$y$') plot.title(r'The curves $\sin x$ and $\cos x$') plot.plot(xs, ys, label=r'$\sin$', color='red') plot.plot(xs, zs, ':', label=r'$\cos$') plot.legend(loc='upper right') plot.savefig("sin-cos-two.png")
Observe that we specified the plot style as “:”, for dotted. We can also use ‘o’ for circles, ‘^’ for triangles, and so on. We can also prefix a colour, e.g. ‘bo’ for blue circles, ‘rx’ for red crosses and so on (the default is ‘b-‘, as we saw above). See the documentation for plot.
Also, Matplotlib has some TeX support. :-) It parses a subset of TeX syntax (be sure to use r before the string, so that you don’t have to escape backslashes), and you can also use
to make it actually use (La)TeX to generate text.
My only major annoyance with the default settings is that the y-axis label is vertical, so one has to tilt one’s head to read it. This is easy to fix:
You can also place text at a certain position, or turn a grid on:
plot.text(math.pi/2, 1, 'top')
You can also annotate text with arrows.
Instead of saving the figure, you can use
and get an interactive window in which you can zoom and so on, but I find it more convenient to just save to image.
You can customize defaults in the matplotlibrc file — fonts, line widths, colours, resolution…
Other plots: Matplotlib can also do histographs, erorr bars, scatter plots, log plots, polarplots, bar charts and yes, pie charts, but these don’t seem to be well-documented.
Animation: Don’t know yet, but it seems that if you want to make a “movie”, the recommended way is to save a bunch of png images and use mencoder/ImageMagick on them.
Edit: If you have a file which is just several lines of (x,y) values in two columns (e.g. one you may have been using as input to gnuplot), this function may help:
def x_and_y(filename): xs = ; ys =  for l in open(filename).readlines(): x, y = [int(s) for s in l.split()] xs.append(x) ys.append(y) return xs, ys
Edit [2010-05-10]: To plot values indexed by dates, use the following.
fig = plot.figure(figsize=(80,10)) plot.plot_date(dates, values, '-', marker='.', label='something') fig.autofmt_xdate()
The first line is because I don’t know how else to set the figure size. The last is so that the dates are rotated and made sparser, so as to not overlap.
More generally, Matplotlib seems to have a model of figures inside plots and axes inside them and so on; it would be good to understand this model.
Edit [2013-03-15]: Found another good-looking tutorial here: http://www.loria.fr/~rougier/teaching/matplotlib/.
[2013-04-08: Comments closed because this post was getting a lot of spam; sorry.]
In 1874, less than 4% of clerical workers in the United States were women; by 1900, the number had increased to approximately 75%.
— from today’s featured article on Wikipedia, to which my only contribution was cheering a bit when it was being written.
It can be argued whether C. Latham Sholes, the inventor of the (first successful) typewriter, was the saviour of women, but there can be no doubt that the typewriter was one of the most major factors in changing their role.
Of course, there were ugly side-effects. The entry of women was resented, and there were endless cartoons insinuating that these secretaries were cheating with their employers whose wives were at home. This was compounded by the manufacturers’ own marketing, which (as has always been the case) consisted of women in provocative pictures. The book Sexy Legs and Typewriters collects some “non-pornographic vintage erotic images” from the period.
And only a couple of decades later, when Ottmar Mergenthaler, “the second Gutenberg”, invented the linotype machine and changed typesetting forever, the printers were prepared, and banded together to prevent women from “taking their jobs”. They even succeeded, for a while.
For a brief while, when you bought a typewriter, a woman came with it.
Barbara Blackburn’s record, for being the fastest typist in the world, was using the Dvorak keyboard. Obviously. :-)
Is there nothing Euler wasn’t involved in?!
That rhetorical question is independent of the following two, which are exceedingly weak connections.
“Connections” to piracy: Very tenuous connections, of course, but briefly, summarising from the article:
- Maupertuis: President of the Berlin Academy for much of the time Euler was there. His father got a license from the French king to attack English ships, made a fortune, and retired. Maupertuis is known for formulating the Principle of Least Action (but maybe it was Euler), and best known for taking measurements showing the Earth bulges at the equator as Newton had predicted, thus “The Man Who Flattened the Earth”.
- Henry Watson: English privateer living in India, lost a fortune to the scheming British East India Company. Wanted to be a pirate, but wasn’t actually one. Known for: translated Euler’s Théorie complette [E426] from its original French: A complete theory of the construction and properties of vessels: with practical conclusions for the management of ships, made easy to navigators. (Yes, Euler wrote that.)
- Kenelm Digby: Not connected to Euler actually, just the recipient of a letter by Fermat in which a problem that was later solved by Euler was discussed. Distinguished alchemist, one of the founders of the Royal Society, did some pirating (once) and was knighted for it.
- Another guy, nevermind.
Moral: The fundamental interconnectedness of all things. Or, connections don’t mean a thing.
The discovery of America: Columbus never set foot on the mainland of America, and died thinking he had found a shorter route to India and China, not whole new continents that were in the way. The question remained whether these new lands were part of Asia (thus, “Very Far East”) or not. The czar of Russia (centuries later) sent Bering to determine the bounds of Russia, and the Bering Strait separating the two continents was discovered and reported back: America was not part of Russia. At about this time, there were riots in Russia, there was nobody to make the announcement, and “Making the announcement fell to Leonhard Euler, still the preeminent member of the St. Petersburg Academy, and really the only member who was still taking his responsibilities seriously.” As the man in charge of drawing the geography of Russia, Euler knew a little, and wrote a letter to Wetstein, member of the Royal Society in London. So it was only through Euler that the world knew that the America that was discovered was new. This letter [E107], with others, is about the only work of Euler in English. That Euler knew English (surprisingly!) is otherwise evident from the fact that he translated and “annotated” a book on ballistics by the Englishman Benjamin Robins. The original was 150 pages long; with Euler’s comments added, it was 720. [E77, translated back into English as New principles of gunnery.]
Most or all of the above is from Ed Sandifer’s monthly column How Euler Did It.
The works of Leonhard Euler online has pages for all 866 of his works; 132 of them are available in English, including the translations from the Latin posted by graduate student Jordan Bell on the arXiv. They are very readable.
This includes his Letters to a German Princess on various topics in physics and philosophy [E343,E344,E417], which were bestsellers when reprinted as science books for a general audience. It includes his textbook, Elements of Algebra [E387,E388]. Find others on Google Books. The translations do not seem to include (among his other books) his classic textbook Introductio in analysin infinitorum [E101,E102, "the foremost textbook of modern times"], though there are French and German translations available.
Apparently, Euler’s Latin is (relatively) not too hard to follow.