<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:georss='http://www.georss.org/georss' xmlns:gd='http://schemas.google.com/g/2005' xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-4470666517647633822</id><updated>2012-01-27T17:20:58.407Z</updated><category term='hevea'/><category term='templates'/><category term='visual basic'/><category term='surfing'/><category term='movies'/><category term='cabernet sauvignon'/><category term='books'/><category term='latex'/><category term='boost'/><category term='condensed matter'/><category term='france'/><category term='assassin&apos;s creed'/><category term='projects'/><category term='merlot'/><category term='word'/><category term='mail-relay.sh'/><category term='ghostscript'/><category term='mathlink'/><category term='feynman'/><category term='firefox'/><category term='make'/><category term='pebble'/><category term='factorial'/><category term='xkcd'/><category term='keymap'/><category term='italy'/><category term='quantum mechanics'/><category term='valgrind'/><category term='spider'/><category term='PhD'/><category term='mobius strip'/><category term='flocking'/><category term='c++0x'/><category term='keyboard'/><category term='neutrinos'/><category term='c++'/><category term='coombe abbey'/><category term='monte carlo'/><category term='cerenkov'/><category term='lectures'/><category term='ackermann'/><category term='simulation'/><category term='gears of war 3'/><category term='mathematica'/><category term='java'/><category term='pedestrians'/><category term='hamiltonian'/><category term='lagrangian'/><category term='transition'/><category term='squirrel'/><category term='bridge'/><category term='IoP'/><category term='simulated annealing'/><category term='groups'/><category term='velociraptors'/><category term='carmenere'/><category term='autostitch'/><category term='bash'/><category term='reconstruction'/><category term='pdf'/><category term='c'/><category term='interim report'/><category term='visual studio'/><category term='segfault'/><category term='chile'/><category term='climbing'/><category term='android'/><category term='xcode'/><category term='noether'/><category term='middleton'/><category term='gravitation'/><category term='swimming'/><category term='mac'/><category term='xbox 360'/><category term='unit testing'/><category term='network'/><category term='evolutionary algorithms'/><category term='circular polariser'/><category term='statistics'/><category term='cat'/><category term='decadence factor'/><category term='new zealand'/><category term='C99'/><category term='google'/><category term='recursion'/><category term='.NET'/><category term='gnuplot'/><category term='autotools'/><category term='thesis'/><category term='cryptography'/><category term='gauge theories'/><category term='javascript'/><category term='double-beta'/><category term='tolkien'/><category term='bbq'/><category term='moon'/><category term='warwick'/><category term='passwords'/><category term='lake district'/><category term='einstein'/><category term='cern'/><category term='special relativity'/><category term='os x'/><category term='hash functions'/><category term='wine'/><category term='graph'/><category term='sauvignon blanc'/><category term='pinot noir'/><category term='panorama'/><category term='visualisation'/><category term='ibm'/><category term='final year project'/><category term='namespaces'/><category term='superconductors'/><category term='iain m. banks'/><category term='london underground'/><category term='leopard'/><category term='python'/><category term='the plan'/><category term='traffic lights'/><category term='random numbers'/><category term='windows'/><category term='schrödinger'/><category term='nmap tutorial'/><category term='physics'/><category term='high peak trail'/><category term='coventry'/><category term='lhc'/><category term='science'/><category term='linux'/><category term='powerpoint'/><category term='castleton'/><category term='gdb'/><category term='audiosurf'/><category term='internet explorer'/><category term='photography'/><category term='php'/><category term='photoshop'/><category term='programming'/><category term='optics'/><category term='nmap'/><category term='random'/><category term='stephenson'/><category term='icc'/><category term='ssh'/><category term='questionable content'/><category term='music'/><category term='games'/><category term='event generator'/><category term='lisp'/><category term='modules'/><category term='syntax highlighting'/><category term='bbc'/><category term='hdr'/><category term='standard model'/><category term='xmodmap'/><category term='adobe reader'/><category term='aumute'/><category term='electronics'/><category term='C#'/><category term='general relativity'/><category term='final report'/><category term='lorentz'/><category term='fourier transform'/><category term='3D'/><category term='food'/><category term='mathematics'/><category term='microsoft'/><category term='gcc'/><category term='g++'/><category term='particle physics'/><category term='netcat'/><category term='electrodynamics'/><title type='text'>Physical Thought</title><subtitle type='html'>A blog of physics, mathematics, programming and photography...</subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://physical-thought.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4470666517647633822/posts/default?max-results=100'/><link rel='alternate' type='text/html' href='http://physical-thought.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><link rel='next' type='application/atom+xml' href='http://www.blogger.com/feeds/4470666517647633822/posts/default?start-index=101&amp;max-results=100'/><author><name>Andrew J. Bennieston</name><uri>http://www.blogger.com/profile/11705217909278393670</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://1.bp.blogspot.com/-CuxWa8TxxsE/TyLc7-RBAQI/AAAAAAAAAH0/S7n6m_NdMe4/s220/19652_621660810204_61306271_38805166_3421187_n.jpg'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>188</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>100</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-4470666517647633822.post-5190946670488035021</id><published>2012-01-05T16:02:00.002Z</published><updated>2012-01-05T16:04:40.891Z</updated><category scheme='http://www.blogger.com/atom/ns#' term='linux'/><category scheme='http://www.blogger.com/atom/ns#' term='pdf'/><category scheme='http://www.blogger.com/atom/ns#' term='thesis'/><category scheme='http://www.blogger.com/atom/ns#' term='PhD'/><category scheme='http://www.blogger.com/atom/ns#' term='adobe reader'/><title type='text'>Adobe Reader on Linux</title><content type='html'>This afternoon I tried to print a chapter of my thesis to read through and figure out where I needed to make changes. I opened it in Adobe Reader on Linux, as I had done hundreds of times before, and tried to print the relevant page range. I was then informed that the document could not be printed!&lt;br /&gt;&lt;br /&gt;Now, this is a little worrying for a thesis—something which is inherently meant for printing! The weird part was that I'd printed bits of it before, to test layout, colour, etc.&lt;br /&gt;&lt;br /&gt;I tried to print other PDFs through Adobe, which all worked fine. I tried to print the thesis from Okular, which also worked fine. I then gave up and Googled the error message (&lt;i&gt;document could not be printed&lt;/i&gt;). It appears that there was some kind of bug in Adobe Reader 9.4.2 that caused some documents to become unprintable. I downloaded (and, obviously, installed) Adobe Reader 9.4.6 and the problem was gone.&lt;br /&gt;&lt;br /&gt;The moral of the story is, I suppose, always keep up to date on your Adobe Reader version. Obviously this is difficult on Linux since the versions are a way behind, and apparently they're going to stop making them altogether [warning: unsubstantiated rumour]. Unfortunately, none of the other PDF viewers I've tried on Linux actually work very well (both Okular and Evince have various rendering problems, though not the &lt;i&gt;same&lt;/i&gt; problems as each other, which is odd because last time I checked they both used the same rendering engine library...)&lt;br /&gt;&lt;br /&gt;Still, I'd rather work with PDF than any of the much less portable formats people regularly send around for no good reason (MS Word documents, OpenOffice documents, etc.)&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4470666517647633822-5190946670488035021?l=physical-thought.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://physical-thought.blogspot.com/feeds/5190946670488035021/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4470666517647633822&amp;postID=5190946670488035021' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4470666517647633822/posts/default/5190946670488035021'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4470666517647633822/posts/default/5190946670488035021'/><link rel='alternate' type='text/html' href='http://physical-thought.blogspot.com/2012/01/adobe-reader-on-linux.html' title='Adobe Reader on Linux'/><author><name>Andrew J. Bennieston</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://bp2.blogger.com/_zi39n2uYgqg/R3f879w2IHI/AAAAAAAAAAY/IsPK0LU5Duc/S220/avatar.png'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4470666517647633822.post-4605991942401513700</id><published>2012-01-04T16:01:00.004Z</published><updated>2012-01-04T16:02:18.339Z</updated><category scheme='http://www.blogger.com/atom/ns#' term='xbox 360'/><category scheme='http://www.blogger.com/atom/ns#' term='games'/><category scheme='http://www.blogger.com/atom/ns#' term='assassin&apos;s creed'/><title type='text'>Assassin's Creed</title><content type='html'>I recently spent quite a while playing &lt;i&gt;Assassin's Creed&lt;/i&gt; and &lt;i&gt;Assassin's Creed II&lt;/i&gt; (I haven't finished II yet...)&lt;br /&gt;&lt;br /&gt;The games are fantastic! The gameplay in ACII is rather better than the original, but the storyline continues sensibly and it's seriously addictive.&lt;br /&gt;&lt;br /&gt;The addictive nature is helped (?) by the lack of obvious breakpoints; you tend to just keep playing, rather than thinking &lt;i&gt;"this is a good place to stop"&lt;/i&gt;.&lt;br /&gt;&lt;br /&gt;I still have quite a bit of ACII to play through, then &lt;i&gt;Brotherhood&lt;/i&gt; and &lt;i&gt;Revelations&lt;/i&gt;, so I suspect my evenings for the next week or two are looking quite full!&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4470666517647633822-4605991942401513700?l=physical-thought.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://physical-thought.blogspot.com/feeds/4605991942401513700/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4470666517647633822&amp;postID=4605991942401513700' title='3 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4470666517647633822/posts/default/4605991942401513700'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4470666517647633822/posts/default/4605991942401513700'/><link rel='alternate' type='text/html' href='http://physical-thought.blogspot.com/2012/01/assassins-creed.html' title='Assassin&apos;s Creed'/><author><name>Andrew J. Bennieston</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://bp2.blogger.com/_zi39n2uYgqg/R3f879w2IHI/AAAAAAAAAAY/IsPK0LU5Duc/S220/avatar.png'/></author><thr:total>3</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4470666517647633822.post-559027039524802231</id><published>2011-09-21T14:06:00.000+01:00</published><updated>2012-01-05T16:09:07.426Z</updated><category scheme='http://www.blogger.com/atom/ns#' term='c++'/><category scheme='http://www.blogger.com/atom/ns#' term='latex'/><category scheme='http://www.blogger.com/atom/ns#' term='reconstruction'/><category scheme='http://www.blogger.com/atom/ns#' term='particle physics'/><category scheme='http://www.blogger.com/atom/ns#' term='warwick'/><category scheme='http://www.blogger.com/atom/ns#' term='simulation'/><category scheme='http://www.blogger.com/atom/ns#' term='quantum mechanics'/><category scheme='http://www.blogger.com/atom/ns#' term='PhD'/><category scheme='http://www.blogger.com/atom/ns#' term='italy'/><category scheme='http://www.blogger.com/atom/ns#' term='physics'/><category scheme='http://www.blogger.com/atom/ns#' term='food'/><title type='text'>Musings of a Ph.D. student</title><content type='html'>As September 2011 draws to a close, I am coming up on the final six months of my Ph.D. and felt that now would be a good time to make a post about some of the things I've managed to do, and some of the things I have left to finish.&lt;br /&gt;&lt;br /&gt;One of the "goals" of most Ph.D. students is to go somewhere nice for a conference or "school" (essentially a week-long course / conference where the goal is to educate or inform about some aspect of theory, experiment or technology). Over the course of my Ph.D. I've managed to go to Italy twice, Oxford once and Glasgow once...&lt;br /&gt;&lt;br /&gt;The first trip happened as the first year of my Ph.D. was almost over; this should be a fairly familiar story for any UK experimental particle physicist, since I am referring to the STFC RAL Summer School in Oxford. This is a two-week long smorgasbord of quantum field theory, and is simultaneously thoroughly enjoyable and complete hell.&lt;br /&gt;&lt;br /&gt;Let me explain that one; if you're interested in particle physics and you're doing an experimental Ph.D. the summer school is the closest you get to a decent understanding of the theory behind it all. The problems for the first week are interesting and solvable, while the problems for the second week are interesting and impossible unless you are a theorist! The hell aspect comes from having two weeks of lectures, problems, solutions, more lectures, too much food, and far too much alcohol.&lt;br /&gt;&lt;br /&gt;Shortly after the summer school, I had a week-long trip to a place called Bertinoro, in the Forlì-Cesena province of the Emilia-Romagna region of Italy (near Bologna). This was for the 'European School of Computing' (ESC 09) which was a week of lectures on high-performance computing for particle physics. Some of the things discussed here were quite interesting, and my understanding of things like virtual memory improved dramatically over the course of the week. One of the interesting aspects was the food; each night we got to try a different local restaurant!&lt;br /&gt;&lt;br /&gt;My third trip was to Siena, Tuscany (Italy). This was for the IPRD10 conference - a week-long conference on particle detectors. Here, the food was spectacular, but more expensive than in Bertinoro. The weather in Siena was wonderful, and it is a beautiful place to walk around. The same cannot be said for Pisa, though. Staying in Pisa was necessary since I flew into the airport there, and had a flight back from there. Once you've seen the tower (and it really does have quite a lean to it!) there's not an awful lot left.&lt;br /&gt;&lt;br /&gt;One of the highlights of Siena was finding what I thought was a little restaurant on a side street. On walking inside, I discovered that it went quite a long way back, opening out onto a balcony looking out over the Tuscan countryside. This proved to be an ideal place for a lunch of lobster linguine!&lt;br /&gt;&lt;br /&gt;The final trip was to Glasgow, for the IoP NPPD 2011 (Institute of Physics Nuclear &amp;amp; Particle Physics Division) Conference. Since several of us from Warwick were going, we rented a house in Glasgow for the duration of the conference. The house was amazing, and I think it helped to keep me sane, having a "house" to go home to rather than a hotel room and another restaurant dinner. We managed to find a Waitrose on the way between the house and Glasgow University, where the conference was held, so all of our evening meal and breakfast needs were taken care of. The cooking facilities in the house were second to none, and the entire experience was a huge success.&lt;br /&gt;&lt;br /&gt;I managed to give talks at both the IPRD10 and NPPD11 conferences, on both occasions to a small but interested audience, so that is one of the Ph.D. checkboxes ticked.&lt;br /&gt;&lt;br /&gt;I've spent three years now working on software for track reconstruction in liquid Argon TPCs (time-projection chambers). This software has been in a mixture of C++ and Python. As I write, I'm currently finishing some work on one such algorithm and heading towards a sensible analysis to round off my thesis... which I started writing last week.&lt;br /&gt;&lt;br /&gt;So, in terms of things left to do, I need to formulate some coherent idea of what my final analysis will actually involve, get all the pieces of software together and working, and then run them on large data samples. All this while simultaneously writing a thesis...&lt;br /&gt;&lt;br /&gt;Regarding the thesis itself, I spent a little while working on stylistic issues such as changing the chapter title pages from the default to something a little more colourful and modern. In doing so, I purchased the &lt;a href="http://en.wikipedia.org/wiki/Futura_%28typeface%29"&gt;&lt;i&gt;Futura Std Medium&lt;/i&gt;&lt;/a&gt; font from adobe.com to use as the chapter title font in my thesis (and then had to figure out how to make XeTeX pick up this font and use it).&lt;br /&gt;&lt;br /&gt;I guess now I just have six months of being very busy, working simultaneously on analysing physics events, writing chapters of my thesis, writing any papers that seem appropriate along the way, and trying to remain sane.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4470666517647633822-559027039524802231?l=physical-thought.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://physical-thought.blogspot.com/feeds/559027039524802231/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4470666517647633822&amp;postID=559027039524802231' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4470666517647633822/posts/default/559027039524802231'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4470666517647633822/posts/default/559027039524802231'/><link rel='alternate' type='text/html' href='http://physical-thought.blogspot.com/2011/09/musings-of-phd-student.html' title='Musings of a Ph.D. student'/><author><name>Andrew J. Bennieston</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://bp2.blogger.com/_zi39n2uYgqg/R3f879w2IHI/AAAAAAAAAAY/IsPK0LU5Duc/S220/avatar.png'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4470666517647633822.post-221903401300953199</id><published>2011-09-21T11:58:00.001+01:00</published><updated>2011-09-21T11:59:20.140+01:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='xbox 360'/><category scheme='http://www.blogger.com/atom/ns#' term='gears of war 3'/><category scheme='http://www.blogger.com/atom/ns#' term='games'/><title type='text'>Gears of War 3</title><content type='html'>So I'm not what you'd call a "big gamer" (I'm neither obese, nor do I play a lot of games). I do, however, own an Xbox 360, and I was therefore eagerly awaiting Gears 3, which was released yesterday.&lt;br /&gt;&lt;br /&gt;Now, my introduction to the Gears saga began with Horde on Gears of War 2, while visiting friends with Xboxes. This experience was sufficient to make me buy a 360 and a copy of Gears 2. Once I'd completed that, I bought Gears 1. I haven't actually *finished* Gears 1, but that is mostly due to a lack of time, rather than, say, lack of interest.&lt;br /&gt;&lt;br /&gt;Anyway, yesterday was eagerly anticipated; I even went so far as to pre-order Gears 3&amp;nbsp; from Amazon (though they didn't manage to get it to me by the release day, which I consider to be a pretty major problem considering the concept of pre-ordering, and the concept of Amazon Prime... oh well!) Instead, I bought a copy from Sainsburys (and will sell the other copy to my housemates) and I spent much of the evening playing.&lt;br /&gt;&lt;br /&gt;The first point I want to make is that, as I write this, I haven't &lt;b&gt;finished&lt;/b&gt; Gears 3. In fact, I've only played through Act 1 on Normal difficulty, and played waves 1 through 33 of Horde on Normal difficulty. Then, extreme tiredness kicked in and I went to bed.&lt;br /&gt;&lt;br /&gt;As far as gameplay is concerned, it feels much the same as Gears 2. The graphics have been polished a little, but it's basically the familiar experience; &lt;a href="http://penny-arcade.com/comic/2011/09/21"&gt;today's Penny Arcade&lt;/a&gt; pretty much sums it up.&lt;br /&gt;&lt;br /&gt;I won't go into details about the storyline, but the first act has an interesting split to it, and the Horde mode has been enhanced somewhat, which makes it a little more interesting than the "wait, shoot, wait" cycle of Gears 2 Horde.&lt;br /&gt;&lt;br /&gt;I haven't tried out the Beast mode yet, but that sounds like it should be fun; maybe I'll write more about that another day!&lt;br /&gt;&lt;br /&gt;In all, Gears 3 delivered exactly what I expected... the third chapter in the Gears story, the familiar gameplay in familiar environments... having played the previous versions, I'm not having too much trouble playing through on Normal difficulty. I guess Hardcore and Insane are going to be more tricky; and probably even more fun.&lt;br /&gt;&lt;br /&gt;As for achievements, the usual complement return (Waves 1-10 on Horde, Waves 1-50 on Horde, story progression in the campaign, etc.) though I haven't spotted any as ridiculously hard to achieve as Seriously 2.0 on Gears 2... yet!&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4470666517647633822-221903401300953199?l=physical-thought.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://physical-thought.blogspot.com/feeds/221903401300953199/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4470666517647633822&amp;postID=221903401300953199' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4470666517647633822/posts/default/221903401300953199'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4470666517647633822/posts/default/221903401300953199'/><link rel='alternate' type='text/html' href='http://physical-thought.blogspot.com/2011/09/gears-of-war-3.html' title='Gears of War 3'/><author><name>Andrew J. Bennieston</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://bp2.blogger.com/_zi39n2uYgqg/R3f879w2IHI/AAAAAAAAAAY/IsPK0LU5Duc/S220/avatar.png'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4470666517647633822.post-9156163786742083591</id><published>2011-03-12T18:27:00.001Z</published><updated>2011-03-12T18:28:44.819Z</updated><category scheme='http://www.blogger.com/atom/ns#' term='projects'/><category scheme='http://www.blogger.com/atom/ns#' term='java'/><category scheme='http://www.blogger.com/atom/ns#' term='programming'/><category scheme='http://www.blogger.com/atom/ns#' term='android'/><title type='text'>More Android Development</title><content type='html'>So far, I've managed to set up Eclipse to use the Android dev. tools and completed the 'Hello World' tutorial. This proved relatively simple, except for the matter of getting the entire emulator visible on a Macbook display. My resolution is 1280x800 and the Android emulator wants to display something 800 pixels high. Luckily, I discovered that you can pass the emulator a command line option to scale the device on screen:&lt;br /&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="color: #444444;"&gt;emulator -scale 0.75&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="color: #444444;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;The full list of options is available at&amp;nbsp;&lt;a href="http://developer.android.com/guide/developing/tools/emulator.html"&gt;http://developer.android.com/guide/developing/tools/emulator.html&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;There's a 'Notepad Tutorial' to try next, so I'll probably do enough of that to get a decent idea of the components available, then start digging around the reference documentation for the components I'll actually need for one of the ideas I have (more on this later!)&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4470666517647633822-9156163786742083591?l=physical-thought.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://physical-thought.blogspot.com/feeds/9156163786742083591/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4470666517647633822&amp;postID=9156163786742083591' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4470666517647633822/posts/default/9156163786742083591'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4470666517647633822/posts/default/9156163786742083591'/><link rel='alternate' type='text/html' href='http://physical-thought.blogspot.com/2011/03/more-android-development.html' title='More Android Development'/><author><name>Andrew J. Bennieston</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://bp2.blogger.com/_zi39n2uYgqg/R3f879w2IHI/AAAAAAAAAAY/IsPK0LU5Duc/S220/avatar.png'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4470666517647633822.post-993453188347370621</id><published>2011-03-12T02:04:00.001Z</published><updated>2011-03-12T18:28:35.463Z</updated><category scheme='http://www.blogger.com/atom/ns#' term='projects'/><category scheme='http://www.blogger.com/atom/ns#' term='java'/><category scheme='http://www.blogger.com/atom/ns#' term='programming'/><category scheme='http://www.blogger.com/atom/ns#' term='android'/><title type='text'>Android Development</title><content type='html'>It's been a while since I posted here, and since I've decided to spend a little time on a new project, I thought I might use the opportunity to write some new posts.&lt;br /&gt;&lt;br /&gt;The project is to get acquainted with the Android SDK and write one or two apps for my Android phone (HTC Desire, since you didn't ask).&lt;br /&gt;&lt;br /&gt;So far, it's going well. I'm taking the easy route, as outlined at&amp;nbsp;&lt;a href="http://developer.android.com/sdk/installing.html"&gt;http://developer.android.com/sdk/installing.html&lt;/a&gt; so I have downloaded the SDK starter, and downloaded Eclipse. I'm now installing the 'ADT' (Android Developer Tools?) into Eclipse.&lt;br /&gt;&lt;br /&gt;I've never really bothered with Eclipse before, since I prefer to do most of my software development with gvim and a terminal window, but it is apparently the easiest way to get started with Android development. We'll see...&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4470666517647633822-993453188347370621?l=physical-thought.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://physical-thought.blogspot.com/feeds/993453188347370621/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4470666517647633822&amp;postID=993453188347370621' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4470666517647633822/posts/default/993453188347370621'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4470666517647633822/posts/default/993453188347370621'/><link rel='alternate' type='text/html' href='http://physical-thought.blogspot.com/2011/03/android-development.html' title='Android Development'/><author><name>Andrew J. Bennieston</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://bp2.blogger.com/_zi39n2uYgqg/R3f879w2IHI/AAAAAAAAAAY/IsPK0LU5Duc/S220/avatar.png'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4470666517647633822.post-8536114130531424025</id><published>2010-06-30T23:27:00.000+01:00</published><updated>2010-06-30T23:27:56.145+01:00</updated><title type='text'>Comment Moderation</title><content type='html'>In the last few days I've noticed a number of spam comments appearing on here. I've turned on comment moderation in order to prevent these receiving any airtime, but please accept my apologies if you are a genuine commenter and your comment is not published immediately; I'll approve the comments just as soon as I can.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4470666517647633822-8536114130531424025?l=physical-thought.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://physical-thought.blogspot.com/feeds/8536114130531424025/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4470666517647633822&amp;postID=8536114130531424025' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4470666517647633822/posts/default/8536114130531424025'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4470666517647633822/posts/default/8536114130531424025'/><link rel='alternate' type='text/html' href='http://physical-thought.blogspot.com/2010/06/comment-moderation.html' title='Comment Moderation'/><author><name>Andrew J. Bennieston</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://bp2.blogger.com/_zi39n2uYgqg/R3f879w2IHI/AAAAAAAAAAY/IsPK0LU5Duc/S220/avatar.png'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4470666517647633822.post-5379210646465694794</id><published>2010-06-26T22:14:00.000+01:00</published><updated>2010-06-26T22:14:48.988+01:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='wine'/><title type='text'>Wine Reviews</title><content type='html'>Some semi-regular readers may have noticed that I occasionally post wine reviews on this blog. Today, I created a new blog,&amp;nbsp;&lt;a href="http://distilled-taste.blogspot.com/"&gt;Distilled Taste&lt;/a&gt;, where I, along with two friends, will review and discuss beers, ciders, wines and spirits from around the world. If you're interested in that kind of thing, why not take a look?&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4470666517647633822-5379210646465694794?l=physical-thought.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://physical-thought.blogspot.com/feeds/5379210646465694794/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4470666517647633822&amp;postID=5379210646465694794' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4470666517647633822/posts/default/5379210646465694794'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4470666517647633822/posts/default/5379210646465694794'/><link rel='alternate' type='text/html' href='http://physical-thought.blogspot.com/2010/06/wine-reviews.html' title='Wine Reviews'/><author><name>Andrew J. Bennieston</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://bp2.blogger.com/_zi39n2uYgqg/R3f879w2IHI/AAAAAAAAAAY/IsPK0LU5Duc/S220/avatar.png'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4470666517647633822.post-3931007541242885085</id><published>2010-05-23T01:41:00.000+01:00</published><updated>2010-05-23T01:41:07.338+01:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='photography'/><category scheme='http://www.blogger.com/atom/ns#' term='moon'/><title type='text'>The Moon</title><content type='html'>This is the best image from fifteen photographs of the Moon that I took this evening. My flat has a skylight thing in the roof, which opens and tilts in various ways (it would be great for using a telescope, actually...) so I decided to set up my camera and tripod and take some photos of the moon, since it was a clear night.&lt;br /&gt;&lt;br /&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://3.bp.blogspot.com/_zi39n2uYgqg/S_h5hHGsDuI/AAAAAAAAAR4/jLLc5jp0ir8/s1600/IMG_5454_fb.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="266" src="http://3.bp.blogspot.com/_zi39n2uYgqg/S_h5hHGsDuI/AAAAAAAAAR4/jLLc5jp0ir8/s400/IMG_5454_fb.jpg" width="400" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4470666517647633822-3931007541242885085?l=physical-thought.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://physical-thought.blogspot.com/feeds/3931007541242885085/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4470666517647633822&amp;postID=3931007541242885085' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4470666517647633822/posts/default/3931007541242885085'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4470666517647633822/posts/default/3931007541242885085'/><link rel='alternate' type='text/html' href='http://physical-thought.blogspot.com/2010/05/moon.html' title='The Moon'/><author><name>Andrew J. Bennieston</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://bp2.blogger.com/_zi39n2uYgqg/R3f879w2IHI/AAAAAAAAAAY/IsPK0LU5Duc/S220/avatar.png'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://3.bp.blogspot.com/_zi39n2uYgqg/S_h5hHGsDuI/AAAAAAAAAR4/jLLc5jp0ir8/s72-c/IMG_5454_fb.jpg' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4470666517647633822.post-7432320829697509762</id><published>2010-04-30T21:02:00.000+01:00</published><updated>2010-04-30T21:02:43.424+01:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='sauvignon blanc'/><category scheme='http://www.blogger.com/atom/ns#' term='new zealand'/><category scheme='http://www.blogger.com/atom/ns#' term='wine'/><title type='text'>Wine: Shelter Bay Sauvignon Blanc 2009</title><content type='html'>This sauvignon blanc is from Marlborough, New Zealand, and possesses strong gooseberry aromas with hints of tropical fruit. The fruit theme continues through to the taste, which is long and smooth. This is a very clean, dry white, with refreshing characteristics ideal for Spring and Summer drinking. I had it with tagliatelle carbonara, but it would go well with fish, chicken or light cheeses.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4470666517647633822-7432320829697509762?l=physical-thought.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://physical-thought.blogspot.com/feeds/7432320829697509762/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4470666517647633822&amp;postID=7432320829697509762' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4470666517647633822/posts/default/7432320829697509762'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4470666517647633822/posts/default/7432320829697509762'/><link rel='alternate' type='text/html' href='http://physical-thought.blogspot.com/2010/04/wine-shelter-bay-sauvignon-blanc-2009.html' title='Wine: Shelter Bay Sauvignon Blanc 2009'/><author><name>Andrew J. Bennieston</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://bp2.blogger.com/_zi39n2uYgqg/R3f879w2IHI/AAAAAAAAAAY/IsPK0LU5Duc/S220/avatar.png'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4470666517647633822.post-7295884677798536306</id><published>2010-03-19T22:48:00.001Z</published><updated>2010-03-19T22:51:18.065Z</updated><category scheme='http://www.blogger.com/atom/ns#' term='pinot noir'/><category scheme='http://www.blogger.com/atom/ns#' term='chile'/><category scheme='http://www.blogger.com/atom/ns#' term='particle physics'/><category scheme='http://www.blogger.com/atom/ns#' term='neutrinos'/><category scheme='http://www.blogger.com/atom/ns#' term='physics'/><category scheme='http://www.blogger.com/atom/ns#' term='food'/><title type='text'>Must look like I'm running away, to you at your faster pace</title><content type='html'>(Post title inspired by Tim's blog post, over at &lt;a href="http://timfightsbears.blogspot.com/"&gt;http://timfightsbears.blogspot.com/&lt;/a&gt;)&lt;br /&gt;&lt;br /&gt;So I thought I'd make a more traditional "blog-style" post; talking about things I've done, and such...&lt;br /&gt;&lt;br /&gt;&lt;b&gt;UK Neutrino Network Meeting&lt;/b&gt;&lt;br /&gt;I attended the March 17th UK Neutrino Network Meeting (link&amp;nbsp;&lt;a href="http://www.pact.cpes.sussex.ac.uk/%7Esjp39/uknnm10.html"&gt;here&lt;/a&gt;) in Sussex, this week. As an experimental physicist, most of the theory talks (so, most of the session) went right over my head, but as someone with an interest in theory and phenomenology it's always nice to hear about what's going on in the field; I had no idea so many people were working so actively on leptogenesis. Seems that the Harrison-Perkins-Scott tri-bi-maximal mixing stuff is pretty popular, too, which is nice.&lt;br /&gt;&lt;br /&gt;The more experimentally-oriented talks proved quite interesting; it's good to see there's a lot of work going on, despite the complete lack of funding!&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Paper&lt;/b&gt;&lt;br /&gt;I've been working towards writing a paper on the stuff I've been doing for my Ph.D. since summer 2009. It's looking like it might be finished in the more imminent future, for the first time since then; the basic software framework is in place and all the algorithms are working to varying degrees, so unless another big surprise is lurking just around the corner, I should be able to actually make some progress. I can't really say any more about this at present, but stay tuned for details when the thing is finally published!&lt;br /&gt;&lt;b&gt; &lt;/b&gt;&lt;br /&gt;&lt;b&gt;Food&lt;/b&gt;&lt;br /&gt;I haven't really had time to cook elaborate meals, lately, but tonight I made a sort of variant on Chicken Basque. I had in mind to do some kind of Coq au vin kind of thing, and I was looking through cookbooks to find some ideas. What I ended up doing was to fry chicken drumsticks and thighs in a little groundnut oil until the skin went golden, then put them aside on a plate, and fry onions, chorizo, garlic and red pepper in the same oil. I then added some sun-dried tomato, and about 150g basmati rice, before pouring in about 250ml of red wine (&lt;i&gt;Cono Sur&lt;/i&gt; Pinot Noir, Chile), 200ml chicken stock, black pepper, paprika and herbs. Once this was all simmering again, the chicken pieces went back in, and the whole thing went in the oven at about 170C (180C if you don't have a fan oven) for 45 minutes. The result was tasty.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Sleep&lt;/b&gt;&lt;br /&gt;I haven't been sleeping much. This is bad. I need more exercise, and to stop working earlier in the evening!&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4470666517647633822-7295884677798536306?l=physical-thought.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://physical-thought.blogspot.com/feeds/7295884677798536306/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4470666517647633822&amp;postID=7295884677798536306' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4470666517647633822/posts/default/7295884677798536306'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4470666517647633822/posts/default/7295884677798536306'/><link rel='alternate' type='text/html' href='http://physical-thought.blogspot.com/2010/03/must-look-like-im-running-away-to-you.html' title='Must look like I&apos;m running away, to you at your faster pace'/><author><name>Andrew J. Bennieston</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://bp2.blogger.com/_zi39n2uYgqg/R3f879w2IHI/AAAAAAAAAAY/IsPK0LU5Duc/S220/avatar.png'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4470666517647633822.post-8836430517305148411</id><published>2010-03-04T20:14:00.000Z</published><updated>2010-03-04T20:14:32.093Z</updated><category scheme='http://www.blogger.com/atom/ns#' term='lorentz'/><category scheme='http://www.blogger.com/atom/ns#' term='standard model'/><category scheme='http://www.blogger.com/atom/ns#' term='particle physics'/><category scheme='http://www.blogger.com/atom/ns#' term='special relativity'/><category scheme='http://www.blogger.com/atom/ns#' term='quantum mechanics'/><category scheme='http://www.blogger.com/atom/ns#' term='schrödinger'/><category scheme='http://www.blogger.com/atom/ns#' term='physics'/><category scheme='http://www.blogger.com/atom/ns#' term='lagrangian'/><category scheme='http://www.blogger.com/atom/ns#' term='gauge theories'/><category scheme='http://www.blogger.com/atom/ns#' term='noether'/><category scheme='http://www.blogger.com/atom/ns#' term='electrodynamics'/><category scheme='http://www.blogger.com/atom/ns#' term='neutrinos'/><category scheme='http://www.blogger.com/atom/ns#' term='science'/><category scheme='http://www.blogger.com/atom/ns#' term='hamiltonian'/><title type='text'>The Road To Quantum Field Theory: Updated Post List</title><content type='html'>Once again, I'm posting an index, essentially, of the posts in the `Road to QFT' series, so far. The previous list was &lt;a href="http://physical-thought.blogspot.com/2009/01/road-to-quantum-field-theory.html"&gt;here&lt;/a&gt;, but I'll reproduce all of the links in this post too.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Pre-Series Posts&lt;/b&gt;&lt;br /&gt;These were posts on related topics (special relativity, quantum mechanics and particle physics)&lt;br /&gt;&lt;ul&gt;&lt;li&gt;&lt;b&gt; &lt;/b&gt;&lt;a href="http://physical-thought.blogspot.com/2008/04/introduction-to-relativity.html"&gt;An Introduction to Relativity&lt;/a&gt;&amp;nbsp;&lt;/li&gt;&lt;li&gt;&lt;a href="http://physical-thought.blogspot.com/2008/04/relativistic-velocity-transformations.html"&gt;Relativistic Velocity Transformations&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href="http://physical-thought.blogspot.com/2008/04/four-vector-relativistic-velocity.html"&gt;Four-Vector Relativistic Velocity Transformations&lt;/a&gt;&amp;nbsp;&lt;/li&gt;&lt;li&gt;&lt;a href="http://physical-thought.blogspot.com/2008/04/classical-electrodynamics.html"&gt;Classical Electrodynamics&lt;/a&gt;&amp;nbsp;&lt;/li&gt;&lt;li&gt;&lt;a href="http://physical-thought.blogspot.com/2008/04/relativistic-quantum-mechanics-klein.html"&gt;Relativistic Quantum Mechanics - The Klein-Gordon Equation&lt;/a&gt;&amp;nbsp;&lt;/li&gt;&lt;li&gt;&lt;a href="http://physical-thought.blogspot.com/2008/05/quantum-mechanics-of-neutrino.html"&gt;The Quantum Mechanics of Neutrino Oscillations&lt;/a&gt;&amp;nbsp;&lt;/li&gt;&lt;/ul&gt;&lt;b&gt;The `Road To Quantum Field Theory' Series&lt;/b&gt;&lt;br /&gt;Posts in the `Road to QFT' series, in chronological order.&lt;br /&gt;&lt;ul&gt;&lt;li&gt;&lt;a href="http://physical-thought.blogspot.com/2008/09/lagrangian-mechanics-from-principle-of.html"&gt;Lagrangian Mechanics: From the Principle of Least Action to the Euler-Lagrange Equation&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href="http://physical-thought.blogspot.com/2008/09/lagrangian-mechanics-from-euler.html"&gt;Lagrangian Mechanics: From the Euler-Lagrange Equation to Newton's Laws&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href="http://physical-thought.blogspot.com/2008/09/lagrangian-mechanics-from-euler_20.html"&gt;Lagrangian Mechanics: From the Euler-Lagrange Equation to Simple Harmonic Motion&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href="http://physical-thought.blogspot.com/2008/09/from-lagrangian-to-hamiltonian.html"&gt;From Lagrangian to Hamiltonian Mechanics&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href="http://physical-thought.blogspot.com/2008/09/symmetries-conserved-quantities-and.html"&gt;Symmetries, Conserved Quantities and Noether's Theorem&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href="http://physical-thought.blogspot.com/2009/01/mathematics-of-special-relativity.html"&gt;The Mathematics of Special Relativity&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href="http://physical-thought.blogspot.com/2009/12/lorentz-covariant-and-gauge-invariant.html"&gt;Lorentz-Covariant and Gauge-Invariant Electrodynamics&lt;/a&gt;&amp;nbsp;&lt;/li&gt;&lt;li&gt;&lt;a href="http://physical-thought.blogspot.com/2010/03/gauge-invariance-in-quantum-mechanics.html"&gt;Gauge Invariance in Quantum Mechanics&lt;/a&gt;&amp;nbsp;&lt;/li&gt;&lt;/ul&gt;&lt;b&gt;Out-of-Series Posts&lt;/b&gt;&lt;br /&gt;Posts on related topics which were not intended as part of the `Road to QFT' series, but may be of interest anyway.&lt;b&gt; &lt;/b&gt;&lt;br /&gt;&lt;ul&gt;&lt;li&gt;&lt;b&gt;&amp;nbsp;&lt;/b&gt; &lt;a href="http://physical-thought.blogspot.com/2008/11/basic-relativity.html"&gt;Basic Relativity&lt;/a&gt;&amp;nbsp;&lt;/li&gt;&lt;/ul&gt;&lt;b&gt;Roadmap&lt;/b&gt;&lt;br /&gt;As before, I'll post a rough list of things still to be covered. By comparing the previous roadmap to the most recent two posts, you'll notice I've done things slightly out of the order I mentioned there, so this is really a very approximate guide.&lt;br /&gt;&lt;ul&gt;&lt;li&gt;Relativistic QM: The Klein-Gordon Equation &amp;amp; Spin-Zero Particles&lt;/li&gt;&lt;li&gt;Relativistic QM 2: The Dirac Equation &amp;amp; Spin-Half Particles&lt;/li&gt;&lt;li&gt;Quantum Electrodynamics (QED)&lt;/li&gt;&lt;li&gt;Quantum Chromodynamics (QCD)&lt;/li&gt;&lt;li&gt;SU(2) and Electroweak Unification&lt;/li&gt;&lt;li&gt;Quark Flavour Mixing &lt;/li&gt;&lt;li&gt;Spontaneous Symmetry Breaking and the Higgs Mechanism &lt;/li&gt;&lt;li&gt;Beyond the Standard Model: Neutrino Mass Terms &amp;amp; Neutrino Mixing&lt;/li&gt;&lt;/ul&gt;This is still a very ambitious set of things to cover. In particular, the posts so far have only brushed the surface, providing the background needed to understand relativistic quantum mechanics and gauge theories. The real work is yet to come! Note also that I am not a theorist, so my coverage of some of the more advanced topics may be less than completely thorough! I've added sections on quark flavour mixing and neutrino masses &amp;amp; mixing to the roadmap since they are of particular interest to me. &lt;br /&gt;&lt;ul&gt;&lt;/ul&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4470666517647633822-8836430517305148411?l=physical-thought.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://physical-thought.blogspot.com/feeds/8836430517305148411/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4470666517647633822&amp;postID=8836430517305148411' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4470666517647633822/posts/default/8836430517305148411'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4470666517647633822/posts/default/8836430517305148411'/><link rel='alternate' type='text/html' href='http://physical-thought.blogspot.com/2010/03/road-to-quantum-field-theory-updated.html' title='The Road To Quantum Field Theory: Updated Post List'/><author><name>Andrew J. Bennieston</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://bp2.blogger.com/_zi39n2uYgqg/R3f879w2IHI/AAAAAAAAAAY/IsPK0LU5Duc/S220/avatar.png'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4470666517647633822.post-6634528429815837702</id><published>2010-03-02T21:37:00.070Z</published><updated>2010-03-02T22:28:05.482Z</updated><category scheme='http://www.blogger.com/atom/ns#' term='lorentz'/><category scheme='http://www.blogger.com/atom/ns#' term='gauge theories'/><category scheme='http://www.blogger.com/atom/ns#' term='special relativity'/><category scheme='http://www.blogger.com/atom/ns#' term='particle physics'/><category scheme='http://www.blogger.com/atom/ns#' term='electrodynamics'/><category scheme='http://www.blogger.com/atom/ns#' term='quantum mechanics'/><title type='text'>Gauge Invariance in Quantum Mechanics</title><content type='html'>&lt;i&gt;This post continues the 'Road to Quantum Field Theory' series.&lt;/i&gt;&lt;br /&gt;&lt;br /&gt;The Lorentz force law for a non-relativistic particle of charge q, moving with velocity v in both electric (&lt;b&gt;E&lt;/b&gt;) and magnetic (&lt;b&gt;B&lt;/b&gt;) fields, is given by: &lt;pre lang="eq.latex"&gt;\mathbf{F} = q\mathbf{E} + q\mathbf{v}\times\mathbf{B}&lt;/pre&gt;This can be derived from Hamilton's equations using the classical Hamiltonian given below.&lt;br /&gt;&lt;pre lang="eq.latex"&gt;H = \frac{1}{2m}\left(\mathbf{p}-q\mathbf{A}\right)^2 + qV&lt;/pre&gt;The Schrödinger equation for a charged particle in an EM field is,&lt;br /&gt;&lt;pre lang="eq.latex"&gt;\left[\frac{1}{2m}\left(-i\nabla - q\mathbf{A}\right)^2 + qV \right] \psi(\mathbf{x},t) = i\frac{\partial \psi(\mathbf{x},t)}{\partial t}&lt;/pre&gt;obtained from the Hamiltonian through the substitution &lt;pre lang="eq.latex"&gt;\mathbf{p} \rightarrow -i\nabla&lt;/pre&gt;as is usual for the quantum mechanical momentum operator. We can identify operator combinations:&lt;br /&gt;&lt;pre lang="eq.latex"&gt;\mathbf{D} = \nabla - iq\mathbf{A}&lt;/pre&gt;&lt;pre lang="eq.latex"&gt;D^0 = \frac{\partial}{\partial t} + iqV&lt;/pre&gt;which replace the operators &lt;pre lang="eq.latex" style="display: inline;"&gt;\nabla, \frac{\partial}{\partial t}&lt;/pre&gt;when we move from the free-particle Schrödinger equation to the electromagnetic field case.&lt;br /&gt;&lt;br /&gt;The solutions for the wavefunctions of the Schrödinger equation describe completely the behaviour of a particle under the influence of the potentials &lt;b&gt;A&lt;/b&gt; and V, but these potentials are not unique, as I showed in the previous post in this series. Instead, they can be changed by a gauge transformation:&lt;br /&gt;&lt;pre lang="eq.latex"&gt;\mathbf{A}\rightarrow\mathbf{A}^\prime=\mathbf{A}+\nabla\chi&lt;/pre&gt;&lt;pre lang="eq.latex"&gt;V\rightarrow V^\prime = V - \frac{\partial\chi}{\partial t}&lt;/pre&gt;Maxwell's equations for &lt;b&gt;E&lt;/b&gt; and &lt;b&gt;B&lt;/b&gt; will remain invariant under these transformations (this was the topic of the previous post), but will the physics described by the Schrödinger equation be the same if we make these changes to the potentials there?&lt;br /&gt;&lt;br /&gt;The answer is &lt;b&gt;no&lt;/b&gt;! The Schrödinger equation is not gauge invariant, since the same wavefunction cannot satisfy both the original and transformed versions! All is not lost, however. The wavefunction itself is not directly observable, whereas &lt;b&gt;E&lt;/b&gt; and &lt;b&gt;B&lt;/b&gt; are. If we do not require the wavefunction to remain invariant when the potentials undergo a transformation, then we are free to change the wavefunction such that we retain invariance of physical observables. Write the Schrödinger equation in terms of some transformed wavefunction,&lt;br /&gt;&lt;pre lang="eq.latex"&gt;\psi\rightarrow\psi^\prime&lt;/pre&gt;i.e.&lt;br /&gt;&lt;pre lang="eq.latex"&gt;\left[\frac{1}{2m}\left(-i\nabla - q\mathbf{A}^\prime\right)^2 + qV^\prime\right] \psi^\prime(\mathbf{x},t) = i\frac{\partial \psi^\prime (\mathbf{x},t)}{\partial t}&lt;/pre&gt;&lt;br /&gt;Now, the &lt;i&gt;form&lt;/i&gt; in which we have written the equation above is identical to that of the original Schrödinger equation, except that we are writing it in terms of primed quantities (psi', &lt;b&gt;A'&lt;/b&gt;, V') instead of unprimed (psi, &lt;b&gt;A&lt;/b&gt;, V). Both equations describe the same physics, so if we can find such a psi', then the Schrödinger equation is &lt;i&gt;gauge covariant&lt;/i&gt;; that is, it maintains the same form under a gauge transformation.&lt;br /&gt;&lt;br /&gt;We know the relationship between &lt;b&gt;A&lt;/b&gt;, V and &lt;b&gt;A'&lt;/b&gt;, V', so we can write down the transformation for psi':&lt;br /&gt;&lt;pre lang="eq.latex"&gt;\psi^\prime (\mathbf{x},t) = e^{iq\chi(\mathbf{x},t)}\psi(\mathbf{x},t)&lt;/pre&gt;where &lt;pre lang="eq.latex" style="display: inline;"&gt;\chi&lt;/pre&gt;is the &lt;i&gt;same&lt;/i&gt; space- and time- dependent function appearing in the transformations of &lt;b&gt;A&lt;/b&gt; and V. We can verify that this results in the gauge covariance of the Schrödinger equation:&lt;br /&gt;&lt;pre lang="eq.latex"&gt;(-i\nabla - q\mathbf{A}^\prime)\psi^\prime=\left[-i\nabla-q\mathbf{A}-q(\nabla\chi)\right]e^{iq\chi}\psi&lt;/pre&gt;&lt;pre lang="eq.latex"&gt;=q(\nabla\chi)e^{iq\chi}\psi + e^{iq\chi}(-i\nabla\psi) + e^{iq\chi}(-q\mathbf{A}\psi) - q(\nabla\chi)e^{iq\chi}\psi&lt;/pre&gt;The first and last terms cancel, leaving:&lt;br /&gt;&lt;pre lang="eq.latex"&gt;(-i\nabla - q\mathbf{A}^\prime)\psi^\prime = e^{iq\chi}(-i\nabla - qA)\psi&lt;/pre&gt;which can be written as:&lt;br /&gt;&lt;pre lang="eq.latex"&gt;(-i\mathbf{D}^\prime \psi^\prime) = e^{iq\chi}(-i\mathbf{D}\psi)&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;The space-time dependent phase factor feels the action of &lt;pre lang="eq.latex" style="display: inline;"&gt;\nabla&lt;/pre&gt;, but passes through the combined &lt;b&gt;D'&lt;/b&gt; operator, converting it to &lt;b&gt;D&lt;/b&gt;, so it becomes clear that &lt;b&gt;D'&lt;/b&gt;psi' is related to &lt;b&gt;D&lt;/b&gt;psi in the same way psi' is related to psi! Similarly,&lt;br /&gt;&lt;pre lang="eq.latex"&gt;(iD^{0\prime}\psi^\prime = e^{iq\chi}(iD^0\psi)&lt;/pre&gt;&lt;br /&gt;We can now erite:&lt;br /&gt;&lt;pre lang="eq.latex"&gt;\frac{1}{2m}(-i\mathbf{D}^\prime)^2 \psi\prime = e^{iq\chi}\frac{1}{2m}(-i\mathbf{D})^2 \psi = e^{iq\chi}iD^0\psi = iD^{0\prime}\psi^\prime&lt;/pre&gt;which demonstrates the correct relationship between psi and psi'. The question remains whether the same physics is described by both psi and psi'. We can see that it is in a number of ways:&lt;br /&gt;&lt;br /&gt;1. The probability density is given by &lt;pre lang="eq.latex" style="display: inline;"&gt;|\psi|^2 = \psi^\dagger \psi&lt;/pre&gt;, which is equivalent to &lt;pre lang="eq.latex"&gt;|\psi\prime|^2 = \psi^{\prime\dagger} \psi^\prime = \psi^\dagger e^{-iq\chi}e^{+iq\chi}\psi = \psi^\dagger \psi&lt;/pre&gt;&lt;br /&gt;2. The probability current, &lt;pre lang="eq.latex"&gt;\psi^\dagger(\nabla\psi) - (\nabla\psi)\psi^\dagger&lt;/pre&gt;is &lt;i&gt;not&lt;/i&gt; invariant under a gauge transformation, but when we replace &lt;pre lang="eq.latex" style="display: inline;"&gt;\nabla \rightarrow \mathbf{D} ~~,~~ \frac{\partial}{\partial t} \rightarrow D^0&lt;/pre&gt;then,&lt;br /&gt;&lt;pre lang="eq.latex"&gt;\psi^\dagger\prime(\mathbf{D}\psi^\prime = \psi^\dagger e^{-iq\chi} e^{iq\chi}(\mathbf{D}\psi) = \psi^\dagger\mathbf{D}\psi&lt;/pre&gt;(and similarly for the other term).&lt;br /&gt;&lt;br /&gt;Hence, identical physics is described by both the wavefunction psi, and the gauge transformed wavefunction psi'; the gauge invariance of Maxwell's equations presents as a &lt;i&gt;gauge covariance&lt;/i&gt; in quantum mechanics, provided that we transform not only the potentials, but the wavefunction also:&lt;br /&gt;&lt;pre lang="eq.latex"&gt;\mathbf{A}\rightarrow \mathbf{A}^\prime = \mathbf{A} + \nabla\chi&lt;/pre&gt;&lt;pre lang="eq.latex"&gt;V\rightarrow V^\prime = V - \frac{\partial \chi}{\partial x}&lt;/pre&gt;&lt;pre lang="eq.latex"&gt;\psi\rightarrow \psi^\prime = i^{iq\chi}\psi&lt;/pre&gt;&lt;br /&gt;Finally, we note that the new differential operators,&lt;br /&gt;&lt;pre lang="eq.latex"&gt;\mathbf{D} = \nabla - iq\mathbf{A} ~~,~~D^0 = \frac{\partial}{\partial t} + iqV&lt;/pre&gt;can be written in a &lt;i&gt;Lorentz covariant&lt;/i&gt; form:&lt;br /&gt;&lt;pre lang="eq.latex"&gt;D^\mu = \partial^\mu + iqA^\mu&lt;/pre&gt;&lt;br /&gt;This allows us to write:&lt;br /&gt;&lt;pre lang="eq.latex"&gt;-iD^{\prime\mu}\psi^\prime = e^{iq\chi}(-iD^\mu \psi)&lt;/pre&gt;and it follows that an equation can involving the operator &lt;pre lang="eq.latex" style="display: inline;"&gt;\partial^\mu&lt;/pre&gt;can be made to be gauge invariant by under the combined transformations:&lt;br /&gt;&lt;pre lang="eq.latex"&gt;A^\mu \rightarrow A^{\prime\mu} = A^\mu - \partial^\mu \chi&lt;/pre&gt;&lt;pre lang="eq.latex"&gt;\psi \rightarrow \psi^\prime = e^{iq\chi}\psi&lt;/pre&gt;provided the &lt;i&gt;minimal substitution&lt;/i&gt; is also made:&lt;br /&gt;&lt;pre lang="eq.latex"&gt;\partial^\mu \rightarrow D^\mu = \partial^\mu + iqA^\mu&lt;/pre&gt;&lt;br /&gt;This provides a simple mechanism to get the wave equation for a particle in an electromagnetic field from the equation for a free particle - by making the above substitution. This forms the basis of the &lt;i&gt;gauge principle&lt;/i&gt;, i.e. the form of an interaction is determined by an insistence on &lt;i&gt;local gauge invariance&lt;/i&gt;.&lt;br /&gt;&lt;br /&gt;That's enough for now; next time we'll move on to study the Klein-Gordon equation for relativistic spin-zero particles.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4470666517647633822-6634528429815837702?l=physical-thought.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://physical-thought.blogspot.com/feeds/6634528429815837702/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4470666517647633822&amp;postID=6634528429815837702' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4470666517647633822/posts/default/6634528429815837702'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4470666517647633822/posts/default/6634528429815837702'/><link rel='alternate' type='text/html' href='http://physical-thought.blogspot.com/2010/03/gauge-invariance-in-quantum-mechanics.html' title='Gauge Invariance in Quantum Mechanics'/><author><name>Andrew J. Bennieston</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://bp2.blogger.com/_zi39n2uYgqg/R3f879w2IHI/AAAAAAAAAAY/IsPK0LU5Duc/S220/avatar.png'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4470666517647633822.post-3687269350841606974</id><published>2010-02-08T15:01:00.000Z</published><updated>2010-02-08T15:01:50.928Z</updated><category scheme='http://www.blogger.com/atom/ns#' term='random'/><category scheme='http://www.blogger.com/atom/ns#' term='python'/><category scheme='http://www.blogger.com/atom/ns#' term='programming'/><title type='text'>Farscape Intro Randomiser</title><content type='html'>While watching Farscape Season 2, Episode 4 (Crackers Don't Matter) last night, I wrote a Python script to randomise elements of the Farscape intro. Here's an example:&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;i&gt;My name is John Crichton, a wormhole hit and I got shot through a military commander. Now I'm lost in some distant part of the universe on an insane radiation wave, full of escaped prisoners. I'm being hunted by a living ship. Doing everything I can. I'm just looking for a way home.&lt;/i&gt;&lt;/div&gt;&lt;div&gt;&lt;i&gt;&lt;br /&gt;&lt;/i&gt;&lt;/div&gt;&lt;div&gt;&lt;i&gt;&lt;br /&gt;&lt;/i&gt;&lt;/div&gt;&lt;br /&gt;&lt;pre name="code" class="python"&gt;import random&lt;br /&gt;&lt;br /&gt;adjectives = [&lt;br /&gt; ('insane', 'an'),&lt;br /&gt; ('living', 'a'),&lt;br /&gt; ('escaped', 'an'),&lt;br /&gt; ]&lt;br /&gt;&lt;br /&gt;nouns = [&lt;br /&gt; ('ship', 'a'),&lt;br /&gt; ('radiation wave', 'a'),&lt;br /&gt; ('military commander', 'a'),&lt;br /&gt; ('prisoner', 'a'),&lt;br /&gt; ('wormhole', 'a')&lt;br /&gt; ]&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;parts = []&lt;br /&gt;parts.append(random.choice(nouns))&lt;br /&gt;nouns.remove(parts[0])&lt;br /&gt;parts.append(random.choice(nouns))&lt;br /&gt;nouns.remove(parts[1])&lt;br /&gt;parts.append(random.choice(adjectives))&lt;br /&gt;adjectives.remove(parts[2])&lt;br /&gt;parts.append(random.choice(nouns))&lt;br /&gt;nouns.remove(parts[3])&lt;br /&gt;parts.append(random.choice(adjectives))&lt;br /&gt;adjectives.remove(parts[4])&lt;br /&gt;parts.append(random.choice(nouns))&lt;br /&gt;nouns.remove(parts[5])&lt;br /&gt;parts.append(random.choice(adjectives))&lt;br /&gt;adjectives.remove(parts[6])&lt;br /&gt;parts.append(random.choice(nouns))&lt;br /&gt;nouns.remove(parts[7])&lt;br /&gt;&lt;br /&gt;result = 'My name is John Crichton, '&lt;br /&gt;result += parts[0][1] + ' ' + parts[0][0]&lt;br /&gt;result += " hit and I got shot through "&lt;br /&gt;result += parts[1][1] + ' ' + parts[1][0]&lt;br /&gt;result += ". Now I'm lost in some distant part of the universe on "&lt;br /&gt;result += parts[2][1] + ' ' + parts[2][0] + ' ' &lt;br /&gt;result += parts[3][0]&lt;br /&gt;result += ", full of "&lt;br /&gt;result += parts[4][0] + ' ' + parts[5][0] + 's'&lt;br /&gt;result += ". I'm being hunted by "&lt;br /&gt;result += parts[6][1] + ' ' + parts[6][0] + ' ' + parts[7][0]&lt;br /&gt;result += ". Doing everything I can. I'm just looking for a way home."&lt;br /&gt;&lt;br /&gt;print result&lt;br /&gt;&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4470666517647633822-3687269350841606974?l=physical-thought.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://physical-thought.blogspot.com/feeds/3687269350841606974/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4470666517647633822&amp;postID=3687269350841606974' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4470666517647633822/posts/default/3687269350841606974'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4470666517647633822/posts/default/3687269350841606974'/><link rel='alternate' type='text/html' href='http://physical-thought.blogspot.com/2010/02/farscape-intro-randomiser.html' title='Farscape Intro Randomiser'/><author><name>Andrew J. Bennieston</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://bp2.blogger.com/_zi39n2uYgqg/R3f879w2IHI/AAAAAAAAAAY/IsPK0LU5Duc/S220/avatar.png'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4470666517647633822.post-7436029006701043015</id><published>2010-01-26T17:05:00.001Z</published><updated>2010-01-26T17:06:04.279Z</updated><category scheme='http://www.blogger.com/atom/ns#' term='food'/><title type='text'>Orange Tiramisu</title><content type='html'>&lt;span style="font-family: 'Lucida Grande';"&gt;At the weekend I made (yet another) tiramisu. This time, though, I used orange juice &amp;amp; Cointreau instead of coffee &amp;amp; amaretto, and I grated the zest of one orange into the egg &amp;amp; mascarpone mix. The result was very tasty - the orange and the dark chocolate grated on top worked well together. I recommend it.&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4470666517647633822-7436029006701043015?l=physical-thought.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://physical-thought.blogspot.com/feeds/7436029006701043015/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4470666517647633822&amp;postID=7436029006701043015' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4470666517647633822/posts/default/7436029006701043015'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4470666517647633822/posts/default/7436029006701043015'/><link rel='alternate' type='text/html' href='http://physical-thought.blogspot.com/2010/01/orange-tiramisu.html' title='Orange Tiramisu'/><author><name>Andrew J. Bennieston</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://bp2.blogger.com/_zi39n2uYgqg/R3f879w2IHI/AAAAAAAAAAY/IsPK0LU5Duc/S220/avatar.png'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4470666517647633822.post-6027845563027328198</id><published>2009-12-23T22:19:00.001Z</published><updated>2009-12-23T22:20:00.895Z</updated><category scheme='http://www.blogger.com/atom/ns#' term='food'/><title type='text'>Tiramisu</title><content type='html'>It seems I make Tiramisu every Christmas. My recipe is pretty much the same as the one in Delia Smith's Winter collection, but where she uses three egg yolks and two egg whites, I also use the remaining egg white. Oh, and amaretto instead of dark rum. Delia's recipe is available at&amp;nbsp;&lt;a href="http://www.deliaonline.com/recipes/cuisine/european/italian/tiramisu.html"&gt;http://www.deliaonline.com/recipes/cuisine/european/italian/tiramisu.html&lt;/a&gt;&lt;br /&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;I either make this in a single large flat dish, or in cocktail glasses. This year I made it in cocktail glasses - to be served individually. They're topped with chopped dark chocolate and a generous dusting of cocoa powder.&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://2.bp.blogspot.com/_zi39n2uYgqg/SzKXTYrArJI/AAAAAAAAARs/0Fu5-kOe_8w/s1600-h/DSC00740.JPG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" src="http://2.bp.blogspot.com/_zi39n2uYgqg/SzKXTYrArJI/AAAAAAAAARs/0Fu5-kOe_8w/s640/DSC00740.JPG" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4470666517647633822-6027845563027328198?l=physical-thought.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://physical-thought.blogspot.com/feeds/6027845563027328198/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4470666517647633822&amp;postID=6027845563027328198' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4470666517647633822/posts/default/6027845563027328198'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4470666517647633822/posts/default/6027845563027328198'/><link rel='alternate' type='text/html' href='http://physical-thought.blogspot.com/2009/12/tiramisu.html' title='Tiramisu'/><author><name>Andrew J. Bennieston</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://bp2.blogger.com/_zi39n2uYgqg/R3f879w2IHI/AAAAAAAAAAY/IsPK0LU5Duc/S220/avatar.png'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://2.bp.blogspot.com/_zi39n2uYgqg/SzKXTYrArJI/AAAAAAAAARs/0Fu5-kOe_8w/s72-c/DSC00740.JPG' height='72' width='72'/><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4470666517647633822.post-705295482507633091</id><published>2009-12-08T21:38:00.000Z</published><updated>2009-12-08T21:38:41.202Z</updated><category scheme='http://www.blogger.com/atom/ns#' term='lorentz'/><category scheme='http://www.blogger.com/atom/ns#' term='gauge theories'/><category scheme='http://www.blogger.com/atom/ns#' term='special relativity'/><category scheme='http://www.blogger.com/atom/ns#' term='particle physics'/><category scheme='http://www.blogger.com/atom/ns#' term='electrodynamics'/><category scheme='http://www.blogger.com/atom/ns#' term='physics'/><title type='text'>Lorentz-Covariant and Gauge-Invariant Electrodynamics</title><content type='html'>Over a year ago I started a series of blog posts aimed at describing quantum field theory, beginning with Lagrangian mechanics and working all the way up. It's been a while since I made any posts in that series. Indeed, the last post was a roadmap of sorts; a list of the topics still to be covered.&lt;br /&gt;&lt;br /&gt;The roadmap hinted that the next step is a relativistic description of electromagnetism. Actually, what we really want to do is describe electromagnetism as a gauge theory. That is, a theory which is gauge invariant. By the end of this post, what we mean by &lt;i&gt;gauge invariance&lt;/i&gt; will become obvious.&lt;br /&gt;&lt;br /&gt;So, here goes.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Maxwell's Equations&lt;/b&gt;&lt;br /&gt;Any treatment of electromagnetism must start with Maxwell's equations, presented below.&lt;br /&gt;&lt;br /&gt;&lt;pre lang="eq.latex"&gt;(1)\,\,\,\,\,\nabla\cdot\mathbf{E} = \rho_{em}&lt;/pre&gt;&lt;br /&gt;&lt;pre lang="eq.latex"&gt;(2)\,\,\,\,\,\nabla\times\mathbf{E} = -\frac{\partial\mathbf{B}}{\partial t}&lt;/pre&gt;&lt;br /&gt;&lt;pre lang="eq.latex"&gt;(3)\,\,\,\,\,\nabla\cdot\mathbf{B} = 0&lt;/pre&gt;&lt;br /&gt;&lt;pre lang="eq.latex"&gt;(4)\,\,\,\,\,\nabla\times\mathbf{B} = \mathbf{j}_{em}&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;Here, &lt;pre lang="eq.latex" style="display: inline;"&gt;\rho_{em}&lt;/pre&gt;and &lt;pre lang="eq.latex" style="display: inline;"&gt;\mathbf{j}_{em}&lt;/pre&gt;are the electric charge density and electric current density, respectively, and we are working in Heaviside-Lorentz units. The densities act as the sources of the electric and magnetic fields.&lt;br /&gt;&lt;br /&gt;Taking the divergence of (4) leads to a problem; the continuity equation for electric charge states that&lt;br /&gt;&lt;pre lang="eq.latex"&gt;(5)\,\,\,\,\,\frac{\partial \rho}{\partial t} + \nabla\cdot\mathbf{j} = 0&lt;/pre&gt;&lt;br /&gt;(note that I will omit the "em" subscript on the densities from now on).&lt;br /&gt;&lt;br /&gt;Since &lt;pre lang="eq.latex"&gt;\nabla\cdot\nabla\times\mathbf{B} = 0\Rightarrow\nabla\cdot\mathbf{j}=0&lt;/pre&gt;&lt;br /&gt;This is only true when the charge density does not vary with time. In general, Ampere's law must be modified to be&lt;br /&gt;&lt;pre lang="eq.latex"&gt;(6)\,\,\,\,\,\nabla\times\mathbf{B}=\mathbf{j}+\frac{\partial\mathbf{E}}{\partial t}&lt;/pre&gt;&lt;br /&gt;This is now consistent with (5), the continuity equation.&lt;br /&gt;&lt;br /&gt;The continuity equation states that the rate of change of charge in some volume is due entirely to the flux of current through its surface. That is to say, &lt;i&gt;electric charge is conserved&lt;/i&gt;. Since this volume can be made arbitrarily small, we can say that electric charge is &lt;i&gt;locally&lt;/i&gt; conserved. This means that we can't balance things out by having a negative charge appear out of nowhere, as long as a positive charge is made the other side of the universe (or a negative charge disappears on the other side of the universe); this conservation law has to apply on an arbitrarily small scale.&lt;br /&gt;&lt;br /&gt;We can introduce the vector potential &lt;pre lang="eq.latex" style="display: inline;"&gt;A_\mu&lt;/pre&gt;in place of the fields &lt;b&gt;E&lt;/b&gt; and &lt;b&gt;B&lt;/b&gt;:&lt;br /&gt;&lt;pre lang="eq.latex"&gt;(7)\,\,\,\,\,\mathbf{B}=\nabla\times\mathbf{A}&lt;/pre&gt;&lt;br /&gt;&lt;pre lang="eq.latex"&gt;(8)\,\,\,\,\,\mathbf{E}=-\nabla V-\frac{\partial \mathbf{A}}{\partial t}&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;This defines the three-vector potential &lt;b&gt;A&lt;/b&gt;, and the scalar potential &lt;b&gt;V&lt;/b&gt; (sometimes called the electrostatic potential, and sometimes denoted &lt;pre lang="eq.latex" style="display: inline;"&gt;\phi&lt;/pre&gt;. Equations (2) and (3) are then satisified automatically.&lt;br /&gt;&lt;br /&gt;The gauge invariance of electromagnetism is based on the fact that, for a given &lt;b&gt;E&lt;/b&gt; and &lt;b&gt;B&lt;/b&gt;, the equations above do not uniquely determine &lt;b&gt;A&lt;/b&gt; and V. In fact, one can apply transformations to &lt;b&gt;A&lt;/b&gt; and V which leave &lt;b&gt;E&lt;/b&gt; and &lt;b&gt;B&lt;/b&gt; completely unchanged; and therefore leave all of the physics unchanged. These are known as &lt;i&gt;gauge transformations&lt;/i&gt;, and the invariance of Maxwell's equations under these transformations is known as &lt;i&gt;gauge invariance&lt;/i&gt;&lt;br /&gt;&lt;br /&gt;We are free to change &lt;b&gt;A&lt;/b&gt; as follows;&lt;br /&gt;&lt;pre lang="eq.latex"&gt;(9)\,\,\,\,\,\mathbf{A}\rightarrow \mathbf{A}^\prime = \mathbf{A}+\nabla\chi&lt;/pre&gt;&lt;br /&gt;where &lt;pre lang="eq.latex" style="display: inline;"&gt;\chi&lt;/pre&gt;is an arbitrary scalar function. Since &lt;pre lang="eq.latex" style="display: inline;"&gt;\nabla\times(\nabla\chi) = 0&lt;/pre&gt;, this does not change &lt;b&gt;B&lt;/b&gt;.&lt;br /&gt;&lt;br /&gt;To preserve &lt;b&gt;E&lt;/b&gt; when making the above transformation, we must simultaneously transform the scalar potential V:&lt;br /&gt;&lt;pre lang="eq.latex"&gt;(10)\,\,\,\,\,V\rightarrow V^\prime=V-\frac{\partial\chi}{\partial t}&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;The transformations (9) and (10) can be written in a single expression using the four-potential,&lt;br /&gt;&lt;pre lang="eq.latex"&gt;(11)\,\,\,\,\,A^\mu = (V, \mathbf{A})&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;Note now that the differential operators,&lt;br /&gt;&lt;pre lang="eq.latex"&gt;(12)\,\,\,\,\,\left(\frac{\partial}{\partial t}, -\nabla\right)&lt;/pre&gt;&lt;br /&gt;form a four-vector operator &lt;pre lang="eq.latex" style="display: inline;"&gt;\partial^\mu&lt;/pre&gt;. The gauge transformation can then be specified by:&lt;br /&gt;&lt;pre lang="eq.latex"&gt;(13)\,\,\,\,\,A^\mu \rightarrow A^{\prime\mu} = A^\mu - d^\mu\chi&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;Maxwell's equations can be written in a &lt;i&gt;manifestly Lorentz covariant&lt;/i&gt; form (meaning, they have the same form under Lorentz transformations) using the four-current:&lt;br /&gt;&lt;pre lang="eq.latex"&gt;(14)\,\,\,\,\,\mathbf{j}^\mu = (\rho,\mathbf{j})&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;The continuity equation can then be written:&lt;br /&gt;&lt;pre lang="eq.latex"&gt;(15)\,\,\,\,\,\partial_\mu j^\mu = 0&lt;/pre&gt;&lt;br /&gt;which in turn allows us to write equations (1) and (6) as:&lt;br /&gt;&lt;pre lang="eq.latex"&gt;(16)\,\,\,\,\,\partial_\mu F^{\mu\nu} = j^\nu&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;The equation above introduced the &lt;i&gt;Field Strength tensor&lt;/i&gt; (or the &lt;i&gt;Faraday tensor&lt;/i&gt;),&lt;br /&gt;&lt;pre lang="eq.latex"&gt;(17)\,\,\,\,\,F^{\mu\nu}=\partial^\mu A^\nu - \partial^\nu A^\mu&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;Under a gauge transformation (13), the Faraday tensor (17) remains unchanged; it is &lt;i&gt;gauge invariant&lt;/i&gt;, and so, therefore, are Maxwell's equations in the form (16). As I already said above, Maxwell's equations are &lt;i&gt;Lorentz covariant&lt;/i&gt; in the form (16), leading to a &lt;i&gt;Lorentz covariant and Gauge invariant&lt;/i&gt; theory.&lt;br /&gt;&lt;br /&gt;Now, one can write&lt;br /&gt;&lt;pre lang="eq.latex"&gt;(18)\,\,\,\,\,\Box A^\nu - \partial^\nu(\partial_\mu A^\mu) = j^\nu&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;Equation (6) can be inferred (and indeed, was inferred by Maxwell) from the local charge conservation requirement expressed by the continuity equation (15). The field equations (16) automatically include the continuity equation. Mathematically speaking, the Faraday tensor (17) is a sort of "four-dimensional curl". This is unchanged by the gauge transformation (13), suggesting that gauge invariance in electromagnetism is related to charge conservation. The reality is a little more complicated.&lt;br /&gt;&lt;br /&gt;It was shown in 1949 by Wigner that the principle that no physical quantity can depend on the absolute value of the electrostatic potential V, combined with conservation of energy, implies that charge conservation holds. This relates charge and energy conservation to an invariance under the transformation of the electrostatic potential by a constant. Charge conservation alone does not require the more general space-time dependent transformation of the gauge invariance we've discussed above.&lt;br /&gt;&lt;br /&gt;Changing the electrostatic potential by a constant amount is an example of a &lt;i&gt;global&lt;/i&gt; transformation. Invariance under this global transformation is related to the conservation of electric charge, but it is not sufficient to obtain all of electromagnetism. Instead, we must impose a &lt;i&gt;local&lt;/i&gt; change in the electrostatic potential V (the time-derivative term in (10), which is &lt;i&gt;compensated&lt;/i&gt; by a simultaneous change in the vector potential &lt;b&gt;A&lt;/b&gt;, leaving Maxwell's equations ultimately unchanged. By including these magnetic effects, the global invariance under a change in V, related to conservation of electric charge, can be extended to a local invariance.&lt;br /&gt;&lt;br /&gt;The concept of local gauge invariance is important for the development of quantum field theory in subsequent posts. Next time, a tour of gauge invariance in quantum mechanics, and the &lt;i&gt;gauge principle&lt;/i&gt;.&lt;br /&gt;&lt;br /&gt;Much of this post was based on Chapter 3 of Aitchison &amp;amp; Hey (Gauge Theories in Particle Physics, 3rd Edition, Vol. I - From Relativistic Quantum Mechanics to QED). It is a book I strongly recommend purchasing if you have an interest in quantum field theory. The second volume discusses QCD and Electroweak theory, and is another good purchase.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4470666517647633822-705295482507633091?l=physical-thought.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://physical-thought.blogspot.com/feeds/705295482507633091/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4470666517647633822&amp;postID=705295482507633091' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4470666517647633822/posts/default/705295482507633091'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4470666517647633822/posts/default/705295482507633091'/><link rel='alternate' type='text/html' href='http://physical-thought.blogspot.com/2009/12/lorentz-covariant-and-gauge-invariant.html' title='Lorentz-Covariant and Gauge-Invariant Electrodynamics'/><author><name>Andrew J. Bennieston</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://bp2.blogger.com/_zi39n2uYgqg/R3f879w2IHI/AAAAAAAAAAY/IsPK0LU5Duc/S220/avatar.png'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4470666517647633822.post-1592070289017586041</id><published>2009-12-06T16:42:00.002Z</published><updated>2009-12-23T22:21:16.950Z</updated><category scheme='http://www.blogger.com/atom/ns#' term='food'/><title type='text'>Mince Pies</title><content type='html'>&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://2.bp.blogspot.com/_zi39n2uYgqg/SxvgjDEEG1I/AAAAAAAAARk/PYrcFPfeyIQ/s1600-h/mince-pies.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" src="http://2.bp.blogspot.com/_zi39n2uYgqg/SxvgjDEEG1I/AAAAAAAAARk/PYrcFPfeyIQ/s400/mince-pies.jpg" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;Here's my recipe for mince pies. I don't tend to make the mincemeat myself; get a decent jar from a supermarket. You'll need about 400g for 12 mince pies, and you can always pour a little Cognac into it to add a bit of a kick!&lt;br /&gt;&lt;br /&gt;175g (6oz) Plain flour&lt;br /&gt;40g (1.5oz) White fat (I use White flora in place of lard)&lt;br /&gt;40g (1.5oz) Unsalted butter&lt;br /&gt;Pinch of salt&lt;br /&gt;Cold water&lt;br /&gt;&lt;br /&gt;The key to making pastry is to keep everything as cold as possible. Use the fats straight from the fridge. Add the fats to the flour in a large bowl, then run your hands under the cold tap for a while and dry them. Next, using only your fingertips to avoid transferring too much heat into the pastry, rub the fats into the flour.&lt;br /&gt;&lt;br /&gt;Once this is done, add the very cold water, a small amount at a time, and use a fork to mix it into the flour. What you want is for the pastry to just come together and leave the bowl clean, without being too wet or sticky. Add the water slowly and stop as soon as the pastry holds together.&lt;br /&gt;&lt;br /&gt;Put the lump of pastry into a plastic bag, and leave in the fridge for at least half an hour. This helps to cool the pastry down again after working with it.&lt;br /&gt;&lt;br /&gt;When you're ready to make the pies, preheat the oven to 200C (190 for a fan oven) and grease the tins. You can either use separate small tins, or one of those tins with twelve hollowed out bits, more commonly used for muffins and yorkshire puddings!&lt;br /&gt;&lt;br /&gt;Flour the work surface, your hands, and the rolling pin, then roll out the pastry, being sure to roll in all directions (turn the pastry round as you roll to do this). Then, use large pastry cutters (or the top of a pint glass) to cut out 12 bases. Put these into the tins and gently push them into shape. Fill with mincemeat to just below the level of the pastry.&lt;br /&gt;&lt;br /&gt;If necessary, re-roll your pastry and use a smaller cutter (or a smaller glass!) to cut the lids. Place the lids on top of the pies, glaze with a little milk, and make a small hole in the centre using a pair of scissors or a barbecue skewer.&lt;br /&gt;&lt;br /&gt;Bake at 200C for 25 to 30 minutes. Allow to cool in the tins for 10 to 15 mins before transferring to a wire cooling rack. To serve, dust with icing sugar.&lt;br /&gt;&lt;br /&gt;The mince pies will keep in an airtight container for about a week, or can be frozen (but don't dust with icing sugar until you're ready to serve them!)&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4470666517647633822-1592070289017586041?l=physical-thought.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://physical-thought.blogspot.com/feeds/1592070289017586041/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4470666517647633822&amp;postID=1592070289017586041' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4470666517647633822/posts/default/1592070289017586041'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4470666517647633822/posts/default/1592070289017586041'/><link rel='alternate' type='text/html' href='http://physical-thought.blogspot.com/2009/12/mince-pies.html' title='Mince Pies'/><author><name>Andrew J. Bennieston</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://bp2.blogger.com/_zi39n2uYgqg/R3f879w2IHI/AAAAAAAAAAY/IsPK0LU5Duc/S220/avatar.png'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://2.bp.blogspot.com/_zi39n2uYgqg/SxvgjDEEG1I/AAAAAAAAARk/PYrcFPfeyIQ/s72-c/mince-pies.jpg' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4470666517647633822.post-7535138649522476360</id><published>2009-11-09T17:05:00.001Z</published><updated>2009-11-14T16:22:02.801Z</updated><category scheme='http://www.blogger.com/atom/ns#' term='projects'/><category scheme='http://www.blogger.com/atom/ns#' term='python'/><category scheme='http://www.blogger.com/atom/ns#' term='programming'/><category scheme='http://www.blogger.com/atom/ns#' term='make'/><title type='text'>makefilter: Colour for make output</title><content type='html'>I wrote a Python program today which runs make (and passes command-line arguments to it) and filters the output, adding ANSI/VT100 colour codes to highlight certain parts.&lt;br /&gt;&lt;br /&gt;The goal was twofold; to distinguish different parts of the gcc / g++ command, and to distinguish commands from error messages and other output lines.&lt;br /&gt;&lt;br /&gt;The highlighting is performed by directly emitting the VT100 control sequences. Eventually I might change this to use ncurses / terminfo / something more portable, but for now this will have to do.&lt;br /&gt;&lt;br /&gt;There's a webpage relating to the program at &lt;a href="http://www.warwick.ac.uk/%7Ephrebd/makefilter.html"&gt;http://www.warwick.ac.uk/~phrebd/makefilter.html&lt;/a&gt; and a screenshot below (the same screenshot as on the webpage!)&lt;br /&gt;&lt;br /&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://2.bp.blogspot.com/_zi39n2uYgqg/SvhLNee6uzI/AAAAAAAAAQw/vbGTv7WZMYA/s1600-h/make-highlighter.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;br /&gt;&lt;/a&gt;&lt;a href="http://2.bp.blogspot.com/_zi39n2uYgqg/Sv7Y6_UqCNI/AAAAAAAAAQ4/09tI9ga1UwI/s1600-h/makefilter.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" src="http://2.bp.blogspot.com/_zi39n2uYgqg/Sv7Y6_UqCNI/AAAAAAAAAQ4/09tI9ga1UwI/s400/makefilter.png" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;I'm aware of several other projects to achieve similar effects. The closest is pretty_make.py, available at &lt;a href="http://phil.freehackers.org/pretty-make/index.html"&gt;http://phil.freehackers.org/pretty-make/index.html&lt;/a&gt;. There is also colorgcc, &lt;a href="http://schlueters.de/colorgcc.html"&gt;http://schlueters.de/colorgcc.html&lt;/a&gt;, which does a similar thing for gcc error messages (the down side is it's written in Perl).&lt;br /&gt;&lt;br /&gt;&lt;span style="color: #0c343d;"&gt;Update: Version 1.3 of makefilter has been released today (Saturday November 14, 2009). This includes a few minor improvements and bugfixes. The screenshot above has also been updated accordingly.&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4470666517647633822-7535138649522476360?l=physical-thought.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://physical-thought.blogspot.com/feeds/7535138649522476360/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4470666517647633822&amp;postID=7535138649522476360' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4470666517647633822/posts/default/7535138649522476360'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4470666517647633822/posts/default/7535138649522476360'/><link rel='alternate' type='text/html' href='http://physical-thought.blogspot.com/2009/11/makefilter-colour-for-make-output.html' title='makefilter: Colour for make output'/><author><name>Andrew J. Bennieston</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://bp2.blogger.com/_zi39n2uYgqg/R3f879w2IHI/AAAAAAAAAAY/IsPK0LU5Duc/S220/avatar.png'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://2.bp.blogspot.com/_zi39n2uYgqg/Sv7Y6_UqCNI/AAAAAAAAAQ4/09tI9ga1UwI/s72-c/makefilter.png' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4470666517647633822.post-1785859709199425943</id><published>2009-09-29T21:06:00.001+01:00</published><updated>2009-09-29T21:07:26.090+01:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='visual studio'/><category scheme='http://www.blogger.com/atom/ns#' term='c++'/><category scheme='http://www.blogger.com/atom/ns#' term='unit testing'/><category scheme='http://www.blogger.com/atom/ns#' term='autotools'/><category scheme='http://www.blogger.com/atom/ns#' term='programming'/><category scheme='http://www.blogger.com/atom/ns#' term='google'/><category scheme='http://www.blogger.com/atom/ns#' term='make'/><title type='text'>Google C++ Testing Framework</title><content type='html'>I was looking around for C++ unit testing frameworks, earlier. I'd already disqualified CppUnit and Boost.Test for various reasons, so I started out with Wikipedia's &lt;a href="http://en.wikipedia.org/wiki/List_of_unit_testing_frameworks"&gt;List of Unit Testing Frameworks&lt;/a&gt;, from which I quickly gravitated towards the &lt;a href="http://code.google.com/p/googletest/"&gt;Google C++ Testing Framework&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;Google Test (as it is apparently known, for short) is a decent stab at a unit testing framework. Admittedly, I use Gmail, Blogger, and Google Maps, and I'm generally quite a fan of all things Google, but still, I had already thrown out two unit test frameworks based on their unsuitability (if that is a word). Google Test looks to be well designed, based on the xUnit concept, and provides a lot of nice stuff, all of which seems to be well documented. What sold it, for me, was the multitude of build systems. Google Test builds under XCode, Visual Studio, GNU make, autotools, Scons, and probably some other things I forgot already.&lt;br /&gt;&lt;br /&gt;The build system was my primary reason for discarding CppUnit; I wanted something I could integrate neatly into an existing project's build system, and not have to introduce an extra system dependency on a unit test framework. So, since Google Test appeared to have the most flexible build system, I started to incorporate it into my project.&lt;br /&gt;&lt;br /&gt;At that point, I went home, so I have yet to see how well it works for actual testing, but if it's as good as the build integration, it will be a pleasure to work with!&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4470666517647633822-1785859709199425943?l=physical-thought.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://physical-thought.blogspot.com/feeds/1785859709199425943/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4470666517647633822&amp;postID=1785859709199425943' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4470666517647633822/posts/default/1785859709199425943'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4470666517647633822/posts/default/1785859709199425943'/><link rel='alternate' type='text/html' href='http://physical-thought.blogspot.com/2009/09/google-c-testing-framework.html' title='Google C++ Testing Framework'/><author><name>Andrew J. Bennieston</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://bp2.blogger.com/_zi39n2uYgqg/R3f879w2IHI/AAAAAAAAAAY/IsPK0LU5Duc/S220/avatar.png'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4470666517647633822.post-1564661204158904691</id><published>2009-09-23T12:46:00.004+01:00</published><updated>2009-09-23T12:55:59.623+01:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='c++'/><category scheme='http://www.blogger.com/atom/ns#' term='unit testing'/><category scheme='http://www.blogger.com/atom/ns#' term='programming'/><title type='text'>Bad Examples</title><content type='html'>I realised today (while browsing examples in the CppUnit Cookbook, documentation for the CppUnit Unit Testing framework) that there exists, on the Internet, a plague of incredibly bad examples.&lt;br /&gt;&lt;br /&gt;Allow me to explain. I'm trying to figure out how to use CppUnit, and I'm trying to do it quickly. Like most programmers, I go straight for the examples, because I can understand code very quickly, without having to read a lot of text explaining the history of, and relationship between, various unit testing frameworks.&lt;br /&gt;&lt;br /&gt;The code examples look good at first glance - they tell me everything I need to know about how to use the framework; I just derive from a certain class, implement a couple of methods, and stick it all into another class to run the tests.&lt;br /&gt;&lt;br /&gt;Ah, but wait. The first example, the one with the class I'm supposed to derive from, doesn't tell me which header to include. I don't know where the CppUnit::TestCase class is declared, and I'm going to have to hunt through the documentation (or grep the source) to find out, because at no point does it give a complete example of this stuff, with the headers!&lt;br /&gt;&lt;br /&gt;Now, I understand that headers often get in the way of demonstrating a single point, and that writers often leave out common headers to save space and to make it clearer what is going on in the example of interest. However, when the header is non-standard, and is absolutely critical to what follows, it's important to keep the include statement visible.&lt;br /&gt;&lt;br /&gt;Ok, rant over. Now I'm going to go back to hunting for the declaration of CppUnit::UnitTest.&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(153, 0, 0);"&gt;Edit: Crisis over. I dug deeper into the documentation, eventually finding a class hierarchy with information about the headers in which things are defined, but still, having complete examples would've saved me a lot of time.&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4470666517647633822-1564661204158904691?l=physical-thought.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://physical-thought.blogspot.com/feeds/1564661204158904691/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4470666517647633822&amp;postID=1564661204158904691' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4470666517647633822/posts/default/1564661204158904691'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4470666517647633822/posts/default/1564661204158904691'/><link rel='alternate' type='text/html' href='http://physical-thought.blogspot.com/2009/09/bad-examples.html' title='Bad Examples'/><author><name>Andrew J. Bennieston</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://bp2.blogger.com/_zi39n2uYgqg/R3f879w2IHI/AAAAAAAAAAY/IsPK0LU5Duc/S220/avatar.png'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4470666517647633822.post-1360072662654043090</id><published>2009-09-21T23:52:00.003+01:00</published><updated>2009-09-22T00:01:04.415+01:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='pinot noir'/><category scheme='http://www.blogger.com/atom/ns#' term='wine'/><category scheme='http://www.blogger.com/atom/ns#' term='france'/><title type='text'>Wine: Domaine de la Vougeraie 'Les Petits Noizons' 2006 (Pommard)</title><content type='html'>A strong offering from Bourgogne, this 100% Pinot Noir has a dark red-brown colour. Initially it does not offer much by way of fragrance, but after leaving to the air for a little, strong notes of plum, cherry, melon and blackcurrant practically leap out of the glass.&lt;br /&gt;&lt;br /&gt;The first taste similarly reveals little but a smooth, velvet character. Subsequent tastings open up the robust, fruity character of this wine, exhibiting many rich berry flavours; blackberry and raspberry in particular. There's a very smooth finish with a hint of very dark chocolate.&lt;br /&gt;&lt;br /&gt;The entire experience is a velvety smooth, rich and full wine. There appears to be a very slight nutty character both to the taste and fragrance, though this may be a mental inference from the name, refering to a walnut plantation.&lt;br /&gt;&lt;br /&gt;In all, an incredible wine, with a very long finish. It would go well with rare steak, lamb or other red meats. Avoid strong flavours such as cheese, which would detract from the fullness of this wine.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4470666517647633822-1360072662654043090?l=physical-thought.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://physical-thought.blogspot.com/feeds/1360072662654043090/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4470666517647633822&amp;postID=1360072662654043090' title='3 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4470666517647633822/posts/default/1360072662654043090'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4470666517647633822/posts/default/1360072662654043090'/><link rel='alternate' type='text/html' href='http://physical-thought.blogspot.com/2009/09/wine-domaine-de-la-vougeraie-les-petits.html' title='Wine: Domaine de la Vougeraie &apos;Les Petits Noizons&apos; 2006 (Pommard)'/><author><name>Andrew J. Bennieston</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://bp2.blogger.com/_zi39n2uYgqg/R3f879w2IHI/AAAAAAAAAAY/IsPK0LU5Duc/S220/avatar.png'/></author><thr:total>3</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4470666517647633822.post-9153529875652417186</id><published>2009-07-15T11:50:00.002+01:00</published><updated>2009-07-15T11:56:41.594+01:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='python'/><category scheme='http://www.blogger.com/atom/ns#' term='programming'/><title type='text'>Reversing Lines In A File</title><content type='html'>As is often the case, an interesting little text manipulation task came up in the office today; given a file containing lines of text, reverse it (i.e. put the last line first, the penultimate line second, etc.)&lt;br /&gt;&lt;br /&gt;I have a feeling there's a neat little command-line utility that already does this (but can't remember what it is...), but my mind soon went to a short Python script. Here's my first stab at this:&lt;br /&gt;&lt;pre name="code" class="python"&gt;&lt;br /&gt;#!/usr/bin/env python&lt;br /&gt;import sys&lt;br /&gt;&lt;br /&gt;lines = []&lt;br /&gt;for line in open(sys.argv[1]):&lt;br /&gt; lines.append(line.strip())&lt;br /&gt;&lt;br /&gt;lines.reverse()&lt;br /&gt;for line in lines:&lt;br /&gt; print line&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;After this, I tried to shorten it a bit. Putting the lines into a list could be done nicely with a list comprehension,&lt;br /&gt;&lt;pre name="code" class="python"&gt;&lt;br /&gt;#!/usr/bin/env python&lt;br /&gt;import sys&lt;br /&gt;&lt;br /&gt;lines = [line.strip() for line in open(sys.argv[1])]&lt;br /&gt;&lt;br /&gt;lines.reverse()&lt;br /&gt;for line in lines:&lt;br /&gt; print line&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;Finally, I discovered the &lt;span style="color: rgb(0, 102, 0);"&gt;reversed()&lt;/span&gt; function, which allows you to create reverse iterators for any Python sequence. Here's where the list comprehension and Python's iteration stuff really comes into its own, leading to a wonderful two-liner (not counting the module import and the #!)&lt;br /&gt;&lt;br /&gt;&lt;pre name="code" class="python"&gt;&lt;br /&gt;#!/usr/bin/env python&lt;br /&gt;import sys&lt;br /&gt;for line in reversed([line.strip() for line in open(sys.argv[1])]):&lt;br /&gt; print line&lt;br /&gt;&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4470666517647633822-9153529875652417186?l=physical-thought.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://physical-thought.blogspot.com/feeds/9153529875652417186/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4470666517647633822&amp;postID=9153529875652417186' title='6 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4470666517647633822/posts/default/9153529875652417186'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4470666517647633822/posts/default/9153529875652417186'/><link rel='alternate' type='text/html' href='http://physical-thought.blogspot.com/2009/07/reversing-lines-in-file.html' title='Reversing Lines In A File'/><author><name>Andrew J. Bennieston</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://bp2.blogger.com/_zi39n2uYgqg/R3f879w2IHI/AAAAAAAAAAY/IsPK0LU5Duc/S220/avatar.png'/></author><thr:total>6</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4470666517647633822.post-812279802709088468</id><published>2009-06-20T19:54:00.002+01:00</published><updated>2009-06-20T20:01:51.684+01:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='chile'/><category scheme='http://www.blogger.com/atom/ns#' term='merlot'/><category scheme='http://www.blogger.com/atom/ns#' term='wine'/><title type='text'>Wine: Santa Rita Merlot Reserva 2007</title><content type='html'>This merlot from Chile's Maipo valley has all the hallmarks of a decent Bordeaux. It has a wonderful ruby-red colour and rich plum aromas with a sweet, decadent note. The robust taste carries strong blackcurrant flavours with undertones of plum and blackberry. A smooth finish rounds off this classic Chilean offering. Strong and alcoholic, this wine is warming and has a good kick to it.&lt;br /&gt;&lt;br /&gt;Drink alone (that is, without food, not without other people) or with food that will stand up to the strength of this wine; steak, blue cheese, mildly spiced or high-garlic foods.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4470666517647633822-812279802709088468?l=physical-thought.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://physical-thought.blogspot.com/feeds/812279802709088468/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4470666517647633822&amp;postID=812279802709088468' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4470666517647633822/posts/default/812279802709088468'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4470666517647633822/posts/default/812279802709088468'/><link rel='alternate' type='text/html' href='http://physical-thought.blogspot.com/2009/06/wine-santa-rita-merlot-reserva-2007.html' title='Wine: Santa Rita Merlot Reserva 2007'/><author><name>Andrew J. Bennieston</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://bp2.blogger.com/_zi39n2uYgqg/R3f879w2IHI/AAAAAAAAAAY/IsPK0LU5Duc/S220/avatar.png'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4470666517647633822.post-3303251941694039946</id><published>2009-06-17T17:47:00.003+01:00</published><updated>2009-06-17T17:48:51.721+01:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='cabernet sauvignon'/><category scheme='http://www.blogger.com/atom/ns#' term='chile'/><category scheme='http://www.blogger.com/atom/ns#' term='wine'/><title type='text'>Wine: Vistasur Cabernet Sauvignon 2007</title><content type='html'>This Chilean Cabernet has a rich cherry aroma and a deep red colour. It tastes light and smooth, with notes of ripe summer berries.The finish is powerful yet fleeting. Goes well with blue cheese!&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4470666517647633822-3303251941694039946?l=physical-thought.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://physical-thought.blogspot.com/feeds/3303251941694039946/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4470666517647633822&amp;postID=3303251941694039946' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4470666517647633822/posts/default/3303251941694039946'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4470666517647633822/posts/default/3303251941694039946'/><link rel='alternate' type='text/html' href='http://physical-thought.blogspot.com/2009/06/wine-vistasur-cabernet-sauvignon-2007.html' title='Wine: Vistasur Cabernet Sauvignon 2007'/><author><name>Andrew J. Bennieston</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://bp2.blogger.com/_zi39n2uYgqg/R3f879w2IHI/AAAAAAAAAAY/IsPK0LU5Duc/S220/avatar.png'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4470666517647633822.post-7362482555983552669</id><published>2009-06-12T22:51:00.003+01:00</published><updated>2009-06-12T22:57:25.758+01:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='sauvignon blanc'/><category scheme='http://www.blogger.com/atom/ns#' term='chile'/><category scheme='http://www.blogger.com/atom/ns#' term='wine'/><title type='text'>Wine: Vistasur Sauvignon Blanc 2008</title><content type='html'>I had this wonderful Chilean white with salmon (and again with tuna). Chilled in the fridge, it was refreshing after warm June days.&lt;br /&gt;&lt;br /&gt;The colour is delicate and clear with a hint of gold, and the fresh fruity aromas rise from the glass. There's a definite peach scent, with something that reminds me of citrus blossom. The taste is also fruity, again with prominent peach flavours. I also got a definite citrus note from the taste, which I initially pinned as lemon, then changed my mind to lime, then back to lemon again. It is a crisp, dry wine with a light finish, leaving the mouth refreshed.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4470666517647633822-7362482555983552669?l=physical-thought.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://physical-thought.blogspot.com/feeds/7362482555983552669/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4470666517647633822&amp;postID=7362482555983552669' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4470666517647633822/posts/default/7362482555983552669'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4470666517647633822/posts/default/7362482555983552669'/><link rel='alternate' type='text/html' href='http://physical-thought.blogspot.com/2009/06/wine-vistasur-sauvignon-blanc-2008.html' title='Wine: Vistasur Sauvignon Blanc 2008'/><author><name>Andrew J. Bennieston</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://bp2.blogger.com/_zi39n2uYgqg/R3f879w2IHI/AAAAAAAAAAY/IsPK0LU5Duc/S220/avatar.png'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4470666517647633822.post-3607377342455677557</id><published>2009-06-06T19:13:00.004+01:00</published><updated>2009-06-09T18:26:41.519+01:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='chile'/><category scheme='http://www.blogger.com/atom/ns#' term='carmenere'/><category scheme='http://www.blogger.com/atom/ns#' term='wine'/><title type='text'>Wine: Cono Sur Carmenere 2008</title><content type='html'>(My first stab at a wine review. In my efforts to remain neutral, I didn't read the label before writing. However, I do have something of a predilection for Chilean reds).&lt;br /&gt;&lt;br /&gt;The first thing that struck me about this wine is the vibrant purple-red colour, indicating a young wine (of course, the 2008 vintage was a big clue here!) After that, the aromas; plummy richness with a hint of autumn berries. The wine has a very smooth, full-bodied taste, with the characteristic Chilean warmth; hints of spice. The taste lingers, giving the wine a wonderfully long finish, which can best be described only as sublime.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4470666517647633822-3607377342455677557?l=physical-thought.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://physical-thought.blogspot.com/feeds/3607377342455677557/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4470666517647633822&amp;postID=3607377342455677557' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4470666517647633822/posts/default/3607377342455677557'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4470666517647633822/posts/default/3607377342455677557'/><link rel='alternate' type='text/html' href='http://physical-thought.blogspot.com/2009/06/wine-cono-sur-carmenere-2008.html' title='Wine: Cono Sur Carmenere 2008'/><author><name>Andrew J. Bennieston</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://bp2.blogger.com/_zi39n2uYgqg/R3f879w2IHI/AAAAAAAAAAY/IsPK0LU5Duc/S220/avatar.png'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4470666517647633822.post-7388819045718581273</id><published>2009-06-01T16:48:00.004+01:00</published><updated>2009-06-01T16:53:57.402+01:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='c++'/><category scheme='http://www.blogger.com/atom/ns#' term='projects'/><category scheme='http://www.blogger.com/atom/ns#' term='python'/><category scheme='http://www.blogger.com/atom/ns#' term='programming'/><title type='text'>STLSearch</title><content type='html'>I almost don't want to post this, since it'll inevitably spawn a number of misinformed, misguided and generally miserable comments. Oh well.&lt;br /&gt;&lt;br /&gt;Today I wrote a Python program called STLSearch. It allows you to quickly bring up the C++ standard library documentation (courtesy of &lt;a href="http://www2.roguewave.com/support/docs/sourcepro/edition9/html/stdlibref/II.html"&gt;Rogue Wave&lt;/a&gt;) for a standard library class or header. There is more information &lt;a href="http://www.warwick.ac.uk/%7Ephrebd/stlsearch.html"&gt;here&lt;/a&gt; and it can be downloaded &lt;a href="http://www.warwick.ac.uk/%7Ephrebd/stlsearch.py"&gt;here.&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;As I said on the detailed page, I know it's bad to call the C++ standard library the "STL", but I wanted a nice snappy name for the program. StandardLibrarySearch.py just doesn't sound so good. So if you don't like it, tough luck.&lt;br /&gt;&lt;br /&gt;Also, I'm aware that this is probably completely irrelevant, reinventing the wheel, has been done a million times before, integrated with bigger and better things, is a part of everyone's favourite development environment, etc. etc. I don't care. I find this useful, as I do most of my programming in vim, and I am publishing it in the hope that someone else might find it useful too. If you don't have anything nice to say, don't say anything at all.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4470666517647633822-7388819045718581273?l=physical-thought.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://physical-thought.blogspot.com/feeds/7388819045718581273/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4470666517647633822&amp;postID=7388819045718581273' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4470666517647633822/posts/default/7388819045718581273'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4470666517647633822/posts/default/7388819045718581273'/><link rel='alternate' type='text/html' href='http://physical-thought.blogspot.com/2009/06/stlsearch.html' title='STLSearch'/><author><name>Andrew J. Bennieston</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://bp2.blogger.com/_zi39n2uYgqg/R3f879w2IHI/AAAAAAAAAAY/IsPK0LU5Duc/S220/avatar.png'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4470666517647633822.post-8299448225340562949</id><published>2009-06-01T11:53:00.007+01:00</published><updated>2009-06-01T17:09:44.350+01:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='c++'/><category scheme='http://www.blogger.com/atom/ns#' term='g++'/><category scheme='http://www.blogger.com/atom/ns#' term='gcc'/><category scheme='http://www.blogger.com/atom/ns#' term='programming'/><category scheme='http://www.blogger.com/atom/ns#' term='icc'/><title type='text'>GCC vs. ICC: Error Messages</title><content type='html'>Here's an error message I was recently confronted with from GCC (g++, actually):&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(204, 0, 0);"&gt;&lt;/span&gt;&lt;span style="color: rgb(204, 0, 0);"&gt;g++ -I. -Wall -O2 -Wextra -Werror -std=c++98 -pedantic-errors -Wfatal-errors -Wwrite-strings -ftrapv -fno-merge-constants -fno-nonansi-builtins -fno-gnu-keywords -fstrict-aliasing   -c -o HitMap.o HitMap.cpp&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(204, 0, 0);"&gt;HitMap.cpp: In function ‘std::ostream&amp;amp; KDTree::operator&amp;lt;&amp;lt;(std::ostream&amp;amp;, const KDTree::HitMap&amp;amp;)’:&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(204, 0, 0);"&gt;HitMap.cpp:12: error: no match for ‘operator&amp;lt;&amp;lt;’ in ‘std::operator&amp;lt;&amp;lt; [with _Traits = std::char_traits&amp;lt;char&amp;gt;](((std::basic_ostream&amp;lt;char, std::char_traits&amp;lt;char&amp;gt; &amp;gt;&amp;amp;)((std::ostream*)KDTree::operator&amp;lt;&amp;lt;(((std::ostream&amp;amp;)((std::ostream*)ost)), ((const KDTree::HitPoint&amp;amp;)(&amp;amp; i.std::_Rb_tree_const_iterator&amp;lt;_Tp&amp;gt;::operator-&amp;gt; [with _Tp = std::pair&amp;lt;const KDTree::HitPoint, KDTree::HitInfo&amp;gt;]()-&amp;gt;std::pair&amp;lt;const KDTree::HitPoint, KDTree::HitInfo&amp;gt;::first))))), ((const char*)": ")) &amp;lt;&amp;lt; i.std::_Rb_tree_const_iterator&amp;lt;_Tp&amp;gt;::operator-&amp;gt; [with _Tp = std::pair&amp;lt;const KDTree::HitPoint, KDTree::HitInfo&amp;gt;]()-&amp;gt;std::pair&amp;lt;const KDTree::HitPoint, KDTree::HitInfo&amp;gt;::second’&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(204, 0, 0);"&gt;compilation terminated due to -Wfatal-errors.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;And here's ICC's (the Intel C++ compiler) take on the same error:&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(204, 0, 0);"&gt;&lt;/span&gt;&lt;span style="color: rgb(204, 0, 0);"&gt;&lt;char,&gt;icc -I. -c -o HitMap.o HitMap.cpp&lt;br /&gt;HitMap.cpp(12): error: no operator "&amp;lt;&amp;lt;" matches these operands&lt;br /&gt;        operand types are: std::basic_ostream&amp;lt;char, std::char_traits&amp;lt;char&amp;gt;&amp;gt; &amp;lt;&amp;lt; const KDTree::HitInfo&lt;br /&gt;      ost &amp;lt;&amp;lt; i-&amp;gt;first &amp;lt;&amp;lt; ": " &amp;lt;&amp;lt; i-&amp;gt;second &amp;lt;&amp;lt; ", ";&lt;br /&gt;                              ^&lt;br /&gt;&lt;br /&gt;compilation aborted for HitMap.cpp (code 2)&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;Now, the GCC error is detailed, sure. It also makes it nearly impossible to figure out, at a glance, where the actual error is (in this case, I had no operator&amp;lt;&amp;lt; defined for the HitInfo class).&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;&lt;br /&gt;The moral of the story? If you can't be bothered to decypher long, cryptic GCC errors, try ICC. Chances are, it'll be more direct.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;I wonder why GCC can't do this? Sometimes, having all that extra information is useful. Mostly, it just gets in the way. Perhaps there should be a command-line option to make gcc display more / less verbose C++ errors. (And yes, I know there are tools to filter standard library and template instantiation related errors to reduce the verbosity, and that there are a whole host of issues surrounding this, and—as I said above—the verbosity is sometimes really useful)&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;Anyway, just thought I'd make a post about this. Mostly as a distraction from having to figure out the bigger (runtime!) error in this damn program.&lt;/span&gt;&lt;/char,&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4470666517647633822-8299448225340562949?l=physical-thought.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://physical-thought.blogspot.com/feeds/8299448225340562949/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4470666517647633822&amp;postID=8299448225340562949' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4470666517647633822/posts/default/8299448225340562949'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4470666517647633822/posts/default/8299448225340562949'/><link rel='alternate' type='text/html' href='http://physical-thought.blogspot.com/2009/06/gcc-vs-icc-error-messages.html' title='GCC vs. ICC: Error Messages'/><author><name>Andrew J. Bennieston</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://bp2.blogger.com/_zi39n2uYgqg/R3f879w2IHI/AAAAAAAAAAY/IsPK0LU5Duc/S220/avatar.png'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4470666517647633822.post-6374838104779531419</id><published>2009-05-14T21:35:00.002+01:00</published><updated>2009-05-14T21:44:59.743+01:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='bash'/><title type='text'>Bash History Editing</title><content type='html'>This post sets a challenge; the goal is to come up with a bash one-liner (which can include multiple statements, pipes, etc. to arbitrary level) which removes "incriminating" lines from the .bash_history file, without looking too incriminating itself.&lt;br /&gt;&lt;br /&gt;For example, you sneak onto someone's system and type &lt;span style="color: rgb(204, 0, 0);"&gt;xhost +&lt;/span&gt; so you can run X apps on their display, but you want to hide how you worked your magic, so they can be in awe that bit longer. Of course, I don't condone such activities, but it's an interesting hypothetical. The problem is to remove the line of interest (xhost +) from the .bash_history file, without leaving something equally obvious; like &lt;span style="color: rgb(204, 0, 0);"&gt;vim .bash_history&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;One way, obviously, would be to simply run vim, then open the file within vim rather than on the command-line. I'm looking for sneakier approaches; things that will look really impressive, but almost incomprehensible, to the untrained eye. Here's my first stab at a one-liner to remove xhost + (amongst other things) from .bash_history... I'd like to see what any readers can come up with; feel free to leave your offerings in comments to this post.&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 102, 0);"&gt;VAR=".$(basename $SHELL)_h*" sed "/x.+\+/d" -i $VAR&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Rules:&lt;br /&gt;1. All offerings must be valid bash commands or sequences thereof&lt;br /&gt;2. All offerings must work when typed into a &lt;span style="font-style: italic;"&gt;single line&lt;/span&gt; on the bash prompt&lt;br /&gt;3. Nothing destructive, please; don't do anything more than remove a few lines from .bash_history&lt;br /&gt;4. While you can probably come up with a million variants on the "open it with vim" approach, these are trivial. I don't want to see those.&lt;br /&gt;5. If you're replying to someone else's comment, try to remember to treat them with the respect and decency you would expect to receive. In other words, keep things polite, and clean.&lt;br /&gt;6. The more obscure, obfuscated or oblique, the better.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4470666517647633822-6374838104779531419?l=physical-thought.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://physical-thought.blogspot.com/feeds/6374838104779531419/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4470666517647633822&amp;postID=6374838104779531419' title='3 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4470666517647633822/posts/default/6374838104779531419'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4470666517647633822/posts/default/6374838104779531419'/><link rel='alternate' type='text/html' href='http://physical-thought.blogspot.com/2009/05/bash-history-editing.html' title='Bash History Editing'/><author><name>Andrew J. Bennieston</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://bp2.blogger.com/_zi39n2uYgqg/R3f879w2IHI/AAAAAAAAAAY/IsPK0LU5Duc/S220/avatar.png'/></author><thr:total>3</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4470666517647633822.post-4129883637543757153</id><published>2009-04-17T09:02:00.003+01:00</published><updated>2009-04-17T09:27:48.787+01:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='traffic lights'/><category scheme='http://www.blogger.com/atom/ns#' term='science'/><category scheme='http://www.blogger.com/atom/ns#' term='bbc'/><title type='text'>On Traffic Lights and the BBC (Unrelated)</title><content type='html'>Today, a rant. Tomorrow, the world?&lt;br /&gt;&lt;br /&gt;A couple of weeks ago, I read &lt;a href="http://www.telegraph.co.uk/motoring/columnists/jamesmay/5113860/Appeal-for-greener-motoring.html"&gt;James May's column&lt;/a&gt; in the Telegraph Motoring section, on Saturday. In it, he mentioned the apparent increase in red traffic lights. This morning I experienced the same phenomenon; a junction which does not usually incur much of a wait was suddenly the greatest bottleneck of my journey. The lights were on red when I approached, turned green just long enough to let two cars through, then went back to red for an inordinately long amount of time. When I eventually got through, the next set of lights were, of course, also red.&lt;br /&gt;&lt;br /&gt;I wouldn't mind, but while those lights were red, I had a clear view of the road in front. Was it full of cars from other directions? No. Was there a queue as those cars filtered onto the next road? No. Was there any reason at all for the lights to be on red? &lt;span style="font-weight: bold;"&gt;No.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Meanwhile, sitting in the car, I was listening to BBC Radio 4. I'd already had the BBC News channel on the TV while I had breakfast, so I wasn't surprised to hear their story that MI5 are looking for a 'chief scientific advisor'. Fair enough.&lt;br /&gt;&lt;br /&gt;Now, &lt;span style="font-style: italic;"&gt;is anyone else getting annoyed by the BBC's tendency to sensationalise mediocre news by completely ignoring the facts (or, in this case, common sense)?&lt;/span&gt; I sure am. It happened with the LHC switch on (something I wrote about &lt;a href="http://physical-thought.blogspot.com/2008/09/on-science-in-education-and-in-media.html"&gt;here&lt;/a&gt;), and it's happening again today. The BBC, on the TV, the radio and their website (article &lt;a href="http://news.bbc.co.uk/1/hi/sci/tech/8002434.stm"&gt;here&lt;/a&gt;) open with a comparison to 'Q', the guy who produces all the gadgets for James Bond. Is this what a scientific advisor really does? No. Is this even remotely within the realm of possibility? No. Is there any justification for bringing this fantasy into a news story? &lt;span style="font-weight: bold;"&gt;No.&lt;/span&gt; Does it get the attention of the public, who know no better? &lt;span style="color: rgb(255, 0, 0);"&gt;&lt;span style="font-weight: bold;"&gt;Yes.&lt;/span&gt; &lt;span style="color: rgb(0, 0, 0);"&gt;And of course, that's all the BBC want. To hell with reporting factual news, or trying to inform the public about what scientists really do. They just want a good story.&lt;br /&gt;&lt;br /&gt;Granted, somewhere down the page of the online article, well beyond the point where most people stop reading, there's a quote from someone saying that it is unlikely the post will involve developing weapons systems for Aston Martins. Well, &lt;span style="font-style: italic;"&gt;no shit&lt;/span&gt;. What a surprise!&lt;br /&gt;&lt;br /&gt;It is this kind of 'journalism' I didn't used to expect from the BBC, but now it seems to be commonplace. Once upon a time, they reported the news. Now, I don't know what they do.&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4470666517647633822-4129883637543757153?l=physical-thought.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://physical-thought.blogspot.com/feeds/4129883637543757153/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4470666517647633822&amp;postID=4129883637543757153' title='3 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4470666517647633822/posts/default/4129883637543757153'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4470666517647633822/posts/default/4129883637543757153'/><link rel='alternate' type='text/html' href='http://physical-thought.blogspot.com/2009/04/on-traffic-lights-and-bbc-unrelated.html' title='On Traffic Lights and the BBC (Unrelated)'/><author><name>Andrew J. Bennieston</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://bp2.blogger.com/_zi39n2uYgqg/R3f879w2IHI/AAAAAAAAAAY/IsPK0LU5Duc/S220/avatar.png'/></author><thr:total>3</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4470666517647633822.post-4020391552218466676</id><published>2009-04-14T23:11:00.003+01:00</published><updated>2009-04-14T23:15:55.667+01:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='bbq'/><category scheme='http://www.blogger.com/atom/ns#' term='wine'/><category scheme='http://www.blogger.com/atom/ns#' term='food'/><title type='text'>First Barbecue!</title><content type='html'>Today marks my first barbecue of 2009; pork chops in a tomato, basil and oregano marinade, with barbecued potatoes (new potatoes, boiled first, then covered in garlic and olive oil, and finished on the barbecue, skewered) and vegetables [and of course, a nice bottle of wine—&lt;a href="http://en.wikipedia.org/wiki/Vacqueyras_AOC"&gt;Vacqueyras&lt;/a&gt;—to go with it all].&lt;br /&gt;&lt;br /&gt;Barbecued food tastes incredible, and I always enjoy this time of year, when it's warm enough and dry enough—not to mention light enough—to have a barbecue, and maybe even to eat outside!&lt;br /&gt;&lt;br /&gt;So, I thought I'd make this blog post to announce that &lt;span style="font-style: italic;"&gt;summer is on the way!&lt;/span&gt; That is all.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4470666517647633822-4020391552218466676?l=physical-thought.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://physical-thought.blogspot.com/feeds/4020391552218466676/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4470666517647633822&amp;postID=4020391552218466676' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4470666517647633822/posts/default/4020391552218466676'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4470666517647633822/posts/default/4020391552218466676'/><link rel='alternate' type='text/html' href='http://physical-thought.blogspot.com/2009/04/first-barbecue.html' title='First Barbecue!'/><author><name>Andrew J. Bennieston</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://bp2.blogger.com/_zi39n2uYgqg/R3f879w2IHI/AAAAAAAAAAY/IsPK0LU5Duc/S220/avatar.png'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4470666517647633822.post-281388768572807417</id><published>2009-03-16T15:29:00.003Z</published><updated>2009-03-16T15:35:16.181Z</updated><category scheme='http://www.blogger.com/atom/ns#' term='pdf'/><title type='text'>PDF and the Internet</title><content type='html'>I have become increasingly annoyed of late with the number of people (including supposedly professional organisations) who publish documents on the Internet in formats not accessible to a large number of people. I refer, of course, to the prevalence of MS Word and PowerPoint documents online.&lt;br /&gt;&lt;br /&gt;The solution is simple, the word `portable' is even in the name of the Portable Document Format. It is also easy to make PDF files these days; either directly from Microsoft Office using their Save as PDF extension, using Acrobat to convert files to PDF, or using PDF Printers and similar. There really is no excuse for providing read-only information in formats other than PDF, online.&lt;br /&gt;&lt;br /&gt;The advantages to PDF are numerous; the primary advantage being convenience! I can read PDF files directly from my web browser with the Adobe Reader plugin. Furthermore, I can open and print PDF files on Windows, Linux and Mac OS X. The same cannot be said of MS Word documents, or PowerPoint presentations.&lt;br /&gt;&lt;br /&gt;I could almost understand if the people putting such documents online were individuals with few resources, but when large, professional organisations provide only Word documents as a source of information, you have to wonder how professional they really are.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4470666517647633822-281388768572807417?l=physical-thought.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://physical-thought.blogspot.com/feeds/281388768572807417/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4470666517647633822&amp;postID=281388768572807417' title='3 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4470666517647633822/posts/default/281388768572807417'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4470666517647633822/posts/default/281388768572807417'/><link rel='alternate' type='text/html' href='http://physical-thought.blogspot.com/2009/03/pdf-and-internet.html' title='PDF and the Internet'/><author><name>Andrew J. Bennieston</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://bp2.blogger.com/_zi39n2uYgqg/R3f879w2IHI/AAAAAAAAAAY/IsPK0LU5Duc/S220/avatar.png'/></author><thr:total>3</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4470666517647633822.post-7117037565699427776</id><published>2009-03-15T17:47:00.003Z</published><updated>2009-03-15T17:58:01.035Z</updated><category scheme='http://www.blogger.com/atom/ns#' term='reconstruction'/><category scheme='http://www.blogger.com/atom/ns#' term='lhc'/><category scheme='http://www.blogger.com/atom/ns#' term='particle physics'/><category scheme='http://www.blogger.com/atom/ns#' term='programming'/><category scheme='http://www.blogger.com/atom/ns#' term='PhD'/><category scheme='http://www.blogger.com/atom/ns#' term='physics'/><title type='text'>Update</title><content type='html'>Well it has been almost a month since I wrote anything here. In fact, my last post was a day before I spent the weekend in Oxford and London, back in February.&lt;br /&gt;&lt;br /&gt;Since then, I've mostly been working, going to the gym, and sleeping. I'm currently working on tracking and reconstruction, a part of which involves creating a piece of software in C++ to follow a particle track (parametrised by start coordinates, end coordinates and track energy or dE/dx) through a 3D volume made up of small cubic cells, depositing energy in each cell; the amount of which depends on the length of the track through that cell.&lt;br /&gt;&lt;br /&gt;If you're thinking that sounds a lot like GEANT, you're right. Only it doesn't need to be as complicated as GEANT. Still, it doesn't work very well right now, and I spent the best part of last week chasing down bugs (actually, chasing bugs round in a circle!)&lt;br /&gt;&lt;br /&gt;Other than that, I'm reading a lot about track reconstruction, pattern recognition, track finding and fitting approaches from the visual scans performed in bubble chambers to the Kalman Filter and the great number of approaches it has spawned. I need to look at the LHC track finding (well, ATLAS and CMS, where they have a very high density of tracks, less so LHCb I think) a little more than I already have, too.&lt;br /&gt;&lt;br /&gt;Outside of the office, I've really only had time to cook, eat and sleep. Such is the life of a Ph.D. student!&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4470666517647633822-7117037565699427776?l=physical-thought.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://physical-thought.blogspot.com/feeds/7117037565699427776/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4470666517647633822&amp;postID=7117037565699427776' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4470666517647633822/posts/default/7117037565699427776'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4470666517647633822/posts/default/7117037565699427776'/><link rel='alternate' type='text/html' href='http://physical-thought.blogspot.com/2009/03/update.html' title='Update'/><author><name>Andrew J. Bennieston</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://bp2.blogger.com/_zi39n2uYgqg/R3f879w2IHI/AAAAAAAAAAY/IsPK0LU5Duc/S220/avatar.png'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4470666517647633822.post-3618551292661202547</id><published>2009-02-19T14:30:00.003Z</published><updated>2009-02-19T14:35:25.184Z</updated><category scheme='http://www.blogger.com/atom/ns#' term='latex'/><title type='text'>Writing Scientific Documents Using LaTeX: Updated</title><content type='html'>I submitted a fifth edition (5/E) of `Writing Scientific Documents Using LaTeX` to CTAN yesterday (and another version today which fixes a couple of minor mistakes in the examples given).&lt;br /&gt;&lt;br /&gt;As usual, the document and associated files can be found at:&lt;br /&gt;&lt;a href="http://www.ctan.org/tex-archive/info/intro-scientific/"&gt;http://www.ctan.org/tex-archive/info/intro-scientific/&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4470666517647633822-3618551292661202547?l=physical-thought.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://physical-thought.blogspot.com/feeds/3618551292661202547/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4470666517647633822&amp;postID=3618551292661202547' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4470666517647633822/posts/default/3618551292661202547'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4470666517647633822/posts/default/3618551292661202547'/><link rel='alternate' type='text/html' href='http://physical-thought.blogspot.com/2009/02/writing-scientific-documents-using.html' title='Writing Scientific Documents Using LaTeX: Updated'/><author><name>Andrew J. Bennieston</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://bp2.blogger.com/_zi39n2uYgqg/R3f879w2IHI/AAAAAAAAAAY/IsPK0LU5Duc/S220/avatar.png'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4470666517647633822.post-262448521080411392</id><published>2009-02-12T10:58:00.005Z</published><updated>2009-02-12T17:08:38.676Z</updated><category scheme='http://www.blogger.com/atom/ns#' term='programming'/><title type='text'>Programming Languages</title><content type='html'>It seems that I "collect" programming languages! Not content with learning a single language, or one of each "kind", I play with a number of different languages and try to find the best (or most interesting) one for any given task.&lt;br /&gt;&lt;br /&gt;If I'm creating something that has to be done reasonably quickly, I stick with the ones I know best: C, C++, Python and PHP. Otherwise, while Python dominates my recreational programming, I can often be found exploring other languages.&lt;br /&gt;&lt;br /&gt;Here's a list of languages I know (to some extent) and could write useful software in:&lt;br /&gt;&lt;ul&gt;&lt;li&gt;C&lt;/li&gt;&lt;li&gt;C++&lt;/li&gt;&lt;li&gt;Python&lt;/li&gt;&lt;li&gt;PHP&lt;/li&gt;&lt;li&gt;Bash (if you count shell scripts)&lt;/li&gt;&lt;li&gt;Perl (to a lesser extent, and mostly write-only)&lt;/li&gt;&lt;li&gt;SQL (Well it is a 'language'...)&lt;/li&gt;&lt;li&gt;BASIC (Oh yeah!)&lt;/li&gt;&lt;li&gt;JavaScript&lt;/li&gt;&lt;li&gt;Mathematica (A language, according to Wikipedia's List of programming languages)&lt;/li&gt;&lt;li&gt;Maple (Also in the List of programming languages)&lt;/li&gt;&lt;li&gt;sed&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;And now the ones I have played with and could probably write something useful in, given a good source of documentation:&lt;br /&gt;&lt;ul&gt;&lt;li&gt;Java&lt;/li&gt;&lt;li&gt;C#&lt;br /&gt;&lt;/li&gt;&lt;li&gt;Visual Basic (Eugh!)&lt;/li&gt;&lt;li&gt;bc&lt;/li&gt;&lt;li&gt;LabVIEW&lt;/li&gt;&lt;li&gt;Tcl&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;And the languages I've looked at and written a few short trial programs in and intend to learn properly:&lt;br /&gt;&lt;ul&gt;&lt;li&gt;Common Lisp&lt;/li&gt;&lt;li&gt;IA32 ASM&lt;/li&gt;&lt;li&gt;Pike&lt;/li&gt;&lt;li&gt;Ruby&lt;/li&gt;&lt;li&gt;Smalltalk&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;And languages I've had some exposure to but have no intention of using (if I can help it):&lt;br /&gt;&lt;ul&gt;&lt;li&gt;Fortran&lt;/li&gt;&lt;li&gt;Pascal&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;And finally the languages I haven't touched, but want to learn:&lt;br /&gt;&lt;ul&gt;&lt;li&gt;Objective Caml&lt;/li&gt;&lt;li&gt;Haskell&lt;/li&gt;&lt;li&gt;Erlang&lt;/li&gt;&lt;li&gt;Lua&lt;/li&gt;&lt;li&gt;PostScript (Yes, really.)&lt;br /&gt;&lt;/li&gt;&lt;li&gt;Scheme&lt;/li&gt;&lt;/ul&gt;The lists of languages I've played with but want to learn more of, or haven't touched and want to learn from scratch are substantially larger than the list of languages I already know or could use with a little documentation, so I have a lot of "work" ahead of me!&lt;br /&gt;&lt;br /&gt;EDIT: I've added a list of markup languages I know, in response to a comment on the original post.&lt;br /&gt;&lt;br /&gt;Markup Languages:&lt;br /&gt;&lt;ul&gt;&lt;li&gt;HTML / XHTML&lt;/li&gt;&lt;li&gt;XML&lt;/li&gt;&lt;li&gt;CSS (Does this count?)&lt;/li&gt;&lt;li&gt;TeX / LaTeX&lt;/li&gt;&lt;li&gt;bbCode (Technically markup, right?)&lt;/li&gt;&lt;/ul&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4470666517647633822-262448521080411392?l=physical-thought.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://physical-thought.blogspot.com/feeds/262448521080411392/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4470666517647633822&amp;postID=262448521080411392' title='6 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4470666517647633822/posts/default/262448521080411392'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4470666517647633822/posts/default/262448521080411392'/><link rel='alternate' type='text/html' href='http://physical-thought.blogspot.com/2009/02/programming-languages.html' title='Programming Languages'/><author><name>Andrew J. Bennieston</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://bp2.blogger.com/_zi39n2uYgqg/R3f879w2IHI/AAAAAAAAAAY/IsPK0LU5Duc/S220/avatar.png'/></author><thr:total>6</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4470666517647633822.post-682490338081113692</id><published>2009-02-11T21:46:00.002Z</published><updated>2009-02-11T21:53:21.280Z</updated><category scheme='http://www.blogger.com/atom/ns#' term='nmap tutorial'/><category scheme='http://www.blogger.com/atom/ns#' term='latex'/><category scheme='http://www.blogger.com/atom/ns#' term='hevea'/><title type='text'>Hevea</title><content type='html'>Back in 2006 I converted my nmap tutorial to LaTeX, then realised that I wanted an HTML version of it too. This turned out to be rather a difficult goal to achieve, as the only software I could find to do this at the time was latex2html.&lt;br /&gt;&lt;br /&gt;latex2html generates multi-page output, and doesn't do too well with some of the more complicated LaTeX features. Even though I tried to keep the nmap tutorial quite simple, latex2html struggled.&lt;br /&gt;&lt;br /&gt;For a single-page version, I wrote a couple of Python scripts to convert LaTeX to bbCode (used on forum systems) and to convert bbCode to HTML. The output was pretty horrific, but it sufficed.&lt;br /&gt;&lt;br /&gt;Now, three years on, I've lost my python scripts, and I wanted to regenerate the single-page HTML version; so I Googled "latex to html".&lt;br /&gt;&lt;br /&gt;A few clicks later I was at the &lt;a href="http://hevea.inria.fr/"&gt;HeVeA&lt;/a&gt; homepage; a LaTeX to HTML translator written in Objective Caml.&lt;br /&gt;&lt;br /&gt;Moments later, I'd downloaded a Slackware 12.0 package for ocaml from &lt;a href="http://www.linuxpackages.net"&gt;linuxpackages.net&lt;/a&gt;, installed it, built HeVeA, and modified my nmap-tutorial makefile to run HeVeA on the TeX file.&lt;br /&gt;&lt;br /&gt;My first surprise was that it all just worked; no errors and only one warning produced by HeVeA. The second surprise was that the output looks so good!&lt;br /&gt;&lt;br /&gt;So, if you want to generate HTML from LaTeX files, I can highly recommend taking a look at HeVeA. Furthermore, I've added yet another language (Ocaml) to my list of languages to learn (LISP is still top of that list...)&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4470666517647633822-682490338081113692?l=physical-thought.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://physical-thought.blogspot.com/feeds/682490338081113692/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4470666517647633822&amp;postID=682490338081113692' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4470666517647633822/posts/default/682490338081113692'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4470666517647633822/posts/default/682490338081113692'/><link rel='alternate' type='text/html' href='http://physical-thought.blogspot.com/2009/02/hevea.html' title='Hevea'/><author><name>Andrew J. Bennieston</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://bp2.blogger.com/_zi39n2uYgqg/R3f879w2IHI/AAAAAAAAAAY/IsPK0LU5Duc/S220/avatar.png'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4470666517647633822.post-7642298512323503147</id><published>2009-02-09T14:43:00.002Z</published><updated>2009-02-09T14:50:45.753Z</updated><category scheme='http://www.blogger.com/atom/ns#' term='nmap tutorial'/><title type='text'>Nmap-Tutorial.com: Site Down</title><content type='html'>At the end of last week, I took down the server hosting the nmap-tutorial.com website. At this time, I have no plans to put it back up, since I cannot justify the cost of running such a server.&lt;br /&gt;&lt;br /&gt;I would like to find a home for the Nmap Tutorial, but I'm not prepared to pay for it any more. I'm looking into one or two possibilities, but for the time being the site will remain down. If you'd like to offer to host it, by all means get in touch!&lt;br /&gt;&lt;br /&gt;In the mean time, the tutorial is still available as a thread on &lt;a href="http://www.security-forums.com/viewtopic.php?t=7872"&gt;Security-Forums.com&lt;/a&gt; and a number of other mirrors.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4470666517647633822-7642298512323503147?l=physical-thought.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://physical-thought.blogspot.com/feeds/7642298512323503147/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4470666517647633822&amp;postID=7642298512323503147' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4470666517647633822/posts/default/7642298512323503147'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4470666517647633822/posts/default/7642298512323503147'/><link rel='alternate' type='text/html' href='http://physical-thought.blogspot.com/2009/02/nmap-tutorialcom-site-down.html' title='Nmap-Tutorial.com: Site Down'/><author><name>Andrew J. Bennieston</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://bp2.blogger.com/_zi39n2uYgqg/R3f879w2IHI/AAAAAAAAAAY/IsPK0LU5Duc/S220/avatar.png'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4470666517647633822.post-8758084600612203816</id><published>2009-02-06T11:38:00.002Z</published><updated>2009-02-06T11:43:20.087Z</updated><category scheme='http://www.blogger.com/atom/ns#' term='mathematica'/><title type='text'>Mathematica Home Edition</title><content type='html'>It seems that Wolfram have created a version of Mathematica 7 targeted at home users. It cannot be used for commercial, nonprofit, government or academic purposes, and comes with a price tag of $295.&lt;br /&gt;&lt;br /&gt;From their press release,&lt;br /&gt;&lt;br /&gt;&lt;em style="color: rgb(0, 0, 153);"&gt;Mathematica Home Edition&lt;/em&gt;&lt;span style="color: rgb(0, 0, 153);"&gt; contains the full functionality of the  recently released &lt;/span&gt;&lt;em style="color: rgb(0, 0, 153);"&gt;Mathematica&lt;/em&gt;&lt;span style="color: rgb(0, 0, 153);"&gt; 7, which integrates powerful  technologies including image processing, parallel computation, and rich  data on astronomy, geography, life sciences, and more. &lt;/span&gt;&lt;em style="color: rgb(0, 0, 153);"&gt;Mathematica  Home Edition&lt;/em&gt;&lt;span style="color: rgb(0, 0, 153);"&gt; also includes &lt;/span&gt;&lt;em style="color: rgb(0, 0, 153);"&gt;Mathematica&lt;/em&gt;&lt;span style="color: rgb(0, 0, 153);"&gt;'s innovative user  interfaces that make it possible for new users to achieve high-impact  results, like dynamic applications, instantly. &lt;/span&gt;&lt;br /&gt;&lt;br /&gt;I thought I'd post this in case anyone wants to check it out, but my thoughts are that the license is somewhat limiting; it'd be useful for personal projects and not much else, and is still prohibitively expensive for such use!&lt;br /&gt;&lt;br /&gt;Anyone who really needs the functionality of Mathematica is likely to have access to a site-license or a huge budget, but if you don't, and you really want to play with Mathematica (as long as it's not for academic, commercial, nonprofit or government use; which doesn't leave much!) then the Home Edition is a "mere" $295.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4470666517647633822-8758084600612203816?l=physical-thought.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://physical-thought.blogspot.com/feeds/8758084600612203816/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4470666517647633822&amp;postID=8758084600612203816' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4470666517647633822/posts/default/8758084600612203816'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4470666517647633822/posts/default/8758084600612203816'/><link rel='alternate' type='text/html' href='http://physical-thought.blogspot.com/2009/02/mathematica-home-edition.html' title='Mathematica Home Edition'/><author><name>Andrew J. Bennieston</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://bp2.blogger.com/_zi39n2uYgqg/R3f879w2IHI/AAAAAAAAAAY/IsPK0LU5Duc/S220/avatar.png'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4470666517647633822.post-5128629335678143824</id><published>2009-02-03T15:09:00.004Z</published><updated>2009-02-03T15:12:34.554Z</updated><category scheme='http://www.blogger.com/atom/ns#' term='linux'/><category scheme='http://www.blogger.com/atom/ns#' term='ghostscript'/><category scheme='http://www.blogger.com/atom/ns#' term='bash'/><category scheme='http://www.blogger.com/atom/ns#' term='pdf'/><category scheme='http://www.blogger.com/atom/ns#' term='programming'/><title type='text'>Merging PDF Files in Linux</title><content type='html'>The following bash script uses gs (GhostScript) to merge several PDFs into one file. The basic command is&lt;br /&gt;&lt;br /&gt;gs -dBATCH -dNOPAUSE -q -sDEVICE=pdfwrite -sOutputFile=out.pdf in1.pdf in2.pdf ...&lt;br /&gt;&lt;br /&gt;To use the bash script, chmod +x it and run as&lt;br /&gt;./mergepdf output.pdf in1.pdf in2.pdf ...&lt;br /&gt;(In other words, it just saves you remembering all the gs options!)&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;#!/bin/bash&lt;br /&gt;&lt;br /&gt;output=$1&lt;br /&gt;echo "Output: $output"&lt;br /&gt;shift&lt;br /&gt;echo "Input: $@"&lt;br /&gt;echo -n "Merging PDFs..."&lt;br /&gt;gs -dBATCH -dNOPAUSE -q -sDEVICE=pdfwrite -sOutputFile=$output $@&lt;br /&gt;echo " Done."&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;Note that this script does no error checking; in particular it doesn't make sure you passed it any options, and it doesn't give you any hints as to how to use it. These are fairly simple things to add, though, so I'll leave them as an exercise to the reader!&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4470666517647633822-5128629335678143824?l=physical-thought.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://physical-thought.blogspot.com/feeds/5128629335678143824/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4470666517647633822&amp;postID=5128629335678143824' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4470666517647633822/posts/default/5128629335678143824'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4470666517647633822/posts/default/5128629335678143824'/><link rel='alternate' type='text/html' href='http://physical-thought.blogspot.com/2009/02/merging-pdf-files-in-linux.html' title='Merging PDF Files in Linux'/><author><name>Andrew J. Bennieston</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://bp2.blogger.com/_zi39n2uYgqg/R3f879w2IHI/AAAAAAAAAAY/IsPK0LU5Duc/S220/avatar.png'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4470666517647633822.post-3411111435091415506</id><published>2009-02-01T17:08:00.005Z</published><updated>2009-02-01T17:42:01.942Z</updated><category scheme='http://www.blogger.com/atom/ns#' term='c++'/><category scheme='http://www.blogger.com/atom/ns#' term='programming'/><category scheme='http://www.blogger.com/atom/ns#' term='c'/><title type='text'>Constness</title><content type='html'>Whenever I talk to someone about C++, the topic of &lt;span style="font-style: italic;"&gt;const&lt;/span&gt; qualifiers almost inevitably arises. It seems many people don't understand what the &lt;span style="font-style: italic;"&gt;const&lt;/span&gt; qualifier does, and with good reason; &lt;span style="font-style: italic;"&gt;const&lt;/span&gt; can mean different things in different places. Fundamentally, though, it means that you're telling the compiler "this cannot be changed, it's a constant".&lt;br /&gt;&lt;br /&gt;So, I'm now going to go through almost every 'type' of constness you're likely to encounter, explaining what it does, and perhaps why, in the context of several C++ declarations.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;const int a = 4;&lt;/span&gt;&lt;br /&gt;Here, the const means that the variable a (assigned the value 4) cannot have its value changed; that is, once 4, it's always 4. Subsequent attempts to assign a new value will be compile-time errors. This is perhaps the most basic form of constness, and is relatively uncommon as it has limited use beyond defining numerical constants, string literals, etc.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;const int *b = &amp;amp;a;&lt;/span&gt;&lt;br /&gt;This form of const declares a pointer to a &lt;span style="font-style: italic;"&gt;const int&lt;/span&gt;. That means that the value pointed to is const, and you &lt;span style="font-style: italic;"&gt;cannot&lt;/span&gt; change it using, say&lt;br /&gt;&lt;span style="color: rgb(0, 102, 0);"&gt;*b = 5;&lt;/span&gt;&lt;br /&gt;However, the pointer itself remains non-const, so you could do something like:&lt;br /&gt;&lt;span style="color: rgb(0, 102, 0);"&gt;const int c;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 102, 0);"&gt;b = &amp;c;&lt;/span&gt;&lt;br /&gt;which is valid, and makes b point to c instead of a. Furthermore, you can make a pointer to a const int point to an integer which isn't implicitly const. All this means is that you cannot change the value of the integer through the pointer (even though you can change it directly). Consider this code:&lt;br /&gt;&lt;span style="color: rgb(0, 102, 0);"&gt;int a = 4;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 102, 0);"&gt;const int* b = &amp;amp;a;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 102, 0);"&gt;*b = 6; // Compile error!&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 102, 0);"&gt;a = 6; // Perfectly acceptable&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;int * const b = &amp;amp;a;&lt;/span&gt;&lt;br /&gt;Given code such as,&lt;br /&gt;&lt;span style="color: rgb(0, 102, 0);"&gt;int a = 4;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 102, 0);"&gt;int c = 6;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 102, 0);"&gt;int * const b = &amp;a;&lt;/span&gt;&lt;br /&gt;then b is a const pointer to a (non-const) int. You can change the value of the integer pointed to, e.g.&lt;br /&gt;&lt;span style="color: rgb(0, 102, 0);"&gt;*b = 7; // sets a to 7&lt;/span&gt;&lt;br /&gt;but you &lt;span style="font-style: italic;"&gt;cannot&lt;/span&gt; change where b points:&lt;br /&gt;&lt;span style="color: rgb(0, 102, 0);"&gt;b = &amp;amp;c; // Compile error!&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;This is an important distinction! a const before the asterisk makes the type &lt;span style="font-style: italic;"&gt;pointed to&lt;/span&gt; const; a const after the asterisk makes the &lt;span style="font-style: italic;"&gt;pointer itself&lt;/span&gt; const.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;const int * const b = &amp;amp;a;&lt;/span&gt;&lt;br /&gt;e.g.&lt;br /&gt;&lt;span style="color: rgb(0, 102, 0);"&gt;int a = 4;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 102, 0);"&gt;int c = 6;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 102, 0);"&gt;const int * const b = &amp;amp;a;&lt;/span&gt;&lt;br /&gt;Here, the value of the variable pointed to by b cannot be changed through b, and the location b points to also cannot be changed:&lt;br /&gt;&lt;span style="color: rgb(0, 102, 0);"&gt;*b = 5; // Compile error!&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 102, 0);"&gt;b = &amp;amp;c; // Compile error!&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;const member function&lt;/span&gt;&lt;br /&gt;Consider the following class:&lt;br /&gt;&lt;span style="color: rgb(0, 0, 153);"&gt;class Employee {&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 153);"&gt;  public:&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 153);"&gt;    Employee(const std::string&amp;amp; name) : e_name(name) {};&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 153);"&gt;    const std::string&amp;amp; getName() const { return e_name; };&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 153);"&gt;    void setName(const std::string&amp;amp; name) { e_name = name; };&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 153);"&gt;  private:&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 153);"&gt;    std::string name;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 153);"&gt;};&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Note that the const qualifier is used liberally here. Note also that references are used extensively. Although this post isn't really about references, I'll mention them briefly in what follows.&lt;br /&gt;&lt;br /&gt;Now, we can construct an Employee object as follows:&lt;br /&gt;&lt;span style="color: rgb(0, 102, 0);"&gt;Employee me("Andrew");&lt;/span&gt;&lt;br /&gt;we could also construct it using something like&lt;br /&gt;&lt;span style="color: rgb(0, 102, 0);"&gt;std::string name = "Andrew";&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 102, 0);"&gt;Employee me(name);&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Notice that the constructor takes a reference to a const std::string object. The reference is so that we avoid copying the string in the function call, and the const ensures the caller that we're not going to change it. Here, all we want to do is construct our internal e_name string from the one passed in. If a reference (or pointer) was not used, we'd copy the string once when making the function call, then copy it again when constructing the internal e_name string. The &lt;span style="font-style: italic;"&gt;const&lt;/span&gt; qualifier makes sure we can't forget what we're doing, and try to directly modify the string passed in by reference. That'd cause a compile-time error.&lt;br /&gt;&lt;br /&gt;Next, we'll take a look at getName(). This returns a reference to a const std::string. Again, the reference is because we have the name stored internally, so we want to avoid making copies by letting other people use this directly. Of course, we still want to have control over what changes can be made to the e_name variable, so we return a const reference, preventing anyone "outside" the class from modifying the string! Finally, notice that there is an additional &lt;span style="font-style: italic;"&gt;const&lt;/span&gt; qualifier after the function name and parameter list (but before the function body)? This tells the compiler that this member function does not (indeed, cannot) modify any of the member variables. This is useful for two reasons:&lt;br /&gt;&lt;br /&gt;1. get... methods should be logically const, and shouldn't change the internal state of the class (the exception is reference-counted resource handles, but see the mutable keyword!)&lt;br /&gt;&lt;br /&gt;2. It allows us to call such a method if we only have a const Employee, or a reference/pointer to a const Employee.&lt;br /&gt;&lt;br /&gt;You see, if you have a const object, the only methods (member functions) you can call on it are those marked const! This is the const that comes after the function declaration but before the definition of the body of the function. Of course, usually you'd separate the declaration into a header file and the definition into a source file, so the distinction is clear. Here, to conserve space, I wrote the definitions inline.&lt;br /&gt;&lt;br /&gt;And, last but not least, notice the setName() function. It takes a reference to a const std::string, for the same reasons as the constructor. It doesn't have to return anything, but we can't mark this member function as const, because it changes the internal state -- it changes the value of e_name!&lt;br /&gt;&lt;br /&gt;Thus concludes our tour of constness. Note that you can combine return types, argument types and the const modifier to a member function, resulting in a very large number of occurrences of the word &lt;span style="font-style: italic;"&gt;const&lt;/span&gt; in a single line, for example here is a (member) function which returns a const int, takes a reference to a const string, and a const pointer to a const char, and does not modify the state of the object upon which it is called:&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 153);"&gt;class Stuff {&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 153);"&gt;  ...&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 153);"&gt;  const int getIndexOf(const std::string&amp;amp; str1, const char * const str2) const;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 153);"&gt;  ...&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 153);"&gt;};&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;My recommendation? Make use of the &lt;span style="font-style: italic;"&gt;const&lt;/span&gt; qualifier as much as possible. It will help you in the long run and will make your code safer (more resilient against unexpected behaviour).&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4470666517647633822-3411111435091415506?l=physical-thought.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://physical-thought.blogspot.com/feeds/3411111435091415506/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4470666517647633822&amp;postID=3411111435091415506' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4470666517647633822/posts/default/3411111435091415506'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4470666517647633822/posts/default/3411111435091415506'/><link rel='alternate' type='text/html' href='http://physical-thought.blogspot.com/2009/02/constness.html' title='Constness'/><author><name>Andrew J. Bennieston</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://bp2.blogger.com/_zi39n2uYgqg/R3f879w2IHI/AAAAAAAAAAY/IsPK0LU5Duc/S220/avatar.png'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4470666517647633822.post-2339948952934689610</id><published>2009-01-24T18:02:00.005Z</published><updated>2009-01-24T18:14:11.491Z</updated><category scheme='http://www.blogger.com/atom/ns#' term='projects'/><category scheme='http://www.blogger.com/atom/ns#' term='network'/><category scheme='http://www.blogger.com/atom/ns#' term='python'/><category scheme='http://www.blogger.com/atom/ns#' term='programming'/><title type='text'>Multicast UDP Host Discovery in Python</title><content type='html'>I'm in the process of writing a file transfer application in Python (don't ask; I don't like to run services such as FTP, SMB, etc. and a lot of people on Windows machines don't want to use SSH...) and I wanted the application to be able to automatically discover other instances of itself on the network.&lt;br /&gt;&lt;br /&gt;I chose Python in part because I love it, and also because it's easy to get running on Windows, Linux and OS X, the three OS' I'm targeting here. With the help of the &lt;a href="http://twistedmatrix.com/trac/"&gt;Twisted&lt;/a&gt; networking engine, UDP multicast is pretty straightforward. Here's a working Python/Twisted class for host discovery:&lt;br /&gt;&lt;pre name="code" class="python"&gt;#!/usr/bin/env python&lt;br /&gt;&lt;br /&gt;# Transpyre&lt;br /&gt;# Network File Transfer Program&lt;br /&gt;&lt;br /&gt;from twisted.internet.protocol import DatagramProtocol&lt;br /&gt;from twisted.internet import reactor&lt;br /&gt;from twisted.application.internet import MulticastServer&lt;br /&gt;from twisted.internet import task&lt;br /&gt;import config&lt;br /&gt;&lt;br /&gt;class HostDiscovery(DatagramProtocol):&lt;br /&gt; def __init__(self):&lt;br /&gt;  self.addresses = []&lt;br /&gt;  self.ping_str = 'PING Transpyre:' + config.nodename&lt;br /&gt;  self.pong_str = 'PONG Transpyre:' + config.nodename&lt;br /&gt;&lt;br /&gt; def startProtocol(self):&lt;br /&gt;  print 'Host discovery: listening'&lt;br /&gt;  self.transport.joinGroup(config.multicast_addr)&lt;br /&gt;  # self.ping() # Not needed any more; the refresh loop calls self.ping() on initialisation!&lt;br /&gt; &lt;br /&gt; def refreshList(self):&lt;br /&gt;  print 'Refreshing list...'&lt;br /&gt;  self.addresses = []&lt;br /&gt;  self.ping()&lt;br /&gt; &lt;br /&gt; def ping(self):&lt;br /&gt;  self.transport.write(self.ping_str, (config.multicast_addr, config.udp_port))&lt;br /&gt;&lt;br /&gt; def pong(self):&lt;br /&gt;  self.transport.write(self.pong_str, (config.multicast_addr, config.udp_port))&lt;br /&gt;&lt;br /&gt; def datagramReceived(self, datagram, address):&lt;br /&gt;  # Check if we received a dgram from another Transpyre instance&lt;br /&gt;  parts = str(datagram).split(':',1)&lt;br /&gt;  if len(parts) == 2:&lt;br /&gt;   print datagram&lt;br /&gt;   if parts[0] == 'PING Transpyre':&lt;br /&gt;    # Send a PONG&lt;br /&gt;    self.pong()&lt;br /&gt;   if parts[0] == 'PONG Transpyre':&lt;br /&gt;    try:&lt;br /&gt;     # Try to find address in list&lt;br /&gt;     idx = self.addresses.index(address[0])&lt;br /&gt;    except:&lt;br /&gt;     # Add it if it isn't there!&lt;br /&gt;     self.addresses.append(address[0])&lt;br /&gt;  print self.addresses&lt;br /&gt;&lt;br /&gt;discovery = HostDiscovery()&lt;br /&gt;reactor.listenMulticast(config.udp_port, discovery)&lt;br /&gt;refresh = task.LoopingCall(discovery.refreshList)&lt;br /&gt;refresh.start(config.refresh_delay) # Refresh list at rate defined in config.py&lt;br /&gt;reactor.run()&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;It sends a UDP packet to the multicast address on port 8192 (by default) with the text 'PING Transpyre:some host name' every 30 seconds and collects the responses ('PONG Transpyre:some other host name'). Each time, the current address list is cleared and regenerated from the packets returned. The packet payload (the text) is checked to determine if the multicast event was indeed another instance of this application, and the PING/PONG mechanism prevents excess packets flying around in some kind of chain reaction!&lt;br /&gt;&lt;br /&gt;Here's config.py which is required by the above file&lt;br /&gt;&lt;pre name="code" class="python"&gt;# config.py&lt;br /&gt;# Edit this to reflect your network settings&lt;br /&gt;# Possibly the GUI will edit this for you...&lt;br /&gt;&lt;br /&gt;# Node name - reported to other hosts&lt;br /&gt;nodename = 'Loki'&lt;br /&gt;&lt;br /&gt;# Download directory&lt;br /&gt;downloads = '/stuff/Transpyre'&lt;br /&gt;&lt;br /&gt;# Refresh address list after every N seconds&lt;br /&gt;refresh_delay = 30&lt;br /&gt;&lt;br /&gt;# IPv4 Multicast Address - Don't change this if you want it to work with other standard installations&lt;br /&gt;multicast_addr = '224.0.0.1'&lt;br /&gt;&lt;br /&gt;# Transpyre UDP Port - Don't change this if you want it to work with other standard installations&lt;br /&gt;udp_port = 8192&lt;br /&gt;&lt;br /&gt;# Transpyre TCP Port - Don't change this if you want it to work with other standard installations&lt;br /&gt;tcp_port = 16384&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4470666517647633822-2339948952934689610?l=physical-thought.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://physical-thought.blogspot.com/feeds/2339948952934689610/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4470666517647633822&amp;postID=2339948952934689610' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4470666517647633822/posts/default/2339948952934689610'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4470666517647633822/posts/default/2339948952934689610'/><link rel='alternate' type='text/html' href='http://physical-thought.blogspot.com/2009/01/multicast-udp-host-discovery-in-python.html' title='Multicast UDP Host Discovery in Python'/><author><name>Andrew J. Bennieston</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://bp2.blogger.com/_zi39n2uYgqg/R3f879w2IHI/AAAAAAAAAAY/IsPK0LU5Duc/S220/avatar.png'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4470666517647633822.post-4842026923903298372</id><published>2009-01-24T17:41:00.003Z</published><updated>2009-01-24T17:54:14.801Z</updated><category scheme='http://www.blogger.com/atom/ns#' term='random'/><category scheme='http://www.blogger.com/atom/ns#' term='xkcd'/><category scheme='http://www.blogger.com/atom/ns#' term='google'/><title type='text'>Some Lists</title><content type='html'>After reading &lt;a href="http://blag.xkcd.com/2008/12/03/some-lists/"&gt;this post&lt;/a&gt; over at &lt;a href="http://xkcd.com/"&gt;xkcd&lt;/a&gt; I decided to try to find some phrases of my own with no results on Google (at the time of posting).&lt;br /&gt;&lt;br /&gt;Here goes...&lt;br /&gt;&lt;ul&gt;&lt;li&gt;"passenger-side toothbrush holder"&lt;/li&gt;&lt;li&gt;"novel fossilised cow dung"&lt;/li&gt;&lt;li&gt;"airbags are for decoration only"&lt;/li&gt;&lt;li&gt;"marketing a new approach to personal hygiene"&lt;/li&gt;&lt;li&gt;"inconclusive proof for the existence of dog"&lt;/li&gt;&lt;li&gt;"positively neutral in charge"&lt;/li&gt;&lt;li&gt;"blind man saves life of guide dog"&lt;/li&gt;&lt;li&gt;"She'll know when it's time to feed the gimp"&lt;/li&gt;&lt;li&gt;"Nine hundred and ninety nine point nine recurring red balloons"&lt;/li&gt;&lt;li&gt;"Golden Retriever retrieves gold"&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;And some things I'd hoped would have no hits, but surprisingly did...&lt;br /&gt;&lt;ul&gt;&lt;li&gt;"Smarter than your average raptor"&lt;/li&gt;&lt;li&gt;"unimaginably imaginary"&lt;/li&gt;&lt;li&gt;"Poodle in a revolving door"&lt;/li&gt;&lt;/ul&gt;Happy Googling, everyone!&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4470666517647633822-4842026923903298372?l=physical-thought.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://physical-thought.blogspot.com/feeds/4842026923903298372/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4470666517647633822&amp;postID=4842026923903298372' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4470666517647633822/posts/default/4842026923903298372'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4470666517647633822/posts/default/4842026923903298372'/><link rel='alternate' type='text/html' href='http://physical-thought.blogspot.com/2009/01/some-lists.html' title='Some Lists'/><author><name>Andrew J. Bennieston</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://bp2.blogger.com/_zi39n2uYgqg/R3f879w2IHI/AAAAAAAAAAY/IsPK0LU5Duc/S220/avatar.png'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4470666517647633822.post-2345067059619340296</id><published>2009-01-13T19:16:00.003Z</published><updated>2009-01-13T19:27:39.076Z</updated><category scheme='http://www.blogger.com/atom/ns#' term='electronics'/><category scheme='http://www.blogger.com/atom/ns#' term='PhD'/><category scheme='http://www.blogger.com/atom/ns#' term='physics'/><title type='text'>Soldering LEDs!</title><content type='html'>I've spent most of the last two days soldering (then re-soldering) LEDs and trying to get a power supply working.&lt;br /&gt;&lt;br /&gt;What I wanted to do was to get 16 white LEDs all switched on at the same time. Easy, right?&lt;br /&gt;&lt;br /&gt;For what I'm doing, I needed about 35cm between each LED, so after acquiring the LEDs in the first place (&lt;a href="http://uk.rs-online.com/web/home.html"&gt;RS&lt;/a&gt; part number 654-2291) I soldered them all together into a single chain with 40cm wires between each one, taking care to connect the LEDs the correct way round!&lt;br /&gt;&lt;br /&gt;I wanted to stick a single resistor onto the end of this chain and push 10 mA through the LEDs (the nominal current each LED requires). The threshold forward voltage per LED is 2.7 V, which gives a minimum power supply voltage of 16 * 2.7 = 43.2 V plus the voltage drop across the current-limiting resistor. Since many (commonly available) power supplies don't provide voltages that high, I had to split the chain into two strings of eight, and drive those two strings in parallel. Using a power-supply that provides a constant current (or provides current-limiting on its own), there should in theory be no need for a resistor in the circuit, since I could just set the power supply to go no higher than 10 mA. However, it was suggested (by the people in the electronics workshop) that I use a 100 Ohm resistor on each branch to protect the LEDs should anyone try to push more current through!&lt;br /&gt;&lt;br /&gt;So, the circuit looks something like this:&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_zi39n2uYgqg/SWzqbTHdoqI/AAAAAAAAAQg/b4xOEWVi3H8/s1600-h/circuit.png"&gt;&lt;img style="display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;width: 400px; height: 127px;" src="http://1.bp.blogspot.com/_zi39n2uYgqg/SWzqbTHdoqI/AAAAAAAAAQg/b4xOEWVi3H8/s400/circuit.png" border="0" alt=""id="BLOGGER_PHOTO_ID_5290861416962433698" /&gt;&lt;/a&gt;&lt;br /&gt;and is currently powered by a 0 - 32V power supply with a current limit set at 0.01 A (10 mA). Strangely enough, the LEDs switch on at around 20 V on the power supply (and certainly less than the expected 21.6 V), which leads me to believe the stated threshold voltage is not quite accurate! Of course, the current drawn appears to also be much less than 10 mA, and for the purposes I require, that the LEDs are on (and that the brightness can be controlled by adjusting the supply voltage) is sufficient!&lt;br /&gt;&lt;br /&gt;A success, so far. Tomorrow I have to try to paint some cardboard black.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4470666517647633822-2345067059619340296?l=physical-thought.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://physical-thought.blogspot.com/feeds/2345067059619340296/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4470666517647633822&amp;postID=2345067059619340296' title='4 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4470666517647633822/posts/default/2345067059619340296'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4470666517647633822/posts/default/2345067059619340296'/><link rel='alternate' type='text/html' href='http://physical-thought.blogspot.com/2009/01/soldering-leds.html' title='Soldering LEDs!'/><author><name>Andrew J. Bennieston</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://bp2.blogger.com/_zi39n2uYgqg/R3f879w2IHI/AAAAAAAAAAY/IsPK0LU5Duc/S220/avatar.png'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://1.bp.blogspot.com/_zi39n2uYgqg/SWzqbTHdoqI/AAAAAAAAAQg/b4xOEWVi3H8/s72-c/circuit.png' height='72' width='72'/><thr:total>4</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4470666517647633822.post-8995131111676528995</id><published>2009-01-12T17:29:00.007Z</published><updated>2009-02-19T10:22:00.454Z</updated><category scheme='http://www.blogger.com/atom/ns#' term='linux'/><category scheme='http://www.blogger.com/atom/ns#' term='programming'/><title type='text'>sed Magic: Removing Lines</title><content type='html'>Problem: Remove lines from a file f2 if they contain a word in file f1.&lt;br /&gt;&lt;br /&gt;Solution:&lt;br /&gt;&lt;pre style="color: rgb(0, 153, 0);"&gt;for word in `cat f1`; do&lt;br /&gt;sed -i "/$word/d" f2;&lt;br /&gt;done&lt;/pre&gt;sed is a stream editor, the -i option performs the editing in-place (i.e. in the original file).&lt;br /&gt;&lt;br /&gt;This came up in the office today and I thought the solution was rather neat (if equally straightforward). Alternatives in most scripting languages (except maybe Perl?) are longer and/or uglier.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4470666517647633822-8995131111676528995?l=physical-thought.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://physical-thought.blogspot.com/feeds/8995131111676528995/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4470666517647633822&amp;postID=8995131111676528995' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4470666517647633822/posts/default/8995131111676528995'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4470666517647633822/posts/default/8995131111676528995'/><link rel='alternate' type='text/html' href='http://physical-thought.blogspot.com/2009/01/sed-magic.html' title='sed Magic: Removing Lines'/><author><name>Andrew J. Bennieston</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://bp2.blogger.com/_zi39n2uYgqg/R3f879w2IHI/AAAAAAAAAAY/IsPK0LU5Duc/S220/avatar.png'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4470666517647633822.post-597976209874997748</id><published>2009-01-11T23:36:00.003Z</published><updated>2009-01-11T23:54:48.257Z</updated><category scheme='http://www.blogger.com/atom/ns#' term='nmap tutorial'/><category scheme='http://www.blogger.com/atom/ns#' term='random'/><category scheme='http://www.blogger.com/atom/ns#' term='warwick'/><title type='text'>Some Random Stuff</title><content type='html'>I don't generally make posts about non-physics-or-programming-related topics, but I thought I'd just outline some of the things that I've done, bought or considered over the last few months.&lt;br /&gt;&lt;br /&gt;I think the main thing has to be my new monitor. I used to run dual 19" Samsung TFTs at home. One of them died in November, so I decided to treat myself to the Samsung T240, a 24" widescreen. I'm now using that as my only monitor, until I can get enough desk space to add a second one, and a graphics card that will cope with both! The surviving 19" is now at my parents' house so I can use it when I go home for the weekend (I took it back when I went for Christmas), so I'll probably get either another widescreen 24" (the same as this one) or two smaller monitors to go either side of it and have a triple-monitor setup, next.&lt;br /&gt;&lt;br /&gt;Around the same time, I got Amazon Prime. This amazing offer gives unlimited free next day delivery on anything sold by Amazon directly (not marketplace sellers) and costs only £49 a year. Since getting Amazon prime, I've more than made back that much in saved delivery costs (but of course, Amazon win too since I've bought a lot more stuff than I usually would have!) If you spend a lot of time and money at Amazon, I highly recommend Prime. The service is amazing, and the ability to order something and have it arrive the next day (Saturdays included) without paying for delivery is great. Amazon is now my first port-of-call when buying something online.&lt;br /&gt;&lt;br /&gt;Since I stayed on at Warwick to do a Ph.D. a large number of people I know have moved on to other places, and those that remained at Warwick have become more broadly geographically distributed. As a result, I'm often quite bored these days. Especially during the evenings and weekends, although to be perfectly honest I'm not sure I have all that much time to do things anyway. Given that I've decided to (try to) go swimming every morning before work, and to the gym three times a week (Tuesdays, Thursdays and Saturdays) there really isn't all that much time for anything beyond eating and sleeping in the evenings, and doing cleaning and washing at the weekends. I guess this is working life!&lt;br /&gt;&lt;br /&gt;Shortly before Christmas I bought a wired USB Apple Keyboard. The main reason was because I was taking my laptop home for Christmas, but not my deskop (my laptop is an Apple Macbook). When the keyboard arrived, however, I liked it so much that I'm now using it as my primary desktop keyboard at home. It's a little weird because I haven't (yet) remapped the keys to correspond to the Apple layout, so the labels don't necessarily correspond to the symbol that is generated when you press a key, but since I hardly ever look at the labels, it doesn't matter enough for me to have been sufficiently annoyed to invest the time playing with xmodmap.&lt;br /&gt;&lt;br /&gt;I think I mentioned in a post a few days/weeks ago that I was considering getting rid of the hosting for &lt;a href="http://www.nmap-tutorial.com"&gt;Nmap-Tutorial.com&lt;/a&gt;. I still haven't decided what to do about that, but given that I'm considering a move to Kenilworth, a holiday in the U.S. and several weekends in European cities, I should probably start to look at reducing my unnecessary expenses.&lt;br /&gt;&lt;br /&gt;On that note, I've been looking into savings accounts at various banks, especially tax free savings such as ISAs. They often have conditions about how much (or little) interest you get paid when you do or don't make a withdrawal in a given month, or about minimum payments, access and notice. To that end, if any reader of this blog has comments about savings accounts they have seen (or use personally) I'd love to hear them. Basically I'm looking for something into which I can stick whatever I think I can afford every month, then withdraw enough to pay for a week in America, or whatever.&lt;br /&gt;&lt;br /&gt;And on that note I think I'll wrap up this post. I just thought it would be good to explain what's going on in the real world, for me, amidst the almost certainly confusing series of posts about quantum field theory, and the random posts on programming and playing with Mathematica.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4470666517647633822-597976209874997748?l=physical-thought.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://physical-thought.blogspot.com/feeds/597976209874997748/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4470666517647633822&amp;postID=597976209874997748' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4470666517647633822/posts/default/597976209874997748'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4470666517647633822/posts/default/597976209874997748'/><link rel='alternate' type='text/html' href='http://physical-thought.blogspot.com/2009/01/some-random-stuff.html' title='Some Random Stuff'/><author><name>Andrew J. Bennieston</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://bp2.blogger.com/_zi39n2uYgqg/R3f879w2IHI/AAAAAAAAAAY/IsPK0LU5Duc/S220/avatar.png'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4470666517647633822.post-1771565179592326191</id><published>2009-01-05T14:31:00.002Z</published><updated>2009-01-05T14:52:46.922Z</updated><category scheme='http://www.blogger.com/atom/ns#' term='lorentz'/><category scheme='http://www.blogger.com/atom/ns#' term='standard model'/><category scheme='http://www.blogger.com/atom/ns#' term='particle physics'/><category scheme='http://www.blogger.com/atom/ns#' term='special relativity'/><category scheme='http://www.blogger.com/atom/ns#' term='quantum mechanics'/><category scheme='http://www.blogger.com/atom/ns#' term='schrödinger'/><category scheme='http://www.blogger.com/atom/ns#' term='physics'/><category scheme='http://www.blogger.com/atom/ns#' term='lagrangian'/><category scheme='http://www.blogger.com/atom/ns#' term='gauge theories'/><category scheme='http://www.blogger.com/atom/ns#' term='noether'/><category scheme='http://www.blogger.com/atom/ns#' term='superconductors'/><category scheme='http://www.blogger.com/atom/ns#' term='electrodynamics'/><category scheme='http://www.blogger.com/atom/ns#' term='mathematics'/><category scheme='http://www.blogger.com/atom/ns#' term='neutrinos'/><title type='text'>The Road To Quantum Field Theory</title><content type='html'>Dedicated readers will know that I've been presenting topics from theoretical physics with the goal of leading from Lagrangian mechanics all the way to quantum field theories. There were a few posts I made on special relativity and relativistic quantum mechanics before the 'QFT Series' of posts really began, and a number of other posts interspersed with those in the series. The most recent post introduced a mathematical notation useful in special relativity and relativistic quantum mechanics, notably four-vectors, tensors, etc.&lt;br /&gt;&lt;br /&gt;Near the beginning I presented a list of topics I was going to cover. At this stage, I think it is appropriate to present a list of topics I've already covered, with links to the posts covering them, then to briefly outline the steps which still remain.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Pre-Series posts on Special Relativity, Quantum Mechanics and Particle Physics&lt;/span&gt;&lt;br /&gt;&lt;ul&gt;&lt;li&gt;&lt;a href="http://physical-thought.blogspot.com/2008/04/introduction-to-relativity.html"&gt;An Introduction to Relativity&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href="http://physical-thought.blogspot.com/2008/04/relativistic-velocity-transformations.html"&gt;Relativistic Velocity Transformations&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href="http://physical-thought.blogspot.com/2008/04/four-vector-relativistic-velocity.html"&gt;Four-Vector Relativistic Velocity Transformations&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href="http://physical-thought.blogspot.com/2008/04/classical-electrodynamics.html"&gt;Classical Electrodynamics&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href="http://physical-thought.blogspot.com/2008/04/relativistic-quantum-mechanics-klein.html"&gt;Relativistic Quantum Mechanics: The Klein-Gordon Equation&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href="http://physical-thought.blogspot.com/2008/05/quantum-mechanics-of-neutrino.html"&gt;The Quantum Mechanics of Neutrino Oscillations&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt;&lt;span style="font-weight: bold;"&gt;&lt;br /&gt;The 'Road to QFT' Series&lt;/span&gt;&lt;br /&gt;&lt;ul&gt;&lt;li&gt;&lt;a href="http://physical-thought.blogspot.com/2008/09/lagrangian-mechanics-from-principle-of.html"&gt;Lagrangian Mechanics: From the Principle of Least Action to the Euler-Lagrange Equation&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href="http://physical-thought.blogspot.com/2008/09/lagrangian-mechanics-from-euler.html"&gt;Lagrangian Mechanics: From the Euler-Lagrange Equation to Newton's Laws&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href="http://physical-thought.blogspot.com/2008/09/lagrangian-mechanics-from-euler_20.html"&gt;Lagrangian Mechanics: From the Euler-Lagrange Equation to Simple Harmonic Motion&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href="http://physical-thought.blogspot.com/2008/09/from-lagrangian-to-hamiltonian.html"&gt;From Lagrangian to Hamiltonian Mechanics&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href="http://physical-thought.blogspot.com/2008/09/symmetries-conserved-quantities-and.html"&gt;Symmetries, Conserved Quantities and Noether's Theorem&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href="http://physical-thought.blogspot.com/2009/01/mathematics-of-special-relativity.html"&gt;The Mathematics of Special Relativity&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt;&lt;span style="font-weight: bold;"&gt;&lt;br /&gt;Out-of-Series Posts&lt;/span&gt;&lt;br /&gt;&lt;ul&gt;&lt;li&gt;&lt;a href="http://physical-thought.blogspot.com/2008/11/basic-relativity.html"&gt;Basic Relativity&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt;&lt;span style="font-weight: bold;"&gt;&lt;br /&gt;Roadmap&lt;br /&gt;&lt;/span&gt;&lt;ul&gt;&lt;li&gt;Relativistic Electrodynamics (Covariant Formulation of Maxwell's Equations)&lt;/li&gt;&lt;li&gt;Relativistic Quantum Mechanics: From Schrödinger to Klein-Gordon&lt;/li&gt;&lt;li&gt;Relativistic Quantum Mechanics II: The Dirac Equation and Spin&lt;/li&gt;&lt;li&gt;Symmetries and the Gauge Principle&lt;/li&gt;&lt;li&gt;Quantum Electrodynamics (QED)&lt;br /&gt;&lt;/li&gt;&lt;li&gt;Aside on Quantum Chromodynamics (QCD)&lt;br /&gt;&lt;/li&gt;&lt;li&gt;SU(2) and Electroweak Unification&lt;/li&gt;&lt;li&gt;Aside on Superconductivity (maybe...)&lt;br /&gt;&lt;/li&gt;&lt;li&gt;Spontaneous Symmetry Breaking and the Higgs Mechanism&lt;/li&gt;&lt;/ul&gt;You may notice that the imminent parts of the roadmap are becoming more clearly defined, while the still-distant final topics are broad and loosely defined. For example, there's likely to be more than one post on QED, but until I get there I don't know how many posts it will take!&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4470666517647633822-1771565179592326191?l=physical-thought.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://physical-thought.blogspot.com/feeds/1771565179592326191/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4470666517647633822&amp;postID=1771565179592326191' title='5 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4470666517647633822/posts/default/1771565179592326191'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4470666517647633822/posts/default/1771565179592326191'/><link rel='alternate' type='text/html' href='http://physical-thought.blogspot.com/2009/01/road-to-quantum-field-theory.html' title='The Road To Quantum Field Theory'/><author><name>Andrew J. Bennieston</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://bp2.blogger.com/_zi39n2uYgqg/R3f879w2IHI/AAAAAAAAAAY/IsPK0LU5Duc/S220/avatar.png'/></author><thr:total>5</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4470666517647633822.post-4459877401584427331</id><published>2009-01-03T16:49:00.013Z</published><updated>2009-01-05T13:17:21.733Z</updated><category scheme='http://www.blogger.com/atom/ns#' term='lorentz'/><category scheme='http://www.blogger.com/atom/ns#' term='special relativity'/><category scheme='http://www.blogger.com/atom/ns#' term='particle physics'/><category scheme='http://www.blogger.com/atom/ns#' term='electrodynamics'/><category scheme='http://www.blogger.com/atom/ns#' term='quantum mechanics'/><category scheme='http://www.blogger.com/atom/ns#' term='mathematics'/><category scheme='http://www.blogger.com/atom/ns#' term='physics'/><title type='text'>The Mathematics of Special Relativity</title><content type='html'>As promised, here is a post outlining the mathematical objects used in special relativity (SR). I'm not going to present fully formal definitions, and I'll almost certainly miss out some things I'll later rely on to explain more advanced concepts, but I'll get to those when the time comes. As for the formal definitions, find a good text on special relativity.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;Contravariant Four-Vectors&lt;/span&gt;&lt;br /&gt;A &lt;span style="font-style:italic;"&gt;contravariant four-vector&lt;/span&gt; is a four-component object which transforms according to the rule&lt;br /&gt;&lt;pre lang="eq.latex"&gt;x^{\prime\mu}=L^\mu_\nu x^\nu&lt;/pre&gt;&lt;br /&gt;where L is the Lorentz transformation (LT) matrix.&lt;br /&gt;&lt;br /&gt;For a transformation from a frame &lt;span style="font-weight:bold;"&gt;S&lt;/span&gt; to a frame &lt;span style="font-weight:bold;"&gt;S'&lt;/span&gt; moving with respect to &lt;span style="font-weight:bold;"&gt;S&lt;/span&gt; with velocity &lt;span style="font-style:italic;"&gt;v&lt;/span&gt; in the positive &lt;span style="font-style:italic;"&gt;x&lt;/span&gt; direction, define&lt;br /&gt;&lt;pre lang="eq.latex"&gt;\begin{align*}&lt;br /&gt;\beta &amp;= \frac{v}{c}\\ \gamma &amp;= \frac{1}{\sqrt{1-\beta^2}}\\ L &amp;= \left(\begin{array}{cccc}\gamma&amp;-\gamma\beta&amp;0&amp;0\\ -\gamma\beta&amp;\gamma&amp;0&amp;0\\0&amp;0&amp;1&amp;0\\0&amp;0&amp;0&amp;1\end{array}\right)\end{align*}&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;For example, the space-time four-vector &lt;pre lang="eq.latex"&gt;x^\mu = \left(\begin{array}{c}ct\\x\\y\\z\end{array}\right)&lt;/pre&gt; transforms as &lt;pre lang="eq.latex"&gt;x^{\prime\mu} = \left(\begin{array}{c}\gamma ct-\gamma\beta x\\-\gamma\beta ct+\gamma x\\y\\z\end{array}\right)&lt;/pre&gt;&lt;br /&gt;&lt;pre lang="eq.latex"&gt;= \left(\begin{array}{c}c\gamma\left(t-\frac{vx}{c^2}\right)\\\gamma\left(x-vt\right)\\y\\z\end{array}\right)&lt;/pre&gt;&lt;br /&gt;i.e. the usual form of the SR Lorentz transforms.&lt;br /&gt;&lt;br /&gt;Contravariant four-vectors are represented with a greek-letter index in the superscript position. In particle physics and quantum field theory it is conventional for time to be the zeroth component, as in all of my posts. In some areas of relativistic quantum mechanics, one will see time as the fourth component. This alters the definition of the LT matrix and the metric tensor, but of course the physics remains the same. I will always use time as the zeroth component in these posts.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;Covariant Four-Vectors and Rank-Two Tensors&lt;/span&gt;&lt;br /&gt;In addition to contravariant four-vectors, there are mathematical objects called covariant four-vectors (sometimes also called one-forms). It is possible to convert between covariant and contravariant vectors using an object known as a metric tensor.&lt;br /&gt;&lt;br /&gt;Covariant vectors are written with a single greek-letter index in the subscript position. Covariant and contravariant vectors are both rank-one tensors; objects where the rank is defined by the number of indices (equivalently the number of times one must apply the Lorentz transforms).&lt;br /&gt;&lt;br /&gt;A metric tensor defines the structure of the space-time in which we are working. For special relativity, we use Minkowski space, and the metric tensor is defined as g:&lt;br /&gt;&lt;pre lang="eq.latex"&gt;g = \left(\begin{array}{cccc}1&amp;0&amp;0&amp;0\\0&amp;-1&amp;0&amp;0\\0&amp;0&amp;-1&amp;0\\0&amp;0&amp;0&amp;-1\end{array}\right)&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;g is a rank-two tensor representing the structure of space-time. In general relativity (GR) different metric tensors can be used for different space-time geometries.&lt;br /&gt;&lt;br /&gt;The metric tensor allows us to convert contravariant vectors into covariant vectors, and vice versa:&lt;br /&gt;&lt;pre lang="eq.latex"&gt;\begin{align*}&lt;br /&gt;x_\mu &amp;= g_{\mu\nu}x^\nu\\&lt;br /&gt;x^\mu &amp;= g^{\mu\nu}x_\nu\end{align*}&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;Note that in these cases, &lt;pre lang="eq.latex" style="display: inline;"&gt;g_{\mu\nu}&lt;/pre&gt; has both indices either raised or lowered, whereas in the Lorentz transforms, L has one raised index and one lowered index. The positions of the indices determine the result (covariant or contravariant) and whether the result is physically meaningful. The Einstein summation convention states that one should sum over repeated indices where one is raised and the other is lowered.&lt;br /&gt;&lt;br /&gt;In Minkowski space, the conversion between co- and contra-variant vectors is simple:&lt;br /&gt;&lt;pre lang="eq.latex"&gt;x^\mu = \left(\begin{array}{c}ct\\x\\y\\z\end{array}\right)&lt;/pre&gt;&lt;br /&gt;&lt;pre lang="eq.latex"&gt;x_\mu = \left(\begin{array}{cccc}ct&amp;-x&amp;-y&amp;-z\end{array}\right)&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;Note that this leads to the useful property that the contraction of a covariant and a contravariant four-vector is a Lorentz-invariant scalar quantity. For example, using the space-time four-vector:&lt;br /&gt;&lt;pre lang="eq.latex"&gt;x^\mu x_\mu = x^\mu g_{\mu\nu}x^\nu = c^2 t^2 - x^2 - y^2 - z^2&lt;/pre&gt;&lt;br /&gt;which should be recognisable as the Lorentz-invariant space-time interval of special relativity.&lt;br /&gt;&lt;br /&gt;This property holds for all four-vectors and in all inertial reference frames.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;Rapidity&lt;/span&gt;&lt;br /&gt;Special Relativity is sometimes formulated in terms of &lt;span style="font-style:italic;"&gt;rapidity&lt;/span&gt; &lt;pre lang="eq.latex" style="display: inline;"&gt;\theta&lt;/pre&gt; rather than velocity &lt;span style="font-style:italic;"&gt;v&lt;/span&gt;.&lt;br /&gt;&lt;br /&gt;Here, &lt;pre lang="eq.latex"&gt;\mathrm{tanh}\,\theta = \beta&lt;/pre&gt;&lt;pre lang="eq.latex"&gt;\Rightarrow \mathrm{cosh}\,\theta = \gamma = \frac{1}{\sqrt{1-\beta^2}}&lt;/pre&gt;.&lt;br /&gt;&lt;br /&gt;The Lorentz transformation matrix is then written (often called &lt;pre lang="eq.latex" style="display: inline;"&gt;\Lambda&lt;/pre&gt; rather than L):&lt;br /&gt;&lt;pre lang="eq.latex"&gt;\Lambda =\left(\begin{array}{cccc}\mathrm{cosh}\,\theta&amp;-\mathrm{sinh}\,\theta&amp;0&amp;0\\-\mathrm{sinh}\,\theta&amp;\mathrm{cosh}\,\theta&amp;0&amp;0\\0&amp;0&amp;1&amp;0\\0&amp;0&amp;0&amp;1\end{array}\right)&lt;/pre&gt;&lt;br /&gt;for the equivalent of&lt;br /&gt;&lt;pre lang="eq.latex"&gt;L = \left(\begin{array}{cccc}\gamma&amp;-\gamma\beta&amp;0&amp;0\\-\gamma\beta&amp;\gamma&amp;0&amp;0\\0&amp;0&amp;1&amp;0\\0&amp;0&amp;0&amp;1\end{array}\right)&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;The usefulness of this approach lies in the fact that while velocities in SR do not add linearly, i.e.&lt;br /&gt;&lt;pre lang="eq.latex"&gt;v_{12} \neq v_1 + v_2&lt;/pre&gt;&lt;br /&gt;Rapidities &lt;span style="font-style:italic;"&gt;do&lt;/span&gt; add linearly:&lt;br /&gt;&lt;pre lang="eq.latex"&gt;\theta_{12} = \theta_1 + \theta_2&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;Useful Objects&lt;/span&gt;&lt;br /&gt;I'm going to list a few of the vectors and tensors which appear often in particle physics, so that when I need to use them in future posts, they won't look completely new. I won't explain much about them here.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-style:italic;"&gt;Energy-Momentum four-vector&lt;/span&gt;&lt;br /&gt;&lt;pre lang="eq.latex"&gt;p^\mu = \left(\begin{array}{c}\frac{E}{c}\\p_x\\p_y\\p_z\end{array}\right) = \left(\begin{array}{c}\frac{E}{c}\\\mathbf{p}\end{array}\right)&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-style:italic;"&gt;Four-Current&lt;/span&gt;&lt;br /&gt;&lt;pre lang="eq.latex"&gt;j^\mu = \left(\begin{array}{c}\rho\\\mathbf{j}\end{array}\right)&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-style:italic;"&gt;(Electromagnetic) Four-Potential&lt;/span&gt;&lt;br /&gt;&lt;pre lang="eq.latex"&gt;A^\mu = \left(\begin{array}{c}\frac{\phi}{c}\\\mathbf{A}\end{array}\right)&lt;/pre&gt;&lt;br /&gt;where &lt;span style="font-weight:bold;"&gt;A&lt;/span&gt; is the vector potential of electromagnetism.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-style:italic;"&gt;Covariant Derivative&lt;/span&gt;&lt;br /&gt;&lt;pre lang="eq.latex"&gt;\partial_\mu = \left(\begin{array}{c}\frac{1}{c}\frac{\partial}{\partial t}\\ \nabla\end{array}\right)&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-style:italic;"&gt;Faraday Tensor&lt;/span&gt;&lt;br /&gt;&lt;pre lang="eq.latex"&gt;F^{\mu\nu} = \partial^\mu A^\nu - \partial^\nu A^\mu&lt;/pre&gt;&lt;br /&gt;&lt;pre lang="eq.latex"&gt;F = \left(\begin{array}{cccc}0&amp;-\frac{E_1}{c}&amp;-\frac{E_2}{c}&amp;-\frac{E_3}{c}\\&lt;br /&gt;\frac{E_1}{c}&amp;0&amp;-B_3&amp;B_2\\&lt;br /&gt;\frac{E_2}{c}&amp;B_3&amp;0&amp;-B_1\\&lt;br /&gt;\frac{E_3}{c}&amp;-B_2&amp;B_1&amp;0\end{array}\right)&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;Note that &lt;pre lang="eq.latex"&gt;F^{\mu\nu}F_{\mu\nu} = 2\left(B^2 - \frac{E^2}{c^2}\right)&lt;/pre&gt; is Lorentz invariant!&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4470666517647633822-4459877401584427331?l=physical-thought.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://physical-thought.blogspot.com/feeds/4459877401584427331/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4470666517647633822&amp;postID=4459877401584427331' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4470666517647633822/posts/default/4459877401584427331'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4470666517647633822/posts/default/4459877401584427331'/><link rel='alternate' type='text/html' href='http://physical-thought.blogspot.com/2009/01/mathematics-of-special-relativity.html' title='The Mathematics of Special Relativity'/><author><name>Andrew J. Bennieston</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://bp2.blogger.com/_zi39n2uYgqg/R3f879w2IHI/AAAAAAAAAAY/IsPK0LU5Duc/S220/avatar.png'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4470666517647633822.post-5306370349062753127</id><published>2008-12-31T12:55:00.005Z</published><updated>2008-12-31T13:28:02.612Z</updated><category scheme='http://www.blogger.com/atom/ns#' term='c++'/><category scheme='http://www.blogger.com/atom/ns#' term='nmap tutorial'/><category scheme='http://www.blogger.com/atom/ns#' term='lhc'/><category scheme='http://www.blogger.com/atom/ns#' term='the plan'/><category scheme='http://www.blogger.com/atom/ns#' term='particle physics'/><category scheme='http://www.blogger.com/atom/ns#' term='special relativity'/><category scheme='http://www.blogger.com/atom/ns#' term='PhD'/><category scheme='http://www.blogger.com/atom/ns#' term='quantum mechanics'/><category scheme='http://www.blogger.com/atom/ns#' term='mathematica'/><category scheme='http://www.blogger.com/atom/ns#' term='physics'/><category scheme='http://www.blogger.com/atom/ns#' term='lagrangian'/><category scheme='http://www.blogger.com/atom/ns#' term='cat'/><category scheme='http://www.blogger.com/atom/ns#' term='reconstruction'/><category scheme='http://www.blogger.com/atom/ns#' term='warwick'/><category scheme='http://www.blogger.com/atom/ns#' term='programming'/><title type='text'>2008</title><content type='html'>Welcome to this, my final post of 2008. This year has seen a number of important events in science, notably the switch-on of the LHC at CERN (and the subsequent switch-off due to problems with magnets and helium). As far as I'm aware, things should be back online soon (ish), and although I'm not directly involved in anything going on at the LHC, I'm watching it with interest.&lt;br /&gt;&lt;br /&gt;In other news, I started my Ph.D. in particle detector research &amp; development, looking specifically at the use of Liquid Argon based detectors. So far, I've written some C++ code to simulate point light sources and attempt to reconstruct their locations, got very annoyed with the ROOT software, figured out how to use ROOT a little better, only to get annoyed with the next slightly-more-complicated thing, and attended a lot of postgraduate lectures on particle physics.&lt;br /&gt;&lt;br /&gt;While I initially thought the lectures weren't going to be much use, it turns out I've learned quite a lot from them, and many things I already knew have become much more concrete in my mind, so I have to say they were a success, even if they did take up a huge amount of time!&lt;br /&gt;&lt;br /&gt;In addition to all of that, I set out in September and October to make posts on quantum field theory, beginning with classical Lagrangian mechanics, moving through Special Relativity (SR) into relativistic quantum mechanics (RQM) and finally into quantum field theory (QFT). I got about as far as the relativity part before I ran out of time. Hopefully in 2009 I'll make time to continue this (hopefully) thorough treatment of theoretical physics.&lt;br /&gt;&lt;br /&gt;If you've been following the posts on those topics, I'd appreciate any feedback, thoughts, comments or suggestions you may have. Are the posts understandable, and at what level? For instance, if you're a physics undergraduate, do you have a decent chance of following the material presented? If you're not a physicist at all, do you get the idea of what's going on, even if you can't follow every step of the way? I have no intention to "dumb down" those posts; I want them to be as in-depth as possible, but I may be convinced to make a parallel series of posts explaining the same material in a less mathematical, more phenomenological way.&lt;br /&gt;&lt;br /&gt;As some readers may know, I wrote a detailed (at the time) tutorial for the Nmap port scanner in the years 2003 - 2006. The 2006 version is kept at &lt;a href="http://www.nmap-tutorial.com"&gt;http://www.nmap-tutorial.com&lt;/a&gt;, a site which I maintain and host. Given that I haven't updated it since 2006, I'm debating whether to keep it there at all, given the cost of hosting the site. There are reasons for keeping it, not least of which is that the same server provides a useful dumping ground for files I want to publish on this blog (which aren't images), such as the &lt;a href="http://physical-thought.blogspot.com/2008/07/mathematica-notebook-fourier-transform.html"&gt;Mathematica notebook&lt;/a&gt; from the &lt;a href="http://physical-thought.blogspot.com/2008/06/fourier-transform-of-cat.html"&gt;Fourier Transform of a Cat&lt;/a&gt; post. There are also reasons for getting rid of it, notably the time and money required to maintain a server. I'm not entirely sure what will happen here, if I can find alternative hosting for the Nmap Tutorial, that would be the ideal solution, but that doesn't seem terribly likely at this time.&lt;br /&gt;&lt;br /&gt;On the topic of websites, I created a site at &lt;a href="http://www.warwick.ac.uk/~phrebd/"&gt;http://www.warwick.ac.uk/~phrebd/&lt;/a&gt; to provide information useful mostly to Warwick students and staff, particle physicists and programmers. I wanted to keep certain links and information together in one place and not in a blog format.&lt;br /&gt;&lt;br /&gt;And now, on a more personal note, I'm thinking of moving to Kenilworth after June 2009. If any Warwick Ph.D. students are reading this, and wouldn't mind living in Kenilworth (my minimum requirements are somewhere with off-road parking, a decent sized kitchen, and a dishwasher) then get in touch.&lt;br /&gt;&lt;br /&gt;Finally, I'd like to wish anyone who bothers to read this a happy new year, and I'll try to post more often in 2009!&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4470666517647633822-5306370349062753127?l=physical-thought.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://physical-thought.blogspot.com/feeds/5306370349062753127/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4470666517647633822&amp;postID=5306370349062753127' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4470666517647633822/posts/default/5306370349062753127'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4470666517647633822/posts/default/5306370349062753127'/><link rel='alternate' type='text/html' href='http://physical-thought.blogspot.com/2008/12/2008.html' title='2008'/><author><name>Andrew J. Bennieston</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://bp2.blogger.com/_zi39n2uYgqg/R3f879w2IHI/AAAAAAAAAAY/IsPK0LU5Duc/S220/avatar.png'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4470666517647633822.post-6953386254372952393</id><published>2008-11-19T09:13:00.003Z</published><updated>2008-11-19T09:23:43.954Z</updated><category scheme='http://www.blogger.com/atom/ns#' term='mathematica'/><title type='text'>Wolfram release Mathematica 7</title><content type='html'>Mathematica 7 has been released today. The release continues the emphasis on bringing together aspects of Mathematica, improving and optimising the way it works, and putting more power and flexibility at the user's fingertips. Better image processing, support for parallel computation and high-performance computing are also mentioned in the Wolfram press release, a section of which reads,&lt;br /&gt;&lt;br /&gt;&lt;span style="font-style: italic; color: rgb(0, 0, 153);"&gt;November 18, 2008, Champaign, Illinois--Wolfram Research today&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic; color: rgb(0, 0, 153);"&gt;announced Mathematica 7, a major release that accelerates the&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic; color: rgb(0, 0, 153);"&gt;drive to integrate and automate functionality as core Mathematica&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic; color: rgb(0, 0, 153);"&gt;capabilities, adding image processing, parallel high-performance&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic; color: rgb(0, 0, 153);"&gt;computing (HPC), new on-demand curated data, and other recently&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic; color: rgb(0, 0, 153);"&gt;developed computational innovations--in total over 500 new&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic; color: rgb(0, 0, 153);"&gt;functions and 12 application areas.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;I haven't had time to check out Mathematica 7 for myself yet, but I'll definitely take a look as soon as I can.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4470666517647633822-6953386254372952393?l=physical-thought.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://physical-thought.blogspot.com/feeds/6953386254372952393/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4470666517647633822&amp;postID=6953386254372952393' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4470666517647633822/posts/default/6953386254372952393'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4470666517647633822/posts/default/6953386254372952393'/><link rel='alternate' type='text/html' href='http://physical-thought.blogspot.com/2008/11/wolfram-release-mathematica-7.html' title='Wolfram release Mathematica 7'/><author><name>Andrew J. Bennieston</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://bp2.blogger.com/_zi39n2uYgqg/R3f879w2IHI/AAAAAAAAAAY/IsPK0LU5Duc/S220/avatar.png'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4470666517647633822.post-2535335441544775412</id><published>2008-11-10T22:57:00.012Z</published><updated>2008-11-19T09:26:00.094Z</updated><category scheme='http://www.blogger.com/atom/ns#' term='lorentz'/><category scheme='http://www.blogger.com/atom/ns#' term='special relativity'/><category scheme='http://www.blogger.com/atom/ns#' term='particle physics'/><category scheme='http://www.blogger.com/atom/ns#' term='physics'/><title type='text'>Basic Relativity</title><content type='html'>I realise I haven't made any posts here recently; I've been far too busy with my Ph.D. and various other commitments. In lieu of the post I wanted to make on special relativity, defining everything carefully and introducing the tensor formulation, I'm going to present some basic concepts of Special Relativity, almost exactly as I taught them to a first year undergraduate examples class. These people had lectures on relativity already, so the stuff below is really a recap and a worked example.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Lorentz Transforms&lt;/span&gt;&lt;br /&gt;Consider a coordinate frame S' moving with velocity v in the positive x-direction of a frame S. The Lorentz transforms between the two frames (x, y, z, t in S and x', y', z', t' in S') are given by:&lt;br /&gt;&lt;pre lang="eq.latex"&gt;&lt;br /&gt;\begin{align*}&lt;br /&gt;x^\prime &amp;amp;= \gamma(x-vt) = \frac{1}{\sqrt{1-\frac{v^2}{c^2}}}(x - vt)\\&lt;br /&gt;y^\prime &amp;amp;= y\\&lt;br /&gt;z^\prime &amp;amp;= z\\&lt;br /&gt;t^\prime &amp;amp;= \gamma\left(t - \frac{vx}{c^2}\right) = \frac{1}{\sqrt{1-\frac{v^2}{c^2}}}\left(t - \frac{vx}{c^2}\right)&lt;br /&gt;\end{align*}&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;The reverse transforms, from S' back to S, are given by:&lt;br /&gt;&lt;pre lang="eq.latex"&gt;&lt;br /&gt;\begin{align*}&lt;br /&gt;x &amp;amp;= \gamma(x^\prime+vt^\prime) = \frac{1}{\sqrt{1-\frac{v^2}{c^2}}}(x^\prime + vt^\prime)\\&lt;br /&gt;y &amp;amp;= y^\prime\\&lt;br /&gt;z &amp;amp;= z^\prime\\&lt;br /&gt;t &amp;amp;= \gamma\left(t^\prime + \frac{vx^\prime}{c^2}\right) = \frac{1}{\sqrt{1-\frac{v^2}{c^2}}}\left(t^\prime + \frac{vx^\prime}{c^2}\right)&lt;br /&gt;\end{align*}&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Velocity Transformation&lt;/span&gt;&lt;br /&gt;If an object is moving with a velocity u' in frame S' (as defined above), we need to determine a transform for the velocity in frame S. Start out with the fact that the velocity in S is &lt;pre style="display: inline;" lang="eq.latex"&gt;u = \frac{\Delta x}{\Delta t}&lt;/pre&gt; and substitute in the transforms above:&lt;br /&gt;&lt;pre lang="eq.latex"&gt;&lt;br /&gt;u = \frac{\Delta x}{\Delta t} &amp;amp;= \frac{\gamma(\Delta x^\prime + v\Delta t^\prime)}{\gamma\left(\Delta t^\prime + \frac{v\Delta x^\prime}{c^2}\right)}&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;Divide through by &lt;pre style="display: inline;" lang="eq.latex"&gt;\Delta t^\prime&lt;/pre&gt;:&lt;br /&gt;&lt;pre lang="eq.latex"&gt;&lt;br /&gt;u= \frac{\frac{\Delta x^\prime}{\Delta t^\prime} + v}{1+\frac{v\Delta x^\prime}{\Delta t^\prime c^2}}&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;Since &lt;pre style="display: inline;" lang="eq.latex"&gt;\frac{\Delta x^\prime}{\Delta t^\prime}=u^\prime&lt;/pre&gt;,&lt;br /&gt;&lt;br /&gt;&lt;pre lang="eq.latex"&gt;&lt;br /&gt;u = \frac{u^\prime + v}{1+\frac{u^\prime v}{c^2}}&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;which is the velocity transform between u and u'!&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Time Dilation&lt;/span&gt;&lt;br /&gt;Consider a particle with a lifetime &lt;pre style="display: inline;" lang="eq.latex"&gt;\tau&lt;/pre&gt; in its rest frame (i.e. in an inertial frame in which the particle has zero momentum). The lifetime t, in a frame moving with velocity v is given by:&lt;br /&gt;&lt;pre lang="eq.latex"&gt;&lt;br /&gt;t = \gamma\tau&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;Since &lt;pre style="display: inline;" lang="eq.latex"&gt;\gamma&lt;/pre&gt; is always greater than or equal to 1, t is always as large as, or larger than, &lt;pre style="display: inline;" lang="eq.latex"&gt;\tau&lt;/pre&gt;. This is the phenomenon of time dilation and the relationship can be used to determine the time dilation in any inertial frame.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Length Contraction&lt;/span&gt;&lt;br /&gt;If the length measured in the lab frame is given by &lt;pre style="display: inline;" lang="eq.latex"&gt;L_0&lt;/pre&gt;, the length seen by a particle moving at speed v in the lab frame is given by:&lt;br /&gt;&lt;pre lang="eq.latex"&gt;&lt;br /&gt;L = \frac{L_0}{\gamma}&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;The length is therefore always smaller than (or exactly the same as) the length in the lab frame, and this is the phenomenon of length contraction.&lt;br /&gt;&lt;br /&gt;Be careful never to use both time dilation and length contraction in the same (part of a) physics problem! If you're working in the lab frame, use time dilation to alter the particle lifetime, and leave the length as measured in the lab frame. If you're in the particle rest frame, use the particle lifetime as given (since they are defined as lifetime in a particle rest frame) and use length contraction to determine the length seen by the particle from the length as measured in the lab.&lt;br /&gt;&lt;br /&gt;The classic atmospheric muon problem, below, illustrates how to use these concepts.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;The Atmospheric Muon Problem&lt;/span&gt;&lt;br /&gt;Muons are produced in cosmic-ray interactions high in the Earth's atmosphere (at, say 8000m). The muon lifetime is &lt;pre style="display: inline;" lang="eq.latex"&gt;2.2\times 10^{-6}~\mathrm{s}&lt;/pre&gt;.&lt;br /&gt;&lt;br /&gt;Muons produced in this way are detected at the Earth's surface. For a muon travelling at 0.998 times the speed of light,&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;(a)&lt;/span&gt; Calculate how far the muon would travel using only classical (non-relativistic) physics.&lt;br /&gt;&lt;br /&gt;Here, we use the classical &lt;pre style="display: inline;" lang="eq.latex"&gt;s = ut&lt;/pre&gt; relationship. The maximum distance the muon can travel is given by:&lt;br /&gt;&lt;pre lang="eq.latex"&gt;&lt;br /&gt;s = 0.998c \tau = 0.998\times 3\times 10^{8} \times 2.2\times 10^{-6} = 658.68~\mathrm{m}&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;In this situation, the muon cannot reach the Earth's surface.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;(b)&lt;/span&gt; In the rest frame of the muon, use relativistic physics to show that the muon can indeed reach the surface.&lt;br /&gt;&lt;br /&gt;In the muon rest frame, the lifetime is still &lt;pre style="display: inline;" lang="eq.latex"&gt;2.2\times 10^{-6}~\mathrm{s}&lt;/pre&gt;, but the length it has to travel is shortened by length contraction:&lt;br /&gt;&lt;pre lang="eq.latex"&gt;&lt;br /&gt;L_\mu = \frac{1}{\gamma}L_E&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;The Lorentz factor is given by:&lt;br /&gt;&lt;pre lang="eq.latex"&gt;&lt;br /&gt;\gamma = \frac{1}{\sqrt{1-\frac{v^2}{c^2}}} = 15.8&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;giving the length seen by the muon as:&lt;br /&gt;&lt;pre lang="eq.latex"&gt;&lt;br /&gt;L_\mu = \frac{8000}{15.8} = 506.32~\mathrm{m}&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;We already worked out that a muon travelling at 0.998c can travel over 600m before it decays using its lifetime as stated, in part a, so now the muons will make it to the surface of the Earth!&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;(c)&lt;/span&gt; In the Earth frame, use relativistic physics to show that the muon can make it to the surface.&lt;br /&gt;&lt;br /&gt;Here, the length is as measured, 8000m, but the lifetime of the muon must be dilated:&lt;br /&gt;&lt;pre style="display: inline;" lang="eq.latex"&gt;t = \gamma \tau&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;We worked out the Lorentz factor above as 15.8, so now we have:&lt;br /&gt;&lt;pre lang="eq.latex"&gt;&lt;br /&gt;t = 15.8 \times 2.2\times 10^{-6} = 3.48 \times 10^{-5}&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;The maximum distance such a muon can travel is then:&lt;br /&gt;&lt;pre lang="eq.latex"&gt;&lt;br /&gt;s = u t = 0.998\times 3\times 10^8 \times 3.48\times 10^{-5} = 10419~\mathrm{m}&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;The muon can now travel over 10 km in the Earth frame, well over the 8 km it needs to hit the surface, so again we can detect such muons on the Earth.&lt;br /&gt;&lt;br /&gt;This example demonstrates several interesting aspects of relativistic physics. Firstly, that it works! We can detect muons produced in this way, which we wouldn't be able to detect if those relativistic effects didn't occur! Secondly, you can analyse a problem using either length contraction or time dilation, but you need to choose your frame carefully. Don't contract or dilate quantities that were measured in the frame you're using; only alter those measured in other frames. Note that lengths are often (but not &lt;span style="font-style: italic;"&gt;always&lt;/span&gt;) measured in a lab frame, and that particle lifetimes are &lt;span style="font-style: italic;"&gt;always&lt;/span&gt; given in the rest frame of the particle concerned!&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4470666517647633822-2535335441544775412?l=physical-thought.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://physical-thought.blogspot.com/feeds/2535335441544775412/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4470666517647633822&amp;postID=2535335441544775412' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4470666517647633822/posts/default/2535335441544775412'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4470666517647633822/posts/default/2535335441544775412'/><link rel='alternate' type='text/html' href='http://physical-thought.blogspot.com/2008/11/basic-relativity.html' title='Basic Relativity'/><author><name>Andrew J. Bennieston</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://bp2.blogger.com/_zi39n2uYgqg/R3f879w2IHI/AAAAAAAAAAY/IsPK0LU5Duc/S220/avatar.png'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4470666517647633822.post-8625908792119429528</id><published>2008-10-28T22:29:00.003Z</published><updated>2008-10-28T22:37:43.307Z</updated><category scheme='http://www.blogger.com/atom/ns#' term='optics'/><category scheme='http://www.blogger.com/atom/ns#' term='reconstruction'/><category scheme='http://www.blogger.com/atom/ns#' term='books'/><category scheme='http://www.blogger.com/atom/ns#' term='physics'/><title type='text'>An Unhelpfulness of Optics Books</title><content type='html'>The collective noun is probably something more like "library" or simply "collection", but I think an Unhelpfulness better describes their applicability to my current work.&lt;br /&gt;&lt;br /&gt;As I mentioned in my &lt;a href="http://physical-thought.blogspot.com/2008/10/quest-for-optics-book.html"&gt;previous post&lt;/a&gt;, I was looking for an optics book which would help me with figuring out how to map a set of point sources onto a close imaging plane, and to be able to reconstruct the positions of those sources.&lt;br /&gt;&lt;br /&gt;Having looked through all the books I mentioned in that post, as well as &lt;span style="font-style:italic;"&gt;Optics (4th Edition)&lt;/span&gt;, E. Hecht (Pearson, 2003), I've reached the (in retrospect, fairly obvious) conclusion that none of them had the treatment I wanted.&lt;br /&gt;&lt;br /&gt;They deal with wave optics and primarily in the far-field regime, for coherent light sources. In my case, the sources are not coherent, and are pretty damn close to the image plane. I resorted to the principle of superposition and to the inverse square law for light intensity, which appears to be producing adequate results, though I would still be interested in any texts on point source reconstruction from images on nearby planes.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4470666517647633822-8625908792119429528?l=physical-thought.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://physical-thought.blogspot.com/feeds/8625908792119429528/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4470666517647633822&amp;postID=8625908792119429528' title='3 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4470666517647633822/posts/default/8625908792119429528'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4470666517647633822/posts/default/8625908792119429528'/><link rel='alternate' type='text/html' href='http://physical-thought.blogspot.com/2008/10/unhelpfulness-of-optics-books.html' title='An Unhelpfulness of Optics Books'/><author><name>Andrew J. Bennieston</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://bp2.blogger.com/_zi39n2uYgqg/R3f879w2IHI/AAAAAAAAAAY/IsPK0LU5Duc/S220/avatar.png'/></author><thr:total>3</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4470666517647633822.post-6217914649821483497</id><published>2008-10-19T13:17:00.004+01:00</published><updated>2008-10-19T13:26:57.217+01:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='optics'/><category scheme='http://www.blogger.com/atom/ns#' term='books'/><category scheme='http://www.blogger.com/atom/ns#' term='physics'/><title type='text'>The Quest for an Optics Book</title><content type='html'>I'm searching for a book on optics; one which covers topics such as reconstructing point sources from an imaging plane a short distance away from them, where the imaging plane consists of an array of detectors (which do not cover the entire surface). It would also be nice if I could find something that covered things like dealing with edge effects and how best to reconstruct points at the edge of the detector area.&lt;br /&gt;&lt;br /&gt;I've been to the &lt;a href="http://www2.warwick.ac.uk/services/library"&gt;University of Warwick Library&lt;/a&gt;, and acquired three books on optics. At first glance, these seem to cover some of the introductory topics as well as a few of the things I will need specifically. Since, currently, I know very little about optics (despite owning a digital SLR camera!) I need to find a gentle introduction followed by some very technical stuff.&lt;br /&gt;&lt;br /&gt;As I read through these to assess their suitability, I may end up posting brief reviews of each one, describing their content and relevance for my purposes. In the mean time, here are the books I've found so far. If anyone can suggest an alternative, or something which contains exactly what I want, please feel free to leave a comment!&lt;br /&gt;&lt;ul&gt;&lt;li&gt;Optical Imaging and Aberrations - Part I: Ray Geometrical Optics, Virendra N. Mahajan (SPIE, 1998)&lt;/li&gt;&lt;li&gt;Astronomical Image and Data Analysis, Jean-Luc Starck and Fionn Murtagh (Springer, 2002)&lt;/li&gt;&lt;li&gt;Introduction to Optics and Optical Imaging, Craig Scott (IEEE Press, 1998)&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4470666517647633822-6217914649821483497?l=physical-thought.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://physical-thought.blogspot.com/feeds/6217914649821483497/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4470666517647633822&amp;postID=6217914649821483497' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4470666517647633822/posts/default/6217914649821483497'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4470666517647633822/posts/default/6217914649821483497'/><link rel='alternate' type='text/html' href='http://physical-thought.blogspot.com/2008/10/quest-for-optics-book.html' title='The Quest for an Optics Book'/><author><name>Andrew J. Bennieston</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://bp2.blogger.com/_zi39n2uYgqg/R3f879w2IHI/AAAAAAAAAAY/IsPK0LU5Duc/S220/avatar.png'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4470666517647633822.post-8247411688037014544</id><published>2008-10-07T12:02:00.001+01:00</published><updated>2008-10-07T12:02:56.591+01:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='c++'/><category scheme='http://www.blogger.com/atom/ns#' term='programming'/><title type='text'>Contraction of Four-Vectors: A C++ Exercise</title><content type='html'>&lt;span style="color: rgb(204, 0, 0);"&gt;NOTE: The examples as typed have not been compiled or checked, however they are directly based on examples I talked through while teaching C++, so there should not be any particularly glaring errors or omissions. Note that I've avoided talking too much about object-oriented design, advanced concepts or why certain things are done the way they are. This article is intended mainly as an introduction to the abstraction mechanisms available with C++ class-based design, and is not intended to introduce any new concepts to the world of C++. In particular, I do not claim to be the first person to have thought of such concepts (as a number of comments have suggested in the past); I'm merely providing an example for those interested!&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Without going into the physics behind it, if we have two objects A and B, each with four components, we can define their contraction as:&lt;br /&gt;&lt;pre lang="eq.latex"&gt;A_{\mu}B^{\mu} = A_0 B_0 - (A_1 B_1 + A_2 B_2 + A_3 B_3)&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;I intend now to use this concept to develop a C++ program from a `first draft' to a finished object-oriented program. This is indented primarily as an introductory-level tutorial for those new to C++ but familiar with many aspects of C or similar languages, so I will not go into a lot of detail about the basics, instead focussing on the C++ specific stuff.&lt;br /&gt;&lt;br /&gt;The first approach could look something like this:&lt;br /&gt;&lt;pre name="code" class="cpp"&gt;&lt;br /&gt;#include &amp;lt;iostream&amp;gt;&lt;br /&gt;&lt;br /&gt;int main()&lt;br /&gt;{&lt;br /&gt; // Create some variables&lt;br /&gt; double a0, a1, a2, a3;&lt;br /&gt; double b0, b1, b2, b3;&lt;br /&gt; &lt;br /&gt; // Prompt and read eight components&lt;br /&gt; std::cout &amp;lt;&amp;lt; "Enter the four components of A, separated by spaces:" &amp;lt;&amp;lt; std::endl;&lt;br /&gt; std::cin &amp;gt;&amp;gt; a0 &amp;gt;&amp;gt; a1 &amp;gt;&amp;gt; a2 &amp;gt;&amp;gt; a3;&lt;br /&gt; std::cout &amp;lt;&amp;lt; "Enter the four components of B, separated by spaces:" &amp;lt;&amp;lt; std::endl;&lt;br /&gt; std::cin &amp;gt;&amp;gt; b0 &amp;gt;&amp;gt; b1 &amp;gt;&amp;gt; b2 &amp;gt;&amp;gt; b3;&lt;br /&gt; &lt;br /&gt; // Calculate contraction and display result&lt;br /&gt; double result = a0*b0 - a1*b1 - a2*b2 - a3*b3;&lt;br /&gt; std::cout &amp;lt;&amp;lt; "A.B = " &amp;lt;&amp;lt; result &amp;lt;&amp;lt; std::endl;&lt;br /&gt; &lt;br /&gt; return 0; &lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;This is a fairly simple program, achieving exactly what we set out to do. However, from the perspective of simplicity, there's a lot of overhead in the main program which detracts from the understanding of what is actually going on. We can make things slightly clearer by writing the contraction as a function; then we'll be able to call it repeatedly from our code, instead of defining what a contraction of four-vectors means at every point it is used:&lt;br /&gt;&lt;pre name="code" class="cpp"&gt;&lt;br /&gt;double contract(double a0, double a1, double a2, double a3,&lt;br /&gt; double b0, double b1, double b2, double b3)&lt;br /&gt;{&lt;br /&gt; return a0*b0 - a1*b1 - a2*b2 - a3*b3;&lt;br /&gt;}&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;Now, our main() looks like this:&lt;br /&gt;&lt;pre name="code" class="cpp"&gt;&lt;br /&gt;int main()&lt;br /&gt;{&lt;br /&gt; // Create some variables&lt;br /&gt; double a0, a1, a2, a3;&lt;br /&gt; double b0, b1, b2, b3;&lt;br /&gt; &lt;br /&gt; // Prompt and read eight components&lt;br /&gt; std::cout &amp;lt;&amp;lt; "Enter the four components of A, separated by spaces:" &amp;lt;&amp;lt; std::endl;&lt;br /&gt; std::cin &amp;gt;&amp;gt; a0 &amp;gt;&amp;gt; a1 &amp;gt;&amp;gt; a2 &amp;gt;&amp;gt; a3;&lt;br /&gt; std::cout &amp;lt;&amp;lt; "Enter the four components of B, separated by spaces:" &amp;lt;&amp;lt; std::endl;&lt;br /&gt; std::cin &amp;gt;&amp;gt; b0 &amp;gt;&amp;gt; b1 &amp;gt;&amp;gt; b2 &amp;gt;&amp;gt; b3;&lt;br /&gt; &lt;br /&gt; // Calculate contraction and display result&lt;br /&gt; double result = contract(a0, a1, a2, a3, b0, b1, b2, b3);&lt;br /&gt; std::cout &amp;lt;&amp;lt; "A.B = " &amp;lt;&amp;lt; result &amp;lt;&amp;lt; std::endl;&lt;br /&gt; &lt;br /&gt; return 0; &lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;No major improvement there, but we've moved the contraction code out into a function so that we can reuse it. Still, it's pretty ugly to pass eight doubles into the function. Much nicer would be to pass two four-vectors; after all, that is what the contraction works with, at a higher level:&lt;br /&gt;&lt;pre name="code" class="cpp"&gt;&lt;br /&gt;#include &amp;lt;iostream&amp;gt;&lt;br /&gt;&lt;br /&gt;class FourVector {&lt;br /&gt; public:&lt;br /&gt;  double x0;&lt;br /&gt;  double x1;&lt;br /&gt;  double x2;&lt;br /&gt;  double x3;&lt;br /&gt;};&lt;br /&gt;&lt;br /&gt;double contract(FourVector a, FourVector b)&lt;br /&gt;{&lt;br /&gt; return a.x0*b.x0 - a.x1*b.x1 - a.x2*b.x2 - a.x3*b.x3;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;int main()&lt;br /&gt;{&lt;br /&gt; // Create some variables&lt;br /&gt; Fourvector a, b;&lt;br /&gt; &lt;br /&gt; // Prompt and read eight components&lt;br /&gt; std::cout &amp;lt;&amp;lt; "Enter the four components of A, separated by spaces:" &amp;lt;&amp;lt; std::endl;&lt;br /&gt; std::cin &amp;gt;&amp;gt; a.x0 &amp;gt;&amp;gt; a.x1 &amp;gt;&amp;gt; a.x2 &amp;gt;&amp;gt; a.x3;&lt;br /&gt; std::cout &amp;lt;&amp;lt; "Enter the four components of B, separated by spaces:" &amp;lt;&amp;lt; std::endl;&lt;br /&gt; std::cin &amp;gt;&amp;gt; b.x0 &amp;gt;&amp;gt; b.x1 &amp;gt;&amp;gt; b.x2 &amp;gt;&amp;gt; b.x3;&lt;br /&gt; &lt;br /&gt; // Calculate contraction and display result&lt;br /&gt; double result = contract(a, b);&lt;br /&gt; std::cout &amp;lt;&amp;lt; "A.B = " &amp;lt;&amp;lt; result &amp;lt;&amp;lt; std::endl;&lt;br /&gt; &lt;br /&gt; return 0;&lt;br /&gt;}&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;Things are a little neater now, but still not ideal. For a start, we have public member variables in our class. This is generally considered bad design, so we should make them private and instead provide alternative mechanisms for accessing them. In this case, the class lends itself perfectly towards the use of operator overloading. The idea here is to define what it means to "multiply" two four-vectors together. We can define operator*() as a member-function of the FourVector class:&lt;br /&gt;&lt;pre name="code" class="cpp"&gt;&lt;br /&gt;#include &amp;lt;iostream&amp;gt;&lt;br /&gt;&lt;br /&gt;class FourVector {&lt;br /&gt; public:&lt;br /&gt;  double x0;&lt;br /&gt;  double x1;&lt;br /&gt;  double x2;&lt;br /&gt;  double x3;&lt;br /&gt;  double operator*(const FourVector&amp;amp; b);&lt;br /&gt;};&lt;br /&gt;&lt;br /&gt;double FourVector::operator*(const FourVector&amp;amp; b)&lt;br /&gt;{&lt;br /&gt; return x0*b.x0 - x1*b.x1 - x2*b.x2 - x3*b.x3;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;int main()&lt;br /&gt;{&lt;br /&gt; // Create some variables&lt;br /&gt; Fourvector a, b;&lt;br /&gt; &lt;br /&gt; // Prompt and read eight components&lt;br /&gt; std::cout &amp;lt;&amp;lt; "Enter the four components of A, separated by spaces:" &amp;lt;&amp;lt; std::endl;&lt;br /&gt; std::cin &amp;gt;&amp;gt; a.x0 &amp;gt;&amp;gt; a.x1 &amp;gt;&amp;gt; a.x2 &amp;gt;&amp;gt; a.x3;&lt;br /&gt; std::cout &amp;lt;&amp;lt; "Enter the four components of B, separated by spaces:" &amp;lt;&amp;lt; std::endl;&lt;br /&gt; std::cin &amp;gt;&amp;gt; b.x0 &amp;gt;&amp;gt; b.x1 &amp;gt;&amp;gt; b.x2 &amp;gt;&amp;gt; b.x3;&lt;br /&gt; &lt;br /&gt; // Calculate contraction and display result&lt;br /&gt; double result = a * b;&lt;br /&gt; std::cout &amp;lt;&amp;lt; "A.B = " &amp;lt;&amp;lt; result &amp;lt;&amp;lt; std::endl;&lt;br /&gt; &lt;br /&gt; return 0;&lt;br /&gt;}&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;As you can see, we have now defined enough code that the statement result = a * b; works as expected, producing the contraction of the two. The member function, when called, is bound to object a (in this case), so x0, x1, x2, x3 all refer to a's variables. We have to refer to the variables in b (passed as an argument to the operator) explicitly as b.x0 etc.&lt;br /&gt;&lt;br /&gt;We still haven't hidden the member variables. To do this, we need to add a couple more things: a constructor, and a stream operator.&lt;br /&gt;&lt;pre name="code" class="cpp"&gt;&lt;br /&gt;#include &amp;lt;iostream&amp;gt;&lt;br /&gt;&lt;br /&gt;class FourVector {&lt;br /&gt; public:&lt;br /&gt;  FourVector() : x0(0), x1(0), x2(0), x3(0) {};&lt;br /&gt;  FourVector(double i0, double i1, double i2, double i3)&lt;br /&gt;   : x0(i0), x1(i1), x2(i2), x3(i3) {};&lt;br /&gt;  double operator*(const FourVector&amp;amp; b);&lt;br /&gt;  friend std::istream&amp;amp; operator&amp;gt;&amp;gt;(std::istream&amp;amp; in, FourVector&amp;amp; v);&lt;br /&gt; private:&lt;br /&gt;  double x0;&lt;br /&gt;  double x1;&lt;br /&gt;  double x2;&lt;br /&gt;  double x3;&lt;br /&gt;};&lt;br /&gt;&lt;br /&gt;double FourVector::operator*(const FourVector&amp;amp; b)&lt;br /&gt;{&lt;br /&gt; return x0*b.x0 - x1*b.x1 - x2*b.x2 - x3*b.x3;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;std::istream&amp;amp; operator&amp;gt;&amp;gt;(std::istream&amp;amp; in, FourVector&amp;amp; v)&lt;br /&gt;{&lt;br /&gt; in &amp;gt;&amp;gt; v.x0 &amp;gt;&amp;gt; v.x1 &amp;gt;&amp;gt; v.x2 &amp;gt;&amp;gt; v.x3;&lt;br /&gt; return in;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;int main()&lt;br /&gt;{&lt;br /&gt; // Create some variables&lt;br /&gt; Fourvector a, b;&lt;br /&gt; &lt;br /&gt; // Prompt and read eight components&lt;br /&gt; std::cout &amp;lt;&amp;lt; "Enter the four components of A, separated by spaces:" &amp;lt;&amp;lt; std::endl;&lt;br /&gt; std::cin &amp;gt;&amp;gt; a;&lt;br /&gt; std::cout &amp;lt;&amp;lt; "Enter the four components of B, separated by spaces:" &amp;lt;&amp;lt; std::endl;&lt;br /&gt; std::cin &amp;gt;&amp;gt; b;&lt;br /&gt; &lt;br /&gt; // Calculate contraction and display result&lt;br /&gt; double result = a * b;&lt;br /&gt; std::cout &amp;lt;&amp;lt; "A.B = " &amp;lt;&amp;lt; result &amp;lt;&amp;lt; std::endl;&lt;br /&gt; &lt;br /&gt; return 0;&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;There are a few things to note here. First, the default constructor:&lt;br /&gt;&lt;pre name="code" class="cpp"&gt;FourVector() : x0(0), x1(0), x2(0), x3(0) {};&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;Constructors are named identically to the class they construct, and have no return type. This particular one takes no arguments, has an initialiser list which sets all the member variables to zero, and has an empty function body -- {};&lt;br /&gt;&lt;br /&gt;The other constructor allows one to construct a FourVector object by passing four doubles into the constructor:&lt;br /&gt;&lt;pre name="code" class="cpp"&gt;&lt;br /&gt;double E, px, py, pz;&lt;br /&gt;// Some code which sets E and p goes here&lt;br /&gt;FourVector EnergyMomentum(E, px, py, pz);&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;Finally, operator&amp;gt;&amp;gt; is a little different. Because the order is stream &amp;gt;&amp;gt; FourVector, we can't make the operator&amp;gt;&amp;gt; a member of FourVector (since it would expect the FourVector object to be passed first!). Furthermore, we need access to the private member variables, or we have nothing to read into. This is a bit of a dilemma, until we use the `friend' statement. This tells the compiler to let a function which is defined outside the class have access to internal class members; precisely what we want here!&lt;br /&gt;&lt;br /&gt;You'll notice that the mechanism by which we got here is quite convoluted; we've added constructors and defined operators, and the class is far from complete -- for it to be generally useful we'd need an output operator, other mathematical operations and more. The amount of code has increased, as has the complexity of the overall solution. But look at the code inside main()... this is now considerably simpler. If we ignore comments and don't prompt the user, we can now write exactly the code which corresponds to the mathematical concept:&lt;br /&gt;&lt;pre name="code" class="cpp"&gt;&lt;br /&gt;int main()&lt;br /&gt;{&lt;br /&gt; FourVector a, b;&lt;br /&gt; std::cin &amp;gt;&amp;gt; a &amp;gt;&amp;gt; b;&lt;br /&gt; double result = a * b;&lt;br /&gt; std::cout &amp;gt;&amp;gt; result &amp;gt;&amp;gt; std::endl;&lt;br /&gt; return 0;&lt;br /&gt;}&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;The best part is that the FourVector class is reusable, and sufficiently powerful to allow this abstraction to be carried forward to develop a whole system for tensor calculus, expressed in terms of the mathematical objects involved!&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4470666517647633822-8247411688037014544?l=physical-thought.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://physical-thought.blogspot.com/feeds/8247411688037014544/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4470666517647633822&amp;postID=8247411688037014544' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4470666517647633822/posts/default/8247411688037014544'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4470666517647633822/posts/default/8247411688037014544'/><link rel='alternate' type='text/html' href='http://physical-thought.blogspot.com/2008/10/contraction-of-four-vectors-c-exercise.html' title='Contraction of Four-Vectors: A C++ Exercise'/><author><name>Andrew J. Bennieston</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://bp2.blogger.com/_zi39n2uYgqg/R3f879w2IHI/AAAAAAAAAAY/IsPK0LU5Duc/S220/avatar.png'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4470666517647633822.post-1043841875271898037</id><published>2008-10-02T22:51:00.002+01:00</published><updated>2008-10-02T22:58:29.670+01:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='mathematica'/><title type='text'>More Mathematica Visualisations: Non-Orientable Foo</title><content type='html'>Here are some more random visualisations I created in Mathematica. I uploaded the videos to YouTube a week ago with the intention of posting links here, but never got round to it. The code I used to generate most of these is fairly straightforward. For the Möbius Strip Traversal:&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 153);"&gt;R := 4&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 153);"&gt;w := 1&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 153);"&gt;Animate[Show[&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 153);"&gt;  ParametricPlot3D[{(R + s Cos[t/2]) Cos[t], (R + s Cos[t/2]) Sin[t], &lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 153);"&gt;    s Sin[t/2]}, {s, -w, w}, {t, 0, 2 \[Pi]}, Boxed -&gt; False, &lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 153);"&gt;   Axes -&gt; False, Mesh -&gt; 3, &lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 153);"&gt;   PlotStyle -&gt; &lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 153);"&gt;    Directive[Opacity[0.9], Orange, Specularity[White, 40]], &lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 153);"&gt;   BoundaryStyle -&gt; Directive[Black]], &lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 153);"&gt;  Graphics3D[Sphere[{R Cos[v], R Sin[v], 0}, 0.5]]], {v, 0, 2 \[Pi], &lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 153);"&gt;  0.05}, DisplayAllSteps -&gt; True]&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;And for the rotating Klein Bottle,&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 153);"&gt;Kx = 6 Cos[u] (1 + Sin[u]);&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 153);"&gt;Ky = 16 Sin[u];&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 153);"&gt;Kr = 4 (1 - Cos[u]/2);&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 153);"&gt;X = If[\[Pi] &lt;&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 153);"&gt;   Kx + Kr Cos[v + \[Pi]],&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 153);"&gt;   Kx + Kr Cos[u] Cos[v]];&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 153);"&gt;Y = If[\[Pi] &lt;&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 153);"&gt;   Ky,&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 153);"&gt;   Ky + Kr Sin[u] Cos[v]];&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 153);"&gt;Z = Kr Sin[v];&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 153);"&gt;ParametricPlot3D[{X, Y, Z}, {u, 0, 2 \[Pi]}, {v, -\[Pi], \[Pi]}, &lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 153);"&gt; Boxed -&gt; False, Axes -&gt; False, &lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 153);"&gt; PlotStyle -&gt; &lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 153);"&gt;  Directive[Opacity[0.75], Orange, Specularity[White, 40]]]&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 153);"&gt;Animate[ParametricPlot3D[{X, Y, Z}, {u, 0, &lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 153);"&gt;   2 \[Pi]}, {v, -\[Pi], \[Pi]}, Boxed -&gt; False, Axes -&gt; False, &lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 153);"&gt;  PlotStyle -&gt; &lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 153);"&gt;   Directive[Opacity[0.75], Orange, Specularity[White, 40]], &lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 153);"&gt;  ViewPoint -&gt; {5 Cos[\[Theta]], 5 Sin[\[Theta]], 5}], {\[Theta], 0, &lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 153);"&gt;  2 \[Pi], 0.1}, DisplayAllSteps -&gt; True]&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Möbius Strip&lt;/b&gt;&lt;br /&gt;&lt;object width="425" height="344"&gt;&lt;param name="movie" value="http://www.youtube.com/v/L48RBsxP2B4&amp;hl=en&amp;fs=1"&gt;&lt;/param&gt;&lt;param name="allowFullScreen" value="true"&gt;&lt;/param&gt;&lt;embed src="http://www.youtube.com/v/L48RBsxP2B4&amp;hl=en&amp;fs=1" type="application/x-shockwave-flash" allowfullscreen="true" width="425" height="344"&gt;&lt;/embed&gt;&lt;/object&gt;&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Klein Bottle&lt;/b&gt;&lt;br /&gt;(Technically, a Klein-Bottle immersed in 3D space)&lt;br /&gt;&lt;object width="425" height="344"&gt;&lt;param name="movie" value="http://www.youtube.com/v/vBnUafDV6f8&amp;hl=en&amp;fs=1"&gt;&lt;/param&gt;&lt;param name="allowFullScreen" value="true"&gt;&lt;/param&gt;&lt;embed src="http://www.youtube.com/v/vBnUafDV6f8&amp;hl=en&amp;fs=1" type="application/x-shockwave-flash" allowfullscreen="true" width="425" height="344"&gt;&lt;/embed&gt;&lt;/object&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4470666517647633822-1043841875271898037?l=physical-thought.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://physical-thought.blogspot.com/feeds/1043841875271898037/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4470666517647633822&amp;postID=1043841875271898037' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4470666517647633822/posts/default/1043841875271898037'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4470666517647633822/posts/default/1043841875271898037'/><link rel='alternate' type='text/html' href='http://physical-thought.blogspot.com/2008/10/more-mathematica-visualisations-non.html' title='More Mathematica Visualisations: Non-Orientable Foo'/><author><name>Andrew J. Bennieston</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://bp2.blogger.com/_zi39n2uYgqg/R3f879w2IHI/AAAAAAAAAAY/IsPK0LU5Duc/S220/avatar.png'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4470666517647633822.post-1957972002595873364</id><published>2008-09-28T11:47:00.008+01:00</published><updated>2008-09-28T12:07:50.292+01:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='statistics'/><category scheme='http://www.blogger.com/atom/ns#' term='projects'/><category scheme='http://www.blogger.com/atom/ns#' term='decadence factor'/><category scheme='http://www.blogger.com/atom/ns#' term='graph'/><category scheme='http://www.blogger.com/atom/ns#' term='mathematica'/><title type='text'>Decadence Factors: Curve Fitting</title><content type='html'>Some months ago I made a post about &lt;a href="http://physical-thought.blogspot.com/2008/06/decadence-factors-ii-decadence-harder.html"&gt;Decadence Factors&lt;/a&gt;. These I defined to be the total electricity consumption of a given country, divided by its population (i.e. electricity consumption per capita). The data was obtained from the CIA World Factbook.&lt;br /&gt;&lt;br /&gt;Going back over my old posts, a couple of days ago, I noticed that the `top 20' graph in my earlier post had what looked like an exponential decay curve, so I set out to find a fit for the decadence vs. position in list, with the most decadent country sitting at position 1.&lt;br /&gt;&lt;br /&gt;I decided to use Mathematica because I've been playing with it again recently, and it proved easy to import the tab-separated data I'd previously used in Gnuplot;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 153);"&gt;data = Import["decadence.csv", "Table"]&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;This imports the data into a nested list of the form {{Name,Factor},{Name,Factor},...}. In order to fit the data (or plot it as a list) I needed the decadence factors in a list without the country names. Easily done:&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 153);"&gt;factors = Transpose[data][[2]]&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;With this achieved, I tried two kinds of fit. The first, a power series up to order &lt;pre style="display: inline;" lang="eq.latex"&gt;x^{120}&lt;/pre&gt;:&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 153);"&gt;fit = Fit[factors, Table[x^n, {n, 0, 120}], x]&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;In the plot below, the fit curve is shown in red, and the original decadence data points are shown in blue. The power series is an extremely good fit, but almost useless for further analysis.&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_zi39n2uYgqg/SN9i2QfEI7I/AAAAAAAAANA/vrZNYTW-pUw/s1600-h/decadence-power-fit.png"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer;" src="http://3.bp.blogspot.com/_zi39n2uYgqg/SN9i2QfEI7I/AAAAAAAAANA/vrZNYTW-pUw/s400/decadence-power-fit.png" alt="" id="BLOGGER_PHOTO_ID_5251024374815007666" border="0" /&gt;&lt;/a&gt;The second fit I tried was of the form &lt;pre style="display: inline;" lang="eq.latex"&gt;A\exp(-Bx)&lt;/pre&gt;. Mathematica fit the curve with the parameters:&lt;br /&gt;&lt;span style="color: rgb(153, 0, 0);"&gt;A = 17032.5&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(153, 0, 0);"&gt;B = 0.0272113&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;The fit command was:&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 153);"&gt;fit2 = FindFit[factors, A Exp[-B x], {A, B}, x]&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;This wasn't quite such a good fit, but it's close enough for us to be able to do a little further work. Again, the red line is the fit curve, the blue points are the original data.&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_zi39n2uYgqg/SN9joIInqnI/AAAAAAAAANI/IIOynCrp_g4/s1600-h/decadence-exp-fit.png"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer;" src="http://1.bp.blogspot.com/_zi39n2uYgqg/SN9joIInqnI/AAAAAAAAANI/IIOynCrp_g4/s400/decadence-exp-fit.png" alt="" id="BLOGGER_PHOTO_ID_5251025231566842482" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;The nice thing about the exponential fit is that it's easy to invert. That is, given a decadence factor, we can work out an approximation of that country's decadence ranking; their position in the list! For a decadence factor F, and a rank R, the fit provided by Mathematica gives:&lt;br /&gt;&lt;pre lang="eq.latex"&gt;&lt;br /&gt;F(R) = 17032.5\exp(-0.0272113 R)&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;Inverting this, we get:&lt;br /&gt;&lt;pre lang="eq.latex"&gt;&lt;br /&gt;R(F) = \frac{-1}{0.0272113}\log\left(\frac{F}{17032.5}\right)&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;This approximation would place Sweden, with a decadence factor of 14825.2 in rank 5.10063. Sweden is actually ranked 5th, so the approximation agrees reasonably with the data.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4470666517647633822-1957972002595873364?l=physical-thought.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://physical-thought.blogspot.com/feeds/1957972002595873364/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4470666517647633822&amp;postID=1957972002595873364' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4470666517647633822/posts/default/1957972002595873364'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4470666517647633822/posts/default/1957972002595873364'/><link rel='alternate' type='text/html' href='http://physical-thought.blogspot.com/2008/09/decadence-factors-curve-fitting.html' title='Decadence Factors: Curve Fitting'/><author><name>Andrew J. Bennieston</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://bp2.blogger.com/_zi39n2uYgqg/R3f879w2IHI/AAAAAAAAAAY/IsPK0LU5Duc/S220/avatar.png'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://3.bp.blogspot.com/_zi39n2uYgqg/SN9i2QfEI7I/AAAAAAAAANA/vrZNYTW-pUw/s72-c/decadence-power-fit.png' height='72' width='72'/><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4470666517647633822.post-4145839711263449372</id><published>2008-09-25T23:21:00.003+01:00</published><updated>2008-09-25T23:34:10.047+01:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='statistics'/><category scheme='http://www.blogger.com/atom/ns#' term='random numbers'/><category scheme='http://www.blogger.com/atom/ns#' term='simulation'/><category scheme='http://www.blogger.com/atom/ns#' term='physics'/><category scheme='http://www.blogger.com/atom/ns#' term='mathematica'/><title type='text'>Visualising Random Walks</title><content type='html'>I've been playing with visualisation in Mathematica recently; particularly with the &lt;span style="color: rgb(0, 102, 0);"&gt;Animate[] &lt;/span&gt;function, allowing a representation (graphical or otherwise) to be viewed as some parameter, or list thereof, changes within some defined range. I used it to produce the &lt;a href="http://physical-thought.blogspot.com/2008/09/lisp-taylor-expansion-of-exponential.html"&gt;earlier video&lt;/a&gt; I posted, showing how the Taylor series approximation of Exp[x] approaches the true Exp[x] function as the number of terms in the expansion increases.&lt;br /&gt;&lt;br /&gt;Today I was trying out random walks in Mathematica. They turn out to be fairly easy to code; random number generation is built in, as is a mechanism of accumulating steps into a list. In order to generate a list of points corresponding to a 1000-step random walk with origin (0,0), the following command suffices:&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 102, 0);"&gt;Points = Accumulate[RandomChoice[{{-1, 0}, {1, 0}, {0, 1}, {0, -1}}, 1000]]&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;In order to visualise the progress of the walk step-by-step, in Mathematica, I used the following &lt;span style="color: rgb(0, 102, 0);"&gt;Animate&lt;/span&gt; command:&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 102, 0);"&gt;Animate[Graphics[{Red, Line[{Points[[1 ;; n]]}]}, &lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 102, 0);"&gt;  PlotRange -&gt; {{-Max[Points], Max[Points]}, {-Max[Points], &lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 102, 0);"&gt;     Max[Points]}}], {n, 1, 1000, 1}, DisplayAllSteps -&gt; True]&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;I'll go through exactly what this is doing... The &lt;span style="color: rgb(0, 102, 0);"&gt;Graphics[...]&lt;/span&gt; part produces a 2D Graphics object. In this case, it consists of a line whose points are given by the list produced in the earlier command. The &lt;span style="color: rgb(0, 102, 0);"&gt;Points[[1;;n]]&lt;/span&gt; part allows &lt;span style="color: rgb(0, 102, 0);"&gt;Animate&lt;/span&gt; to work its magic...&lt;br /&gt;&lt;br /&gt;By telling Animate that we want to see n run from 1 to 1000, in steps of 1, displaying each step as we go, we obtain a new Graphics object each step, with a line containing the first n points of the &lt;span style="color: rgb(0, 102, 0);"&gt;Points&lt;/span&gt; list we generated earlier. Adding a few options to keep the plot range constant across all of these new visualisations (otherwise, Mathematica would rescale the axes, and the resulting image would `flicker'), we get a video of each step of the walk being added on to the previous steps.&lt;br /&gt;&lt;br /&gt;Unfortunately, for some reason I couldn't get this to directly export in that format. I managed to produce an AVI file which showed the Animate box, but didn't animate the behaviour correctly. So instead, I produced a &lt;span style="color: rgb(0, 102, 0);"&gt;Table[]&lt;/span&gt; of Graphics objects, and exported that using one image for each frame of the AVI, using the command:&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 102, 0);"&gt;Export["random.avi", &lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 102, 0);"&gt; Table[Graphics[{Red, Line[{Points[[1 ;; n]]}]}, &lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 102, 0);"&gt;   PlotRange -&gt; {{-Max[Points], Max[Points]}, {-Max[Points], &lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 102, 0);"&gt;      Max[Points]}}], {n, 1, 1000, 1}]]&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;The result, after transcoding to MPEG-4 to dramatically reduce the filesize, and uploading to YouTube, is included below!&lt;br /&gt;&lt;br /&gt;&lt;object width="425" height="344"&gt;&lt;param name="movie" value="http://www.youtube.com/v/KfE1Saz4NSI&amp;hl=en&amp;fs=1"&gt;&lt;/param&gt;&lt;param name="allowFullScreen" value="true"&gt;&lt;/param&gt;&lt;embed src="http://www.youtube.com/v/KfE1Saz4NSI&amp;hl=en&amp;fs=1" type="application/x-shockwave-flash" allowfullscreen="true" width="425" height="344"&gt;&lt;/embed&gt;&lt;/object&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4470666517647633822-4145839711263449372?l=physical-thought.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://physical-thought.blogspot.com/feeds/4145839711263449372/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4470666517647633822&amp;postID=4145839711263449372' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4470666517647633822/posts/default/4145839711263449372'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4470666517647633822/posts/default/4145839711263449372'/><link rel='alternate' type='text/html' href='http://physical-thought.blogspot.com/2008/09/visualising-random-walks.html' title='Visualising Random Walks'/><author><name>Andrew J. Bennieston</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://bp2.blogger.com/_zi39n2uYgqg/R3f879w2IHI/AAAAAAAAAAY/IsPK0LU5Duc/S220/avatar.png'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4470666517647633822.post-3529823740812965746</id><published>2008-09-24T14:23:00.008+01:00</published><updated>2008-09-24T15:20:52.043+01:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='lisp'/><category scheme='http://www.blogger.com/atom/ns#' term='projects'/><category scheme='http://www.blogger.com/atom/ns#' term='recursion'/><category scheme='http://www.blogger.com/atom/ns#' term='factorial'/><category scheme='http://www.blogger.com/atom/ns#' term='programming'/><category scheme='http://www.blogger.com/atom/ns#' term='mathematics'/><title type='text'>LISP: Taylor Expansion of Exponential Function</title><content type='html'>The code below defines a LISP function to approximate &lt;pre style="display: inline;" lang="eq.latex"&gt;\exp(x)&lt;/pre&gt; using a Taylor expansion. I first had to define the functions factorial (x!) and pow (raise x to the power n) in order to define the Taylor expansion of exp(x),&lt;br /&gt;&lt;pre lang="eq.latex"&gt;&lt;br /&gt;\exp(x) \approx 1 + x + \frac{x^2}{2!} + \ldots + \frac{x^n}{n!} + \ldots&lt;br /&gt;&lt;/pre&gt;&lt;pre style="color: rgb(0, 102, 0);"&gt;(defun factorial(x)&lt;br /&gt; (let ((acc 1))&lt;br /&gt;(dotimes (i x)&lt;br /&gt;  (setf acc (* acc (+ i 1))))&lt;br /&gt;  acc))&lt;br /&gt;&lt;br /&gt;(defun pow(x n)&lt;br /&gt; (let ((acc 1))&lt;br /&gt;(dotimes (i n)&lt;br /&gt;  (setf acc (* acc x)))&lt;br /&gt;acc))&lt;br /&gt;&lt;br /&gt;(defun taylor-exp(x)&lt;br /&gt; (let ((a 1) (b x) (n 1) (tolerance 0.00001))&lt;br /&gt;(loop&lt;br /&gt;  (setf a (+ a (/ (pow x n) (factorial n))))&lt;br /&gt;  (setf n (+ n 1))&lt;br /&gt;  (if (&lt; (abs (- b a)) tolerance)   (return (* a 1.0))   (setf b a)))))&lt;/pre&gt;&lt;br /&gt;And here's a test run comparing the built-in (exp 2) with (taylor-exp 2):&lt;br /&gt;&lt;pre style="color: rgb(0, 0, 153);"&gt;(exp 2)&lt;br /&gt;7.389056&lt;br /&gt;(taylor-exp 2)&lt;br /&gt;7.389055&lt;/pre&gt;&lt;br /&gt;With a little more fine-tuning of the tolerance parameter, the two could agree to arbitrary precision!&lt;br /&gt;&lt;br /&gt;Here's a video produced using Mathematica, showing the convergence of the Taylor series to the true Exp[x]. It was produced using Animate[Plot[ Evaluate[{Exp[x], Normal[Series[Exp[x], {x, 0, n}]]}], {x, 0, 5}, PlotRange -&amp;gt; 200, PlotStyle -&amp;gt; Thick], {n, 1, 12, 2}]&lt;br /&gt;&lt;br /&gt;&lt;object width="425" height="350"&gt; &lt;param name="movie" value="http://www.youtube.com/v/Cg-1lciuldM"&gt; &lt;/param&gt; &lt;embed src="http://www.youtube.com/v/Cg-1lciuldM" type="application/x-shockwave-flash" width="425" height="350"&gt; &lt;/embed&gt; &lt;/object&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4470666517647633822-3529823740812965746?l=physical-thought.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://physical-thought.blogspot.com/feeds/3529823740812965746/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4470666517647633822&amp;postID=3529823740812965746' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4470666517647633822/posts/default/3529823740812965746'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4470666517647633822/posts/default/3529823740812965746'/><link rel='alternate' type='text/html' href='http://physical-thought.blogspot.com/2008/09/lisp-taylor-expansion-of-exponential.html' title='LISP: Taylor Expansion of Exponential Function'/><author><name>Andrew J. Bennieston</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://bp2.blogger.com/_zi39n2uYgqg/R3f879w2IHI/AAAAAAAAAAY/IsPK0LU5Duc/S220/avatar.png'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4470666517647633822.post-7592829108502088918</id><published>2008-09-24T08:23:00.015+01:00</published><updated>2008-09-24T11:51:40.968+01:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='lagrangian'/><category scheme='http://www.blogger.com/atom/ns#' term='gauge theories'/><category scheme='http://www.blogger.com/atom/ns#' term='noether'/><category scheme='http://www.blogger.com/atom/ns#' term='groups'/><category scheme='http://www.blogger.com/atom/ns#' term='electrodynamics'/><category scheme='http://www.blogger.com/atom/ns#' term='physics'/><category scheme='http://www.blogger.com/atom/ns#' term='hamiltonian'/><title type='text'>Symmetries, Conserved Quantities and Noether's Theorem</title><content type='html'>Following on from my posts on Lagrangian and Hamiltonian Mechanics [&lt;a href="http://physical-thought.blogspot.com/2008/09/lagrangian-mechanics-from-principle-of.html"&gt;1&lt;/a&gt;, &lt;a href="http://physical-thought.blogspot.com/2008/09/lagrangian-mechanics-from-euler.html"&gt;2&lt;/a&gt;, &lt;a href="http://physical-thought.blogspot.com/2008/09/lagrangian-mechanics-from-euler_20.html"&gt;3&lt;/a&gt;, &lt;a href="http://physical-thought.blogspot.com/2008/09/from-lagrangian-to-hamiltonian.html"&gt;4&lt;/a&gt;], I'd like to discuss one of the most amazing topics in physics. The consideration of the symmetries of physical laws and how those symmetries relate to conserved quantities, the fundamentally beautiful mathematics lying beneath, and the extent to which we can develop theories of the world around us from such simple concepts; these things continually inspire me and provoke my interest.&lt;br /&gt;&lt;br /&gt;I'll start by showing that the formulation of Lagrangian and Hamiltonian Mechanics, thus far, allows us to determine several conservation laws. Consider, for example, the &lt;span style="font-style: italic;"&gt;homogeneity&lt;/span&gt; of space. Space is homogeneous if the motion (or time-evolution) of a particle (or system thereof) is independent of absolute position. That is, the potential does not vary with absolute position (it can still vary with the vector distance between two particles, as an interaction potential, for example!)&lt;br /&gt;&lt;br /&gt;If we make a transformation &lt;pre style="display: inline;" lang="eq.latex"&gt;\mathbf{r}\rightarrow\mathbf{r}+\delta\mathbf{r}&lt;/pre&gt;, then the Lagrangian will also transform as &lt;pre style="display: inline;" lang="eq.latex"&gt;L \rightarrow L+\delta L&lt;/pre&gt;. For a single particle, we can Taylor expand as follows:&lt;br /&gt;&lt;pre lang="eq.latex"&gt;&lt;br /&gt;L(\mathbf{r}+\delta\mathbf{r},\mathbf{v}) = L(\mathbf{r},\mathbf{v})+\frac{\partial L}{\partial x}\delta x+\frac{\partial L}{\partial y}\delta y+\frac{\partial L}{\partial z}\delta z&lt;/pre&gt;&lt;br /&gt;Which we can use to write&lt;br /&gt;&lt;pre lang="eq.latex"&gt;\delta L = \frac{\partial L}{\partial \mathbf{r}}\cdot\delta\mathbf{r}&lt;/pre&gt;&lt;br /&gt;&lt;pre style="display: inline;" lang="eq.latex"&gt;\frac{\partial L}{\partial \mathbf{r}}&lt;/pre&gt; is a vector quantity; each component is the derivative of L with respect to the corresponding coordinate of &lt;span style="font-weight: bold;"&gt;r&lt;/span&gt;. For a single particle, then, &lt;pre style="display: inline;" lang="eq.latex"&gt;\frac{\partial L}{\partial \mathbf{r}}=\nabla L&lt;/pre&gt;.&lt;br /&gt;&lt;br /&gt;Homogeneity of space requires that &lt;pre style="display: inline;" lang="eq.latex"&gt;\delta L = 0&lt;/pre&gt;. Since &lt;pre style="display: inline;" lang="eq.latex"&gt;\delta \mathbf{r}&lt;/pre&gt; is arbitrary (and therefore not necessarily zero), we have that&lt;br /&gt;&lt;pre lang="eq.latex"&gt;&lt;br /&gt;\frac{\partial L}{\partial q_i} = 0 ~~~~~~ (\star)&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;This holds only if L does not depend on absolute position, otherwise there would be a contribution &lt;pre style="display: inline;" lang="eq.latex"&gt;\delta L&lt;/pre&gt; from many of the possible choices of &lt;pre style="display: inline;" lang="eq.latex"&gt;\delta\mathbf{r}&lt;/pre&gt;. Spatial dependence of e.g. V(x) implies spatial variation of L, and momentum would not be conserved.&lt;br /&gt;&lt;br /&gt;The Euler-Lagrange Equation applies for each coordinate in the vector &lt;span style="font-weight: bold;"&gt;r&lt;/span&gt;. The sum of these Euler-Lagrange Equations (ELEs) means that &lt;pre style="display: inline;" lang="eq.latex"&gt;(\star)&lt;/pre&gt; requires that:&lt;br /&gt;&lt;pre lang="eq.latex"&gt;&lt;br /&gt;\begin{multiline*}&lt;br /&gt;\frac{d}{dt}\frac{\partial L}{\partial \dot{q}_i} = 0 \\&lt;br /&gt;\Rightarrow p_i = \frac{\partial L}{\partial \dot{q}_i} ~~\mathrm{remains~constant}&lt;br /&gt;\end{multiline*}&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;We have, therefore, demonstrated the conservation of momentum as a result of requiring translational invariance. That is, &lt;span style="font-style: italic;"&gt;any canonical momenta whose conjugate coordinates do not appear explicitly in the Lagrangian are conserved.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Turning once again to time symmetries, let us re-derive the conservation of energy. If the Lagrangian is homogeneous in time, i.e. &lt;pre style="display: inline;" lang="eq.latex"&gt;L(q,\dot{q})~~\mathrm{not}~~L(q,\dot{q},t)&lt;/pre&gt;, then:&lt;br /&gt;&lt;pre lang="eq.latex"&gt;&lt;br /&gt;\frac{dL}{dt} = \sum_i \frac{\partial L}{\partial q_i}\dot{q}_i + \sum_i\frac{\partial L}{\partial \dot{q}_i}\ddot{q}_i&lt;/pre&gt;&lt;br /&gt;As L does not depend explicitly on time, there is no term &lt;pre style="display: inline;" lang="eq.latex"&gt;\frac{\partial L}{\partial t}&lt;/pre&gt; on the RHS. Sunstituting &lt;pre style="display: inline;" lang="eq.latex"&gt;\frac{\partial L}{\partial q_i}&lt;/pre&gt; from the ELE,&lt;br /&gt;&lt;pre lang="eq.latex"&gt;&lt;br /&gt;\frac{dL}{dt} = \sum_i\dot{q}_i\frac{d}{dt}\frac{\partial L}{\partial\dot{q}_i}+\sum_i\frac{\partial L}{\partial\dot{q}_i}\ddot{q}_i = \sum_i\frac{d}{dt}\left(\dot{q}_i\frac{\partial L}{\partial\dot{q}_i}\right)&lt;/pre&gt;&lt;pre lang="eq.latex"&gt;&lt;br /&gt;\begin{multiline*}&lt;br /&gt;\Rightarrow \frac{d}{dt}\sum_i\left( \dot{q}_i\frac{\partial L}{\partial\dot{q}_i}-L \right) = 0 \\&lt;br /&gt;\Rightarrow H = \sum_i \dot{q}_i\frac{\partial L}{\partial \dot{q}_i} - L~~~\mathrm{remains~constant}&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;The conservation of energy holds for any motion in a non-time-varying external field V(x)&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;We turn now to the isotropy of space, and show that angular momentum is conserved due to rotational invariance of the Lagrangian. Consider rotation by an angle &lt;pre style="display: inline;" lang="eq.latex"&gt;|\delta\theta|&lt;/pre&gt; (with a direction given by &lt;pre style="display: inline;" lang="eq.latex"&gt;\delta\theta&lt;/pre&gt;) about a vector. For small rotations, &lt;pre style="display: inline;" lang="eq.latex"&gt;\mathbf{r}\rightarrow \mathbf{r}+\delta\mathbf{r}&lt;/pre&gt;, with &lt;pre style="display: inline;" lang="eq.latex"&gt;\delta\mathbf{r} = \delta\theta\times r&lt;/pre&gt;. Each component of the velocity is also transformed by this rotation, &lt;pre style="display: inline;" lang="eq.latex"&gt;\delta\mathbf{v}=\delta\theta\times\mathbf{v}&lt;/pre&gt;.&lt;br /&gt;&lt;br /&gt;For a single body, we now impose the requirement that the Lagrangian be unchanged under such a rotation (i.e. we require space to be isotropic).&lt;br /&gt;&lt;pre lang="eq.latex"&gt;\delta L = \sum_i\left( \frac{\partial L}{\partial q_i}\cdot\delta r_i + \frac{\partial L}{\partial\dot{q}_i}\cdot\delta v_i \right) = 0&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;We can replace &lt;pre style="display: inline;" lang="eq.latex"&gt;\frac{\partial L}{\partial v_i}&lt;/pre&gt; by the vector canonical momentum &lt;pre style="display: inline;" lang="eq.latex"&gt;p_i&lt;/pre&gt;, and &lt;pre style="display: inline;" lang="eq.latex"&gt;\frac{\partial L}{\partial q_i}&lt;/pre&gt; by &lt;pre style="display: inline;" lang="eq.latex"&gt;\dot{p}_i&lt;/pre&gt;, leaving:&lt;br /&gt;&lt;pre lang="eq.latex"&gt;\begin{multiline*}&lt;br /&gt;\left(\dot{\mathbf{p}}\cdot\delta\mathbf{r} + \mathbf{p}\cdot\delta\mathbf{v}\right) = 0 \\&lt;br /&gt;\Rightarrow \dot{\mathbf{p}}\cdot\left(\delta\theta\times \mathbf{r}\right) + \mathbf{p}\cdot\left(\delta\theta\times\mathbf{v}\right) = 0&lt;br /&gt;\end{multiline*}&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;Since &lt;pre style="display: inline;" lang="eq.latex"&gt;\mathbf{a}\cdot\left(\mathbf{b}\times\mathbf{c}\right) = \mathbf{b}\cdot\left(\mathbf{c}\times\mathbf{a}\right)&lt;/pre&gt;,&lt;br /&gt;&lt;pre lang="eq.latex"&gt;&lt;br /&gt;\begin{multiline*}&lt;br /&gt;\delta\theta\cdot\left(\left[\mathbf{r}\times\dot{\mathbf{p}}\right]+\left[\mathbf{v}\times\mathbf{p}\right]\right)=0\\&lt;br /&gt;\Rightarrow\delta\theta\cdot\frac{d}{dt}\left(\mathbf{r}\times\mathbf{p}\right)=0\end{multiline*}&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;Since &lt;pre style="display: inline;" lang="eq.latex"&gt;\delta\theta&lt;/pre&gt; is arbitrary, this requires that &lt;pre style="display: inline;" lang="eq.latex"&gt;\mathbf{r}\times\mathbf{p}&lt;/pre&gt; does not change in time, hence angular momentum is a conserved quantity.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Hamilton's Equations&lt;/span&gt;&lt;br /&gt;Using the ideas presented above, I'm going to take a moment to derive Hamilton's Equations, which will prove useful later on.&lt;br /&gt;&lt;br /&gt;Consider changes in the Lagrangian L, according to&lt;br /&gt;&lt;pre lang="eq.latex"&gt;dL = \sum_i\frac{\partial L}{\partial\dot{q}_i}\,d\dot{q}_i + \sum_i\frac{\partial L}{\partial q_i}\,dq_i&lt;/pre&gt;&lt;br /&gt;This can be written:&lt;br /&gt;&lt;pre lang="eq.latex"&gt;dL=\sum_ip_i\,d\dot{q}_i+\sum_i\dot{p}_i\,dq_i&lt;/pre&gt;&lt;br /&gt;since &lt;pre style="display: inline;" lang="eq.latex"&gt;\frac{\partial L}{\partial q_i}=\dot{p}_i&lt;/pre&gt; and &lt;pre style="display: inline;" lang="eq.latex"&gt;\frac{\partial L}{\partial\dot{q}_i}=p_i&lt;/pre&gt;.&lt;br /&gt;Using,&lt;br /&gt;&lt;pre lang="eq.latex"&gt;\sum_i p_i\,d\dot{q}_i = d\left(\sum_i p_i q_i\right) - \sum_i\dot{q}_i\,dp_i&lt;/pre&gt;,&lt;br /&gt;&lt;pre lang="eq.latex"&gt;&lt;br /&gt;d\left(\sum_i p_i\dot{q}_i - L\right) = -\sum_i\dot{p}_i\,dq_i+\sum_i\dot{q}_i\,dp_i&lt;/pre&gt;&lt;br /&gt;The argument of the differential on the left is the Hamiltonian, H, &lt;pre style="display: inline;" lang="eq.latex"&gt;H(q,p,t)=\sum_i p_i\dot{q}_i - L&lt;/pre&gt;, therefore:&lt;br /&gt;&lt;pre lang="eq.latex"&gt;dH = -\sum_i\dot{p}_i\,dq_i + \sum_i\dot{q}_i\,dp_i&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;From here, we can obtain Hamilton's Equations:&lt;br /&gt;&lt;pre lang="eq.latex"&gt;\begin{align*}&lt;br /&gt;\dot{q}_i &amp;amp;= \frac{\partial H}{\partial p_i}\\&lt;br /&gt;\dot{p_i} &amp;amp;= \frac{\partial H}{\partial q_i}&lt;br /&gt;\end{align*}&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;For m coordinates (and m momenta), Hamilton's Equations form a system of 2m first-order differential equations, compared to the m second-order equations in the Lagrangian treatment.&lt;br /&gt;&lt;br /&gt;The total time derivative,&lt;br /&gt;&lt;pre lang="eq.latex"&gt;&lt;br /&gt;\frac{dH}{dt}=\frac{\partial H}{\partial t}+\sum_i\frac{\partial H}{\partial q_i}\dot{q}_i+\sum_i\frac{\partial H}{\partial p_i}\dot{p}_i&lt;/pre&gt;&lt;br /&gt;Substituting Hamilton's equations for &lt;pre style="display: inline;" lang="eq.latex"&gt;\dot{q}_i, \dot{p}_i&lt;/pre&gt;, the last two terms cancel, so&lt;br /&gt;&lt;pre lang="eq.latex"&gt;\frac{dH}{dt} = \frac{\partial H}{\partial t}&lt;/pre&gt;&lt;br /&gt;and if H does not depend &lt;span style="font-style: italic;"&gt;explicitly&lt;/span&gt; on time, &lt;pre style="dispay: inline;" lang="eq.latex"&gt;\frac{dH}{dt}=0&lt;/pre&gt; and energy is conserved!&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Noether's Theorem&lt;/span&gt;&lt;br /&gt;The three conserved quantities above were shown to be related to the invariance of the Lagrangian under some symmetry transformation:&lt;br /&gt;&lt;ul&gt;&lt;li&gt;Translational invariance (homogeneity of space) ==&gt; Conservation of momentum&lt;/li&gt;&lt;li&gt;Rotational invariance (isotropy of space) ==&gt; Conservation of angular momentum&lt;/li&gt;&lt;li&gt;Time invariance (homogeneity of time) ==&gt; Conservation of energy&lt;/li&gt;&lt;/ul&gt;&lt;br /&gt;Noether's Theorem states that any differentiable symmetry of the Action (integral of the Lagrangian) of a physical system has a corresponding conservation law.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-style:italic;"&gt;To every differentiable symmetry generated by local actions, there corresponds a conserved current.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;`Symmetry' here, refers to the covariance of the form of a physical law with respect to a Lie group of transformations; the conserved quantity is known as a &lt;span style="font-style:italic;"&gt;charge&lt;/span&gt; and the flow carrying it as a &lt;span style="font-style:italic;"&gt;current&lt;/span&gt; (c.f. electrodynamics).&lt;br /&gt;&lt;br /&gt;Noether's Theorem, which I will discuss in more detail at a later date, is another critical component used to build gauge theories. The key thing to remember right now is that a symmetry (invariance) of the Lagrangian corresponds to a conserved quantity; we can use this result to look for the underlying symmetry behind quantities we know to be conserved (for example, electric charge).&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4470666517647633822-7592829108502088918?l=physical-thought.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://physical-thought.blogspot.com/feeds/7592829108502088918/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4470666517647633822&amp;postID=7592829108502088918' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4470666517647633822/posts/default/7592829108502088918'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4470666517647633822/posts/default/7592829108502088918'/><link rel='alternate' type='text/html' href='http://physical-thought.blogspot.com/2008/09/symmetries-conserved-quantities-and.html' title='Symmetries, Conserved Quantities and Noether&apos;s Theorem'/><author><name>Andrew J. Bennieston</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://bp2.blogger.com/_zi39n2uYgqg/R3f879w2IHI/AAAAAAAAAAY/IsPK0LU5Duc/S220/avatar.png'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4470666517647633822.post-3501310251543745231</id><published>2008-09-22T14:38:00.002+01:00</published><updated>2008-09-22T15:06:43.365+01:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='latex'/><title type='text'>Feedback on `Writing Scientific Documents Using LaTeX'</title><content type='html'>Since I submitted my article &lt;span style="font-style: italic;"&gt;Writing Scientific Documents Using LaTeX&lt;/span&gt; to CTAN, I've had several emails offering comments, suggestions and improvements. I plan on taking all of these into account for the next edition, which should be available sometime soon. Meanwhile, I thought I'd just post a little about some of the suggestions here.&lt;br /&gt;&lt;br /&gt;The single most common suggestion was that I replace the use of &lt;span style="color: rgb(153, 0, 0);"&gt;$$ ... $$&lt;/span&gt; to delimit displayed mathematics with the &lt;span style="color: rgb(153, 0, 0);"&gt;\[ ... \]&lt;/span&gt; form. The dollar-variant is apparently deprecated, and the newer square bracket style preferred. The reason for this, as given in &lt;a href="http://www.ctan.org/tex-archive/info/l2tabu/"&gt;http://www.ctan.org/tex-archive/info/l2tabu/&lt;/a&gt;, is that the &lt;span style="color: rgb(153, 0, 0);"&gt;$$ &lt;/span&gt;form is a plain TeX command, and should be avoided in LaTeX due to inconsistencies. Check the l2tabu document for more details.&lt;br /&gt;&lt;br /&gt;Another frequent comment was that the &lt;span style="font-style: italic;"&gt;eqnarray&lt;/span&gt; environment is bad, and should always be replaced by the &lt;span style="font-style: italic;"&gt;align&lt;/span&gt; or similar, from the &lt;span style="font-style: italic;"&gt;amsmath&lt;/span&gt; package. I originally thought I'd leave a discussion of &lt;span style="font-style: italic;"&gt;eqnarray&lt;/span&gt; in there for reference, but now it seems better to remove it entirely.&lt;br /&gt;&lt;br /&gt;Other comments related to minor corrections and requests for additional explanation in some sections, expanded coverage of BibTeX and more details on table design.&lt;br /&gt;&lt;br /&gt;As I said above, I plan to incorporate all of these suggestions into the 5th Edition of the article.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4470666517647633822-3501310251543745231?l=physical-thought.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://physical-thought.blogspot.com/feeds/3501310251543745231/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4470666517647633822&amp;postID=3501310251543745231' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4470666517647633822/posts/default/3501310251543745231'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4470666517647633822/posts/default/3501310251543745231'/><link rel='alternate' type='text/html' href='http://physical-thought.blogspot.com/2008/09/feedback-on-writing-scientific.html' title='Feedback on `Writing Scientific Documents Using LaTeX&apos;'/><author><name>Andrew J. Bennieston</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://bp2.blogger.com/_zi39n2uYgqg/R3f879w2IHI/AAAAAAAAAAY/IsPK0LU5Duc/S220/avatar.png'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4470666517647633822.post-4658088876652040917</id><published>2008-09-22T13:19:00.011+01:00</published><updated>2008-09-22T14:32:27.367+01:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='lagrangian'/><category scheme='http://www.blogger.com/atom/ns#' term='gauge theories'/><category scheme='http://www.blogger.com/atom/ns#' term='standard model'/><category scheme='http://www.blogger.com/atom/ns#' term='groups'/><category scheme='http://www.blogger.com/atom/ns#' term='superconductors'/><category scheme='http://www.blogger.com/atom/ns#' term='special relativity'/><category scheme='http://www.blogger.com/atom/ns#' term='particle physics'/><category scheme='http://www.blogger.com/atom/ns#' term='electrodynamics'/><category scheme='http://www.blogger.com/atom/ns#' term='quantum mechanics'/><category scheme='http://www.blogger.com/atom/ns#' term='mathematics'/><category scheme='http://www.blogger.com/atom/ns#' term='physics'/><category scheme='http://www.blogger.com/atom/ns#' term='hamiltonian'/><title type='text'>From Lagrangian to Hamiltonian Mechanics</title><content type='html'>If the Lagrangian L does not depend explicitly on time, and varies with time only through the time-dependence of the coordinate q (and its time derivative), then we can define a constant of motion known as the Hamiltonian, H.&lt;br /&gt;&lt;br /&gt;That is, if&lt;br /&gt;&lt;pre lang="eq.latex"&gt;&lt;br /&gt;\begin{align*}&lt;br /&gt;L = L(q(t),\dot{q}(t)) \\&lt;br /&gt;\mathrm{not}~~L = L(q(t), \dot{q}(t), t)&lt;br /&gt;\end{align*}&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;then the Hamiltonian H can be defined as&lt;br /&gt;&lt;pre lang="eq.latex"&gt;H = \dot{q}\frac{\partial L}{\partial \dot{q}} - L&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;For the simplest example of a particle of mass m, moving through a potential V(x), with velocity v = dx/dt, we have &lt;pre style="display: inline;" lang="eq.latex"&gt;L = \frac{m\dot{x}^2}{2} - V(x) = T - V&lt;/pre&gt;. Using the above definition of the Hamiltonian, &lt;pre style="display: inline;" lang="eq.latex"&gt;H = \frac{m\dot{x}^2}{2} + V(x)&lt;/pre&gt; which can be identified as the &lt;span style="font-style: italic;"&gt;total energy&lt;/span&gt;. Since H is a constant of motion, this result corresponds to &lt;span style="font-style: italic;"&gt;conservation of energy!&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;More generally,&lt;br /&gt;&lt;pre lang="eq.latex"&gt;\frac{dH}{dt}=\frac{d}{dt}\left(\dot{x}\frac{\partial L}{\partial\dot{x}}\right)-\frac{\partial L}{\partial\dot{x}}\frac{d\dot{x}}{dt}-\frac{\partial L}{\partial x}\frac{dx}{dt}&lt;/pre&gt;&lt;pre lang="eq.latex"&gt;= v\left( \frac{d}{dt}\frac{\partial L}{\partial \dot{x}} - \frac{\partial L}{\partial x}\right) = 0&lt;/pre&gt;&lt;br /&gt;since the last term inside the brackets vanishes (it's the Euler-Lagrange Equation!)&lt;br /&gt;&lt;br /&gt;Note that if L depends explicitly on time, the above does not hold, and we lose conservation of energy; here, energy can be `used' in thermodynamically irreversible processes. Of course, if we expanded the Lagrangian to take into account a large enough system, we regain conservation of energy for the universe as a whole!&lt;br /&gt;&lt;br /&gt;The Hamiltonian H is an &lt;span style="font-style: italic;"&gt;integral of the motion&lt;/span&gt;, since&lt;br /&gt;&lt;pre lang="eq.latex"&gt;\frac{dH}{dt} = 0 \Rightarrow \int_{t_0}^{t_1}\frac{dH}{dt}\,dt = \left[H\right]_{t_0}^{t_1} = 0&lt;/pre&gt;&lt;br /&gt;It contains only first-order time derivatives of the coordinate q, whereas the Euler-Lagrange equation contains second-order time derivatives, &lt;pre style="display: inline;" lang="eq.latex"&gt;\frac{d}{dt}\frac{\partial L}{\partial \dot{q}}&lt;/pre&gt;.&lt;br /&gt;&lt;br /&gt;As an example of determining the Hamiltonian from a Lagrangian, I'd like to look at the case of Special Relativity (SR). There are two reasons for this... first, the SR Lagrangian looks a bit different from the usual T - V form of classical mechanics. Secondly, Special Relativity will feature prominently in a number of future posts as I start to direct the methods of Lagrangian and Hamiltonian mechanics towards describing gauge theories.&lt;br /&gt;&lt;br /&gt;The SR Lagrangian in a potential V(x) is given by&lt;br /&gt;&lt;pre lang="eq.latex"&gt;L = \frac{-mc^2}{\gamma} - V(x) = -mc^2\sqrt{1-\frac{v^2}{c^2}} - V(x)&lt;/pre&gt;&lt;br /&gt;where I have used &lt;pre style="display: inline;" lang="eq.latex"&gt;v = \dot{x} = \frac{dx}{dt}&lt;/pre&gt; and have referred to the rest mass as simply m, while many books use the notation m_0.&lt;br /&gt;&lt;br /&gt;The Hamiltonian H can be found as&lt;br /&gt;&lt;pre lang="eq.latex"&gt;\begin{multiline*}&lt;br /&gt;H = v\frac{\partial L}{\partial v} - L\\&lt;br /&gt;= \frac{mc^2}{\sqrt{1-\frac{v^2}{c^2}}} + V(x)\\&lt;br /&gt;= \gamma mc^2 + V(x)&lt;br /&gt;\end{multiline*}&lt;/pre&gt;&lt;br /&gt;The last line is readily identified as the total relativistic energy of a particle of rest mass m in a potential V(x), so our interpretation of the Hamiltonian holds!&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Canonical Momenta&lt;/span&gt;&lt;br /&gt;I'd like to take a moment now to introduce some new nomenclature and notation, and to explain why it is useful here.&lt;br /&gt;&lt;br /&gt;First, a reminder that the Euler-Lagrange equation for a coordinate q can be written as&lt;br /&gt;&lt;pre lang="eq.latex"&gt;\frac{d}{dt}\frac{\partial L}{\partial \dot{q}} = \frac{\partial L}{\partial q}&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;We can define a quantity p, known as the &lt;span style="font-style: italic;"&gt;canonical momentum conjugate to the coordinate q&lt;/span&gt;, as follows&lt;br /&gt;&lt;pre lang="eq.latex"&gt;p=\frac{\partial L}{\partial \dot{q}}&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;and a quantity F, known as the &lt;span style="font-style: italic;"&gt;canonical force conjugate to the momentum p&lt;/span&gt;, as&lt;br /&gt;&lt;pre lang="eq.latex"&gt;F = \frac{\partial L}{\partial q}&lt;/pre&gt;&lt;br /&gt;These follow the usual definitions such that &lt;pre style="display: inline;" lang="eq.latex"&gt;T = \frac{p^2}{2m}&lt;/pre&gt; and &lt;pre style="display: inline;" lang="eq.latex"&gt;F = -\nabla V&lt;/pre&gt;, since the Lagrangian L = T - V.&lt;br /&gt;&lt;br /&gt;Written in this form, the Euler-Lagrange Equation directly represents Newton's 2nd Law:&lt;br /&gt;&lt;pre lang="eq.latex"&gt;F = \dot{\mathbf{p}}&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;For multiple coordinates &lt;pre style="display: inline;" lang="eq.latex"&gt;q_i&lt;/pre&gt;, the Hamiltonian H is given by&lt;br /&gt;&lt;pre lang="eq.latex"&gt;&lt;br /&gt;H = \sum_i p_i \dot{q}_i - L&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;where &lt;pre style="display: inline;" lang="eq.latex"&gt;p_i&lt;/pre&gt; is the canonical momentum conjugate to the coordinate &lt;pre style="display: inline;" lang="eq.latex"&gt;q_i&lt;/pre&gt;.&lt;br /&gt;&lt;br /&gt;Introducing the concept of canonical momentum conjugate to a coordinate is essential for the future posts I'd like to make on this blog. The reason for this is that when I discuss quantum field theory, the concepts introduced above will play an essential role in the procedure. More on this later!&lt;br /&gt;&lt;br /&gt;Meanwhile, although I provided a couple of classical mechanics examples for the use of the Lagrangian, in order to introduce the concept at a level that most people can understand from the world around them, I will refrain from posting similar examples making use of the Hamiltonian, since I wish to progress to more complicated topics.&lt;br /&gt;&lt;br /&gt;In order to illuminate the path from here to a discussion of gauge theories, I'd like now to simply list some of the topics I must first cover. As such, the interested reader will notice any such posts! I anticipate that this list will be incomplete, and that I will need to cover certain topics in a lot more detail than others.&lt;br /&gt;&lt;ol&gt;&lt;li&gt;Symmetries and Noether's Theorem (some of this)&lt;br /&gt;&lt;/li&gt;&lt;li&gt;Special Relativity in four-vector formulation (lots of this)&lt;br /&gt;&lt;/li&gt;&lt;li&gt;Relativistic electrodynamics (not much of this)&lt;/li&gt;&lt;li&gt;Relativistic Quantum Mechanics (I've already discussed the Klein-Gordon equation, but I'll go over this and other aspects, again)&lt;/li&gt;&lt;li&gt;Spin &amp;amp; Relativity (Pauli matrices and the gamma matrices)&lt;/li&gt;&lt;li&gt;The Dirac Equation (in some detail!)&lt;/li&gt;&lt;li&gt;U(1) symmetries and the Gauge Principle&lt;/li&gt;&lt;li&gt;Quantum Electrodynamics&lt;/li&gt;&lt;li&gt;SU(2) and Electroweak Unification&lt;/li&gt;&lt;li&gt;Aside on Superconductivity (which may be omitted)&lt;br /&gt;&lt;/li&gt;&lt;li&gt;Spontaneous Symmetry Breaking and the Higgs Mechanism&lt;/li&gt;&lt;/ol&gt;&lt;br /&gt;&lt;br /&gt;I expect those posts to take some considerable time. I've spent at least two weeks discussing Lagrangian mechanics, and we have a long way to go before I can introduce the Higgs mechanism, which is the ultimate goal of this entire series of posts. The idea is that anyone with a basic grounding in physics and mathematics should be able to learn enough about Lagrangian &amp;amp; Hamiltonian Mechanics, Quantum Mechanics and Special Relativity to be able to appreciate the formulation of the gauge theories of the Standard Model of Particle Physics, and to go a little beyond that and get a look at the Higgs mechanism. Let's hope I make it to the end!&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4470666517647633822-4658088876652040917?l=physical-thought.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://physical-thought.blogspot.com/feeds/4658088876652040917/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4470666517647633822&amp;postID=4658088876652040917' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4470666517647633822/posts/default/4658088876652040917'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4470666517647633822/posts/default/4658088876652040917'/><link rel='alternate' type='text/html' href='http://physical-thought.blogspot.com/2008/09/from-lagrangian-to-hamiltonian.html' title='From Lagrangian to Hamiltonian Mechanics'/><author><name>Andrew J. Bennieston</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://bp2.blogger.com/_zi39n2uYgqg/R3f879w2IHI/AAAAAAAAAAY/IsPK0LU5Duc/S220/avatar.png'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4470666517647633822.post-7032086667098566577</id><published>2008-09-20T12:06:00.008+01:00</published><updated>2008-09-21T21:22:02.785+01:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='lagrangian'/><category scheme='http://www.blogger.com/atom/ns#' term='physics'/><title type='text'>Lagrangian Mechanics: From the Euler-Lagrange Equation to Simple Harmonic Motion</title><content type='html'>I already wrote about &lt;a href="http://physical-thought.blogspot.com/2008/09/lagrangian-mechanics-from-euler.html"&gt;obtaining Newton's Laws from the Principle of Least Action&lt;/a&gt;. Now I'm going to analyse a simple mass-spring system; effectively just a case of substituting in a suitable potential for the spring.&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_zi39n2uYgqg/SNTZmdsm93I/AAAAAAAAAMo/KyX6IuJ0x6M/s1600-h/spring.jpg"&gt;&lt;img style="display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;" src="http://2.bp.blogspot.com/_zi39n2uYgqg/SNTZmdsm93I/AAAAAAAAAMo/KyX6IuJ0x6M/s400/spring.jpg" border="0" alt=""id="BLOGGER_PHOTO_ID_5248058720623458162" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;Let us go through all of the steps, once more. We'll choose our coordinate x to be the displacement from the equilibrium length of the spring, as shown on the diagram. The kinetic energy of the moving mass is then just &lt;pre lang="eq.latex" style="display: inline;"&gt;T=\frac{m\dot{x}^2}{2}&lt;/pre&gt;. The potential of a spring stretched (or compressed) x metres from its equilibrium length is given by &lt;pre lang="eq.latex" style="display: inline;"&gt;V=\frac{kx^2}{2}&lt;/pre&gt;, where k is the spring constant (N m^-1).&lt;br /&gt;&lt;br /&gt;So, for our mass-spring system, the Lagrangian is&lt;br /&gt;&lt;pre lang="eq.latex"&gt;&lt;br /&gt;L = \frac{1}{2}\left(m\dot{x}^2 - kx^2\right)}&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;Applying the Euler-Lagrange equation, we obtain&lt;br /&gt;&lt;pre lang="eq.latex"&gt;&lt;br /&gt;\begin{multiline*}&lt;br /&gt;-kx - \frac{d}{dt}\left(m\dot{x}\right) = 0 \\&lt;br /&gt;\Rightarrow \ddot{x} - \frac{k}{m}x = 0&lt;br /&gt;\end{multiline*}&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;Comparing the last line above with the general form of &lt;a href="http://en.wikipedia.org/wiki/Simple_harmonic_motion"&gt;Simple Harmonic Motion&lt;/a&gt; (SHM), &lt;pre lang="eq.latex" style="display: inline;"&gt;\ddot{q} - \omega^2 q = 0&lt;/pre&gt; we can see that the equation of motion rendered by applying the Euler-Lagrange equation to the Lagrangian of a mass-spring system provides Simple Harmonic Motion with a frequency&lt;br /&gt;&lt;pre lang="eq.latex"&gt;&lt;br /&gt;\omega = \sqrt{\frac{k}{m}}&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;This is as expected for the case of a mass-spring system!&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4470666517647633822-7032086667098566577?l=physical-thought.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://physical-thought.blogspot.com/feeds/7032086667098566577/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4470666517647633822&amp;postID=7032086667098566577' title='3 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4470666517647633822/posts/default/7032086667098566577'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4470666517647633822/posts/default/7032086667098566577'/><link rel='alternate' type='text/html' href='http://physical-thought.blogspot.com/2008/09/lagrangian-mechanics-from-euler_20.html' title='Lagrangian Mechanics: From the Euler-Lagrange Equation to Simple Harmonic Motion'/><author><name>Andrew J. Bennieston</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://bp2.blogger.com/_zi39n2uYgqg/R3f879w2IHI/AAAAAAAAAAY/IsPK0LU5Duc/S220/avatar.png'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://2.bp.blogspot.com/_zi39n2uYgqg/SNTZmdsm93I/AAAAAAAAAMo/KyX6IuJ0x6M/s72-c/spring.jpg' height='72' width='72'/><thr:total>3</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4470666517647633822.post-7606913464783841343</id><published>2008-09-19T14:08:00.006+01:00</published><updated>2008-09-19T14:37:14.206+01:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='lagrangian'/><category scheme='http://www.blogger.com/atom/ns#' term='physics'/><title type='text'>Lagrangian Mechanics: From the Euler-Lagrange Equation to Newton's Laws</title><content type='html'>Last week I &lt;a href="http://physical-thought.blogspot.com/2008/09/lagrangian-mechanics-from-principle-of.html"&gt;wrote about the Euler-Lagrange Equation&lt;/a&gt;, and how it can be obtained from the Principle of Least Action. Today, I'd like to show that this equation is consistent with Newtonian Mechanics.&lt;br /&gt;&lt;br /&gt;For reference, the Euler-Lagrange equation for some arbitrary coordinate q is:&lt;pre lang="eq.latex"&gt;&lt;br /&gt;\frac{\partial L}{\partial q} - \frac{d}{dt}\frac{\partial L}{\partial \dot{q}} = 0&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;L, the Lagrangian, is the kinetic energy of a system minus the potential.&lt;br /&gt;&lt;br /&gt;Let us now consider the case of a free particle of mass m, moving in a potential V(x).  The particle's instantaneous speed is given by &lt;pre lang="eq.latex" style="display: inline;"&gt;v = \frac{dx}{dt}=\dot{x}&lt;/pre&gt;. The kinetic energy is the familiar &lt;pre lang="eq.latex" style="display: inline;"&gt;T=\frac{1}{2}m\dot{x}^2&lt;/pre&gt;.&lt;br /&gt;&lt;br /&gt;Applying the Euler-Lagrange Equation, we have:&lt;br /&gt;&lt;pre lang="eq.latex"&gt;&lt;br /&gt;\begin{align*}&lt;br /&gt;\frac{\partial L}{\partial x} = -\frac{\partial V(x)}{\partial x} \\&lt;br /&gt;\mathrm{and}~~\frac{\partial L}{\partial \dot{x}} = m\dot{x} \\&lt;br /&gt;\Rightarrow \frac{d}{dt}\frac{\partial L}{\partial \dot{x}} = m\ddot{x}&lt;br /&gt;\end{align*}&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;Putting these together, we have:&lt;br /&gt;&lt;pre lang="eq.latex"&gt;&lt;br /&gt;\begin{align*}&lt;br /&gt;-\frac{\partial V(x)}{\partial x} - m\ddot{x} = 0 \\&lt;br /&gt;\Rightarrow m\ddot{x} = -\frac{\partial V}{\partial x}&lt;br /&gt;\end{align*}&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;The right-hand side is the gradient of a potential energy (in 1D). Force can be defined in terms of the gradient of a potential V:&lt;br /&gt;&lt;pre lang="eq.latex"&gt;&lt;br /&gt;F = -\nabla V&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;And since &lt;pre lang="eq.latex" style="display: inline;"&gt;\ddot{x} = \frac{d^2 x}{dt^2}&lt;/pre&gt; is acceleration, a, the result of applying the Euler-Lagrange equation to a classical-mechanical Lagrangian is the familiar form of Newton's Second Law:&lt;br /&gt;&lt;pre lang="eq.latex"&gt;&lt;br /&gt;F = ma&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;In other words, applying the Euler-Lagrange equation to a suitable Lagrangian provides an equation of motion!&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4470666517647633822-7606913464783841343?l=physical-thought.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://physical-thought.blogspot.com/feeds/7606913464783841343/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4470666517647633822&amp;postID=7606913464783841343' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4470666517647633822/posts/default/7606913464783841343'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4470666517647633822/posts/default/7606913464783841343'/><link rel='alternate' type='text/html' href='http://physical-thought.blogspot.com/2008/09/lagrangian-mechanics-from-euler.html' title='Lagrangian Mechanics: From the Euler-Lagrange Equation to Newton&apos;s Laws'/><author><name>Andrew J. Bennieston</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://bp2.blogger.com/_zi39n2uYgqg/R3f879w2IHI/AAAAAAAAAAY/IsPK0LU5Duc/S220/avatar.png'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4470666517647633822.post-1436452456851198267</id><published>2008-09-18T00:04:00.001+01:00</published><updated>2008-09-18T00:08:11.838+01:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='cern'/><category scheme='http://www.blogger.com/atom/ns#' term='standard model'/><category scheme='http://www.blogger.com/atom/ns#' term='lhc'/><category scheme='http://www.blogger.com/atom/ns#' term='particle physics'/><category scheme='http://www.blogger.com/atom/ns#' term='physics'/><title type='text'>On Science in Education and in the Media</title><content type='html'>It is a rare, but not entirely unprecedented, occasion that I find myself writing not about scientific fact, programming or mathematics, but expressing an opinion. Indeed, this time it may prove even less favourable than my post calling for the elimination of PowerPoint presentations in physics lectures. The topic for today is a mixed bag of sensationalism, media scaremongering, poor reporting and poorer education.&lt;br /&gt;&lt;br /&gt;My thoughts turned to these topics last week as the media fully embraced the coming apocalypse. I refer, of course, to the coverage of the first beam of protons to traverse the Large Hadron Collider (LHC) at CERN. Reports of the end of the world at the hands of a man-made black hole were clearly exaggerated (after all, we're still here). That the claims of black-hole catastrophe had little scientific merit, and no expert had voiced such concerns, did not appear to bother the mass media, as a number of newspapers and even the BBC led with reports of the possibility of a planet-swallowing black hole being produced at the LHC on September 10, 2008.&lt;br /&gt;&lt;br /&gt;What did not occur to any members of the media to point out was that no collisions were planned for that day, so there was absolutely no chance of producing a black hole on September 10, whatsoever. If you're reading this after about mid-October, you can join me in laughing at the media for completely failing to warn the public bout the collisions of protons and anti-protons now taking place routinely, at centre-of-mass energies of up to 10 TeV (assuming everything went according to plan).&lt;br /&gt;&lt;br /&gt;What annoyed me further still were the constant references to the LHC as a `big bang' machine. ALICE, the project that will use the LHC to study quark-gluon plasmas created by the collision of protons with Lead nuclei, recreating the conditions of the early universe, is only one of four current LHC experiments; proton-Lead collisions will account for at most a third of the LHC's operational time. Meanwhile, LHCb will look at the physics of B-hadrons, particles containing one or more `bottom' quarks, at the high energies available (up to 14 TeV at full power), while CMS and ATLAS will look for whatever new physics they can find at these unprecedented centre-of-mass energies. It is ATLAS and CMS which are geared up to detect the Higgs boson, a particle which would confirm the theoretical Higgs Mechanism of spontaneous symmetry breaking to provide massive particles to the otherwise massless gauge theories of the Standard Model of Particle Physics. I shall avoid getting into the topic of the separation of science and religion, broken by the continual reference to the Higgs boson as some kind of `God particle'.&lt;br /&gt;&lt;br /&gt;I realise that, had the headlines been along the lines of "Scientists successfully guide protons around 27 km loop", there would have been much less public interest, but that is certainly no reason to sensationalise, to play on a fear of the unknown, or to exploit the natural curiosity many people express about the origins of our universe. As a physicist, I've spent much of the past week convincing people that the world is not going to end (at least, not as a result of the LHC producing black holes) and that the research being carried out is much broader than trying to make a Big Bang of our own!&lt;br /&gt;&lt;br /&gt;Onward, then, to the issue of science education. I can't help thinking that the public understanding of the physics going on at the LHC should be much deeper than it currently is. I know that the vast majority of people on the planet will never again hear the terms `gauge theory' or `spontaneous symmetry breaking', but surely there are other issues which a better science education would open the public's mind to.&lt;br /&gt;&lt;br /&gt;Two examples spring to mind, and it is a coincidence, precipitated in part by media coverage, that they are related: Energy, and Global Warming (or should I say `Climate Change'?) I'll write first about energy; specifically electrical power generation.&lt;br /&gt;&lt;br /&gt;Power generation is covered in secondary science courses in a broadly Geographical context. The student learns about the renewables vs. non-renewables, Carbon emission, inefficiency of, say, wind power, and even the relative cost of different sources of energy. Nuclear power is given brief coverage too. The problem is, none of this is science! A lot of it is politics, or economics at best.&lt;br /&gt;&lt;br /&gt;How would I change it? I'd use the issue of power generation to launch into the science behind it; thermodynamics, turbines, efficiency and electromagnetic induction. Solar power to introduce the photoelectric effect and basic quantum physics, nuclear power to introduce radioactivity, fission and nuclear binding energy. Even fusion, though there is little new science here, and magnetic confinement is beyond the scope of secondary education! Instead, how about inertial confinement (laser fusion) to illustrate the concepts of energy, intensity, power transmission and constructive interference in waves?&lt;br /&gt;&lt;br /&gt;Given such an education, emphasising the actual science, the public should be better able to make informed decisions, carry out accurate and productive debate, and think for themselves, rather than relying on the media to misinform.&lt;br /&gt;&lt;br /&gt;Science is taking a central role in modern society, and will only become more central in the future. It is negligent to soften the focus of secondary science education, even for those who have no intention of pursuing a career in a science-related discipline. The public has a right to understand where science is heading and how it affects them.&lt;br /&gt;&lt;br /&gt;I shall avoid saying anything about global warming, since it is a topic which has been demonstrated to cause `heated' debate, and I'd rather avoid arguments in which neither side has sufficient facts to back up their claims, here. Is it a good thing to try to reduce our CO2 emissions, to become more energy efficient, and less reliant on limited reserves of fossil fuels? Yes, of course it is. But when a large number of scientists cannot even agree on the cause of climate change, it is a poorly informed media pressing the issue home to the general public.&lt;br /&gt;&lt;br /&gt;Steering now away from global warming, I will close by reiterating my central points. First, I am decidedly unimpressed by the media coverage of the LHC last week. Not only was it mostly misinformed, it was an obvious case of sensational reporting, serving only to inflate readership (or viewers, for the televised media). In particular, I found the BBC coverage sadly disappointing.&lt;br /&gt;&lt;br /&gt;Secondly, I fear that compulsory science education does not do enough to provide the public with the knowledge they are increasingly going to need in order to understand the issues of the world around them. Finally, I make the suggestion that topical issues should be used to lead into hard science, making it relevant and capturing the interest of those not of a scientific disposition.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4470666517647633822-1436452456851198267?l=physical-thought.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://physical-thought.blogspot.com/feeds/1436452456851198267/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4470666517647633822&amp;postID=1436452456851198267' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4470666517647633822/posts/default/1436452456851198267'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4470666517647633822/posts/default/1436452456851198267'/><link rel='alternate' type='text/html' href='http://physical-thought.blogspot.com/2008/09/on-science-in-education-and-in-media.html' title='On Science in Education and in the Media'/><author><name>Andrew J. Bennieston</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://bp2.blogger.com/_zi39n2uYgqg/R3f879w2IHI/AAAAAAAAAAY/IsPK0LU5Duc/S220/avatar.png'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4470666517647633822.post-4106552191231892500</id><published>2008-09-16T23:53:00.003+01:00</published><updated>2008-09-16T23:57:37.515+01:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='latex'/><title type='text'>Writing Scientific Documents Using LaTeX: Permanent home on CTAN</title><content type='html'>Following the suggestion of someone who commented on my &lt;a href="http://physical-thought.blogspot.com/2008/09/writing-scientific-documents-using.html"&gt;previous post&lt;/a&gt; about my article &lt;span style="font-style:italic;"&gt;Writing Scientific Documents Using LaTeX&lt;/span&gt;, I submitted the PDF and TeX source to &lt;a href="http://www.ctan.org/"&gt;CTAN&lt;/a&gt;, the Comprehensive Tex Archive Network. After changing the license to the &lt;a href="http://www.latex-project.org/lppl/"&gt;LPPL&lt;/a&gt;, it was accepted into the archive.&lt;br /&gt;&lt;br /&gt;As a result, the PDF can now be found permanently at the following location:&lt;br /&gt;&lt;a href="http://www.ctan.org/get/info/intro-scientific/scidoc.pdf"&gt;http://www.ctan.org/get/info/intro-scientific/scidoc.pdf&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;The CTAN entry is at &lt;a href="http://www.ctan.org/tex-archive/info/intro-scientific/"&gt;http://www.ctan.org/tex-archive/info/intro-scientific/&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4470666517647633822-4106552191231892500?l=physical-thought.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://physical-thought.blogspot.com/feeds/4106552191231892500/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4470666517647633822&amp;postID=4106552191231892500' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4470666517647633822/posts/default/4106552191231892500'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4470666517647633822/posts/default/4106552191231892500'/><link rel='alternate' type='text/html' href='http://physical-thought.blogspot.com/2008/09/writing-scientific-documents-using_16.html' title='Writing Scientific Documents Using LaTeX: Permanent home on CTAN'/><author><name>Andrew J. Bennieston</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://bp2.blogger.com/_zi39n2uYgqg/R3f879w2IHI/AAAAAAAAAAY/IsPK0LU5Duc/S220/avatar.png'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4470666517647633822.post-4154652175061597013</id><published>2008-09-14T23:40:00.005+01:00</published><updated>2008-09-15T00:01:53.070+01:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='lagrangian'/><category scheme='http://www.blogger.com/atom/ns#' term='gauge theories'/><category scheme='http://www.blogger.com/atom/ns#' term='particle physics'/><category scheme='http://www.blogger.com/atom/ns#' term='quantum mechanics'/><category scheme='http://www.blogger.com/atom/ns#' term='physics'/><category scheme='http://www.blogger.com/atom/ns#' term='hamiltonian'/><title type='text'>Lagrangian Mechanics: From the Principle of Least Action to the Euler-Lagrange Equation</title><content type='html'>A quantity known as the Action, A is defined as&lt;br /&gt;&lt;pre lang="eq.latex"&gt;&lt;br /&gt;A = \int L \,dt&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;where L is known as the Lagrangian. The simplest Lagrangian is given as the kinetic energy T of a system minus the potential energy V of the system:&lt;br /&gt;&lt;pre lang="eq.latex"&gt;&lt;br /&gt;L(x,t) = T(x,t) - V(x,t)&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;By extremising the Action (minimising it, in this case) we can obtain the Euler-Lagrange Equation, a key equation for Lagrangian and Hamiltonian mechanics. The concept is also used extensively in quantum mechanics and particle physics, particularly when dealing with gauge theories.&lt;br /&gt;&lt;br /&gt;Consider an extremised path x(t) from a point x(t0) to a point x(t1), and some excursion from this path, as shown in the figure below. The excursion is given by some small function a(t), and the velocity is changed accordingly:&lt;br /&gt;&lt;pre lang="eq.latex"&gt;&lt;br /&gt;\begin{align*}&lt;br /&gt;x(t) \rightarrow x(t) + a(t) \\&lt;br /&gt;v(t) \rightarrow v(t) + \dot{a}(t)&lt;br /&gt;\end{align*}&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_zi39n2uYgqg/SM2UZHRV5mI/AAAAAAAAAMg/pU_OkTw1J-c/s1600-h/paths.jpg"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer;" src="http://1.bp.blogspot.com/_zi39n2uYgqg/SM2UZHRV5mI/AAAAAAAAAMg/pU_OkTw1J-c/s400/paths.jpg" alt="" id="BLOGGER_PHOTO_ID_5246012300125922914" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;If we take x(t) to be the extremal path from x(t0) to x(t1), with the end-points fixed, and a(t) to be some small but general excursion from that path which must pass through the end-points, we can assert that:&lt;br /&gt;&lt;pre lang="eq.latex"&gt;&lt;br /&gt;a(t_0) = a(t_1) = 0&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;The Lagrangian will be changed as a result of these excursions. To first-order in small a(t), the Lagrangian transforms as:&lt;br /&gt;&lt;pre lang="eq.latex"&gt;&lt;br /&gt;\begin{align*}&lt;br /&gt;L(x,v) \rightarrow L(x+a, v+\dot{a}) \\&lt;br /&gt;= L(x, v) + a(t)\frac{\partial L}{\partial x} + \dot{a}(t)\frac{\partial L}{\partial v}&lt;br /&gt;\end{align*}&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;The Action therefore transforms according to &lt;pre lang="eq.latex" style="display: inline;"&gt;A \rightarrow A + \delta A&lt;/pre&gt; where:&lt;br /&gt;&lt;pre lang="eq.latex"&gt;&lt;br /&gt;\delta A = \int_{t_0}^{t_1}\,dt \left( a(t)\frac{\partial L}{\partial x} + \frac{da}{dt}\frac{\partial L}{\partial v} \right)&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;The second term in the brackets above can be integrated by parts:&lt;br /&gt;&lt;pre lang="eq.latex"&gt;&lt;br /&gt;\int_{t_0}^{t_1}\,dt \frac{da}{dt}\frac{\partial L}{\partial v} = \left[ a(t)\frac{\partial L}{\partial v} \right]_{t_0}^{t_1} - \int_{t_0}^{t_1}dt\,a(t)\frac{d}{dt}\frac{\partial L}{\partial v}&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;Since a(t0) = a(t1) = 0, the integrated part (in square brackets) vanishes, leaving the following form for delta A:&lt;br /&gt;&lt;pre lang="eq.latex"&gt;&lt;br /&gt;\delta A = \int dt\,a(t)\left(\frac{\partial L}{\partial x} - \frac{d}{dt}\frac{\partial L}{\partial v}\right)&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;For arbitrary a(t), to minimise the action (by having delta A zero), the part in brackets must be zero. This is the Euler-Lagrange Equation, rewritten for a generalised coordinate q (in place of x) and using the time-derivative of q in place of the velocity v, above:&lt;br /&gt;&lt;pre lang="eq.latex"&gt;&lt;br /&gt;\frac{\partial L}{\partial q} - \frac{d}{dt}\frac{\partial L}{\partial \dot{q}} = 0&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;As I mentioned above, the Euler-Lagrange Equation is critical for the understanding of several aspects of quantum mechanics and gauge theories. Since I plan on making posts about some of these topics in the future, I felt I should begin by explaining Lagrangian mechanics, rather than jumping in at the deep end.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4470666517647633822-4154652175061597013?l=physical-thought.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://physical-thought.blogspot.com/feeds/4154652175061597013/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4470666517647633822&amp;postID=4154652175061597013' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4470666517647633822/posts/default/4154652175061597013'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4470666517647633822/posts/default/4154652175061597013'/><link rel='alternate' type='text/html' href='http://physical-thought.blogspot.com/2008/09/lagrangian-mechanics-from-principle-of.html' title='Lagrangian Mechanics: From the Principle of Least Action to the Euler-Lagrange Equation'/><author><name>Andrew J. Bennieston</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://bp2.blogger.com/_zi39n2uYgqg/R3f879w2IHI/AAAAAAAAAAY/IsPK0LU5Duc/S220/avatar.png'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://1.bp.blogspot.com/_zi39n2uYgqg/SM2UZHRV5mI/AAAAAAAAAMg/pU_OkTw1J-c/s72-c/paths.jpg' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4470666517647633822.post-559268202278529129</id><published>2008-09-14T00:33:00.006+01:00</published><updated>2008-09-14T22:53:05.272+01:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='latex'/><title type='text'>Two-Column Layouts in LaTeX</title><content type='html'>I was recently asked about using LaTeX to create the two-column layout often seen in scientific journals. I used this layout in some lab reports and project reports.&lt;br /&gt;&lt;br /&gt;The first thing to do is to include the &lt;a href="http://www.ctan.org/tex-archive/help/Catalogue/entries/multicol.html"&gt;&lt;span style="font-style: italic;"&gt;multicol&lt;/span&gt;&lt;/a&gt; package in your preamble:&lt;pre&gt;\usepackage{multicol}&lt;/pre&gt;&lt;br /&gt;After that, to place text within a multi-column layout, start the &lt;span style="font-style: italic;"&gt;multicols&lt;/span&gt; environment (note the s at the end!) and specify the number of columns you'd like:&lt;pre&gt;\begin{multicols}{2}&lt;/pre&gt;&lt;br /&gt;Finally, end the multi-column layout with:&lt;pre&gt;\end{multicols}&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;It's as simple as that! Any sections, subsections, equations etc. between the two will now be automatically formatted into two columns.&lt;br /&gt;&lt;br /&gt;There are, however, a few caveats and points to note for formatting considerations.&lt;br /&gt;&lt;br /&gt;The first thing to note is that the abstract is often formatted as a single column. To do this, simply place the &lt;span style="color: rgb(153, 0, 0);"&gt;\begin{multicols}{2}&lt;/span&gt; command below your abstract, but above the first &lt;span style="color: rgb(153, 0, 0);"&gt;\section&lt;/span&gt; command.&lt;br /&gt;&lt;br /&gt;Secondly, I usually typeset references within the two-column layout. To do this, end the &lt;span style="font-style: italic;"&gt;multicols&lt;/span&gt; environment after your references section.&lt;br /&gt;&lt;br /&gt;Finally, and most importantly, graphics and tables do not always work well with multi-column environments. In order to achieve reasonable results, I used a few workarounds.&lt;br /&gt;&lt;br /&gt;If the graphic is large, or has small text, set it normally and it will float outside of the column layout, spanning both columns. For smaller figures, you can create an adjusted figure or table environment which forces LaTeX to set the figure in the column, at the point you typed it in the source text. This is not always what you want, but a reasonable layout can usually be obtained by playing with the exact positioning of the table or graphic commands in the source.&lt;br /&gt;&lt;br /&gt;The following, inserted into the preamble, defines two new environments, &lt;span style="font-style: italic;"&gt;tablehere&lt;/span&gt; and &lt;span style="font-style: italic;"&gt;figurehere&lt;/span&gt;, which insert tables and figures inline with the column text.&lt;br /&gt;&lt;pre&gt;% Figures within a column...&lt;br /&gt;\makeatletter&lt;br /&gt;\newenvironment{tablehere}&lt;br /&gt;{\def\@captype{table}}&lt;br /&gt;{}&lt;br /&gt;\newenvironment{figurehere}&lt;br /&gt;{\def\@captype{figure}}&lt;br /&gt;{}&lt;br /&gt;\makeatother&lt;br /&gt;&lt;/pre&gt;In addition to this, you'll probably need to scale graphics to the column width. This can be achieved with the \resizebox command inside a &lt;span style="font-style: italic;"&gt;figure&lt;/span&gt; or our new &lt;span style="font-style: italic;"&gt;figurehere&lt;/span&gt; environment. For example,&lt;br /&gt;&lt;pre&gt;\begin{figurehere}&lt;br /&gt;\centering&lt;br /&gt;\resizebox{\columnwidth}{!}{\includegraphics{gf-graphs.eps}}&lt;br /&gt;\caption{\label{gf-graphs}Graph showing applied RF frequency against magnetic field from the sweep coils, the gradient of the lines reveals information about $g_f$ for each isotope. The left gradient, corresponding to \chem{^{85}{Rb}} is $7.73 \times 10^9 (\pm 1.5 \times 10^8)$.  The right gradient, corresponding to \chem{^{87}{Rb}}, is $5.24 \times 10^9 (\pm 6.00 \times 10^7)$ }&lt;br /&gt;\end{figurehere}&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;span style="color: rgb(153, 0, 0);"&gt;\columnwidth&lt;/span&gt; is defined by the &lt;span style="font-style: italic;"&gt;multicol&lt;/span&gt; package to be the width of a text-column!&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4470666517647633822-559268202278529129?l=physical-thought.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://physical-thought.blogspot.com/feeds/559268202278529129/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4470666517647633822&amp;postID=559268202278529129' title='11 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4470666517647633822/posts/default/559268202278529129'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4470666517647633822/posts/default/559268202278529129'/><link rel='alternate' type='text/html' href='http://physical-thought.blogspot.com/2008/09/two-column-layouts-in-latex.html' title='Two-Column Layouts in LaTeX'/><author><name>Andrew J. Bennieston</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://bp2.blogger.com/_zi39n2uYgqg/R3f879w2IHI/AAAAAAAAAAY/IsPK0LU5Duc/S220/avatar.png'/></author><thr:total>11</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4470666517647633822.post-8019458264938444020</id><published>2008-09-14T00:09:00.003+01:00</published><updated>2008-09-14T00:20:39.174+01:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='the plan'/><title type='text'>Blog Comments</title><content type='html'>In the last couple of months I have been receiving a lot more comments on posts to this blog. This is, I think, a good thing. Thanks to everyone who took the time to leave a comment.&lt;br /&gt;&lt;br /&gt;Some of the posts on this blog are meant to inform others, to precipitate discussion. In such cases, I welcome all comments, but could I ask that you please take the time to read the post before commenting, and that you understand that a number of posts are informative, rather than attempting to be original work. Those which are original work are usually (but not always) prefixed by a tale of how I got interested in that line of thought. On those other posts, the informative ones, comments telling me that this has been done before are not constructive.&lt;br /&gt;&lt;br /&gt;Here's how you can post a constructive comment on those informative posts:&lt;br /&gt;&lt;ol&gt;&lt;li&gt;Add something I forgot, missed out or didn't cover. Provide more details, discuss caveats and cases where the general principle doesn't work.&lt;/li&gt;&lt;li&gt;Provoke discussion; ask questions, pose new problems or extend existing ones.&lt;/li&gt;&lt;li&gt;Provide your own take on the issue, even if the &lt;a href="http://www.boost.org/"&gt;Boost&lt;/a&gt; people, &lt;a href="http://en.wikipedia.org/wiki/Technical_Report_1"&gt;TR1&lt;/a&gt;, physicists on Mars, or whoever, have been there and done it before. Rehashing stuff never hurts, and it might improve your own understanding as well as that of any other readers!&lt;/li&gt;&lt;li&gt;Offer links to further details, other blog posts about the same topic, etc. (Note: Don't take this as an excuse for spamming, I read every comment posted to this blog and I will remove those containing links to irrelevant material)&lt;/li&gt;&lt;/ol&gt;Once again, I'd like to thank everyone who has posted a comment so far. It's nice to know that people read this stuff, and even nicer to know that they take the time to comment. One of my goals here is to communicate science and technology to others, and a part of that communication is high-quality discussion.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4470666517647633822-8019458264938444020?l=physical-thought.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://physical-thought.blogspot.com/feeds/8019458264938444020/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4470666517647633822&amp;postID=8019458264938444020' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4470666517647633822/posts/default/8019458264938444020'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4470666517647633822/posts/default/8019458264938444020'/><link rel='alternate' type='text/html' href='http://physical-thought.blogspot.com/2008/09/blog-comments.html' title='Blog Comments'/><author><name>Andrew J. Bennieston</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://bp2.blogger.com/_zi39n2uYgqg/R3f879w2IHI/AAAAAAAAAAY/IsPK0LU5Duc/S220/avatar.png'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4470666517647633822.post-3147699625256361612</id><published>2008-09-13T23:33:00.002+01:00</published><updated>2008-09-13T23:40:04.069+01:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='latex'/><title type='text'>Writing Scientific Documents Using LaTeX</title><content type='html'>Back in 2007, I wrote a short document describing some of the basic LaTeX commands and explaining how to go about creating a document using LaTeX. I did this because I was writing third year lab reports collaboratively with my lab partners (as per the regulations for the third year lab at Warwick) and I wanted us all to be using LaTeX, so the reports would look good and so that editing the sections together would be easier. In order to do this, though, I had to educate my lab partners in the use of LaTeX.&lt;br /&gt;&lt;br /&gt;Since then, the document has been read (and requested!) by other physicists, scientists and mathematicians at Warwick and in the wider world. I've updated it several times to add content and to correct minor mistakes. It was not until this week, however, that someone suggested I put it online and make it freely available to anyone who wants it (and can find it).&lt;br /&gt;&lt;br /&gt;So, I spent a while tonight polishing it up, adding a few more subsections, and creating what is now the 13-page Fourth Edition. It is available online at &lt;a href="http://www.physical-thought.com/scidoc.pdf"&gt;http://www.physical-thought.com/scidoc.pdf&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4470666517647633822-3147699625256361612?l=physical-thought.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://physical-thought.blogspot.com/feeds/3147699625256361612/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4470666517647633822&amp;postID=3147699625256361612' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4470666517647633822/posts/default/3147699625256361612'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4470666517647633822/posts/default/3147699625256361612'/><link rel='alternate' type='text/html' href='http://physical-thought.blogspot.com/2008/09/writing-scientific-documents-using.html' title='Writing Scientific Documents Using LaTeX'/><author><name>Andrew J. Bennieston</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://bp2.blogger.com/_zi39n2uYgqg/R3f879w2IHI/AAAAAAAAAAY/IsPK0LU5Duc/S220/avatar.png'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4470666517647633822.post-8301370427192497813</id><published>2008-09-10T15:21:00.004+01:00</published><updated>2008-09-10T15:24:06.592+01:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='cern'/><category scheme='http://www.blogger.com/atom/ns#' term='lhc'/><category scheme='http://www.blogger.com/atom/ns#' term='particle physics'/><category scheme='http://www.blogger.com/atom/ns#' term='physics'/><title type='text'>LHC First Beam: Anti-clockwise Beam</title><content type='html'>This morning, a clockwise beam of protons was passed all the way around the LHC's 27km beamline, making a total of 3 complete revolutions. This afternoon, an anti-clockwise beam completed 2 revolutions. (I believe those numbers are correct; I obtained them from the &lt;a href="http://webcast.cern.ch/"&gt;CERN live webcast&lt;/a&gt;).&lt;br /&gt;&lt;br /&gt;This is great news for the LHC; everything seems to have worked out incredibly well, and to have made full traversals, both within an hour of each first attempt, is a huge success!&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4470666517647633822-8301370427192497813?l=physical-thought.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://physical-thought.blogspot.com/feeds/8301370427192497813/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4470666517647633822&amp;postID=8301370427192497813' title='4 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4470666517647633822/posts/default/8301370427192497813'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4470666517647633822/posts/default/8301370427192497813'/><link rel='alternate' type='text/html' href='http://physical-thought.blogspot.com/2008/09/lhc-first-beam-anti-clockwise-beam.html' title='LHC First Beam: Anti-clockwise Beam'/><author><name>Andrew J. Bennieston</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://bp2.blogger.com/_zi39n2uYgqg/R3f879w2IHI/AAAAAAAAAAY/IsPK0LU5Duc/S220/avatar.png'/></author><thr:total>4</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4470666517647633822.post-7260905661681449905</id><published>2008-09-10T09:26:00.005+01:00</published><updated>2008-09-10T09:28:26.177+01:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='cern'/><category scheme='http://www.blogger.com/atom/ns#' term='lhc'/><category scheme='http://www.blogger.com/atom/ns#' term='particle physics'/><category scheme='http://www.blogger.com/atom/ns#' term='physics'/><title type='text'>LHC First Beam: Full Circle</title><content type='html'>A proton beam has completed a circuit of the 27km of the Large Hadron Collider (LHC) beamline!&lt;br /&gt;&lt;br /&gt;Perhaps I'll make a post later about the physics going on at the LHC. Meanwhile, I'm getting some coffee.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4470666517647633822-7260905661681449905?l=physical-thought.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://physical-thought.blogspot.com/feeds/7260905661681449905/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4470666517647633822&amp;postID=7260905661681449905' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4470666517647633822/posts/default/7260905661681449905'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4470666517647633822/posts/default/7260905661681449905'/><link rel='alternate' type='text/html' href='http://physical-thought.blogspot.com/2008/09/lhc-first-beam-full-circle.html' title='LHC First Beam: Full Circle'/><author><name>Andrew J. Bennieston</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://bp2.blogger.com/_zi39n2uYgqg/R3f879w2IHI/AAAAAAAAAAY/IsPK0LU5Duc/S220/avatar.png'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4470666517647633822.post-3641298503695536838</id><published>2008-09-10T09:16:00.002+01:00</published><updated>2008-09-10T09:18:55.588+01:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='cern'/><category scheme='http://www.blogger.com/atom/ns#' term='lhc'/><category scheme='http://www.blogger.com/atom/ns#' term='particle physics'/><category scheme='http://www.blogger.com/atom/ns#' term='physics'/><title type='text'>LHC First Beam: 7km Left</title><content type='html'>The proton beam has made it around 20km of the LHC, according to the latest BBC News coverage. They keep showing a CERN schematic showing the LHC beamline layout and the beam progress. Does anyone know if this is online anywhere?&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4470666517647633822-3641298503695536838?l=physical-thought.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://physical-thought.blogspot.com/feeds/3641298503695536838/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4470666517647633822&amp;postID=3641298503695536838' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4470666517647633822/posts/default/3641298503695536838'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4470666517647633822/posts/default/3641298503695536838'/><link rel='alternate' type='text/html' href='http://physical-thought.blogspot.com/2008/09/lhc-first-beam-7km-left.html' title='LHC First Beam: 7km Left'/><author><name>Andrew J. Bennieston</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://bp2.blogger.com/_zi39n2uYgqg/R3f879w2IHI/AAAAAAAAAAY/IsPK0LU5Duc/S220/avatar.png'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4470666517647633822.post-4889117202793717940</id><published>2008-09-10T08:57:00.003+01:00</published><updated>2008-09-10T09:04:11.097+01:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='cern'/><category scheme='http://www.blogger.com/atom/ns#' term='lhc'/><category scheme='http://www.blogger.com/atom/ns#' term='particle physics'/><category scheme='http://www.blogger.com/atom/ns#' term='physics'/><title type='text'>LHC First Beam</title><content type='html'>I'm sitting here watching the BBC News coverage of the LHC first beam. Currently, it seems that protons have made it half way round the 27km beamline.&lt;br /&gt;&lt;br /&gt;Over the course of the day, the guys at CERN plan to get a proton beam around the entire 27km!&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4470666517647633822-4889117202793717940?l=physical-thought.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://physical-thought.blogspot.com/feeds/4889117202793717940/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4470666517647633822&amp;postID=4889117202793717940' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4470666517647633822/posts/default/4889117202793717940'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4470666517647633822/posts/default/4889117202793717940'/><link rel='alternate' type='text/html' href='http://physical-thought.blogspot.com/2008/09/lhc-first-beam.html' title='LHC First Beam'/><author><name>Andrew J. Bennieston</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://bp2.blogger.com/_zi39n2uYgqg/R3f879w2IHI/AAAAAAAAAAY/IsPK0LU5Duc/S220/avatar.png'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4470666517647633822.post-1800796290535882109</id><published>2008-08-22T16:29:00.012+01:00</published><updated>2008-08-22T17:07:00.320+01:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='groups'/><category scheme='http://www.blogger.com/atom/ns#' term='particle physics'/><category scheme='http://www.blogger.com/atom/ns#' term='mathematics'/><title type='text'>Groups and Matrix Fun</title><content type='html'>In the process of working through &lt;i&gt;Introduction to Elementary Particles (Griffiths)&lt;/i&gt;, this summer, I've been trying most of the end-of-chapter exercises. Some are reminders of things I did a while ago, others are a different take on something I did fairly recently, and have proved interesting. Still other questions are topics I had previously taken for granted due to lack of time to work out for myself. This post is about one such question.&lt;br /&gt;&lt;br /&gt;The question involved showing that sets of n*n matrices with various properties form groups. The conditions for a set to form a group under some operation (multiplication, here) are:&lt;br /&gt;&lt;ol&gt;&lt;li&gt;&lt;span style="font-weight: bold;"&gt;Closure&lt;/span&gt;: If A and B are in the set, then the product AB is also in the set, i.e. there exists some M such that AB = M&lt;/li&gt;&lt;li&gt;&lt;span style="font-weight: bold;"&gt;Identity&lt;/span&gt;: There is an element I such that IA = AI = A for all elements A in the set&lt;/li&gt;&lt;li&gt;&lt;span style="font-weight: bold;"&gt;Inverse&lt;/span&gt;: For every element A, there is an inverse, A^-1, such that AA^-1 = A^-1 A = I&lt;/li&gt;&lt;li&gt;&lt;span style="font-weight: bold;"&gt;Associativity&lt;/span&gt;: A(BC) = (AB)C&lt;/li&gt;&lt;/ol&gt;The fourth is pretty obvious for matrices anyway, so I'll ignore that. Equally, the identity matrix,&lt;pre lang="eq.latex"&gt;I = \left(\begin{array}{cccc}&lt;br /&gt;1&amp;amp;0&amp;amp;\ldots &amp;amp; 0\\&lt;br /&gt;0 &amp;amp; 1 &amp;amp; \ldots &amp;amp; 0\\&lt;br /&gt;\vdots &amp;amp; \vdots &amp;amp; \ddots &amp;amp;\vdots \\&lt;br /&gt;0 &amp;amp; 0  &amp;amp; \ldots &amp;amp; 1\end{array}\right)&lt;br /&gt;&lt;/pre&gt; provides the identity element in all of the cases considered here.&lt;br /&gt;&lt;br /&gt;All we need to look at, then, are &lt;span style="font-style:italic;"&gt;closure&lt;/span&gt; and &lt;span style="font-style:italic;"&gt;inverse&lt;/span&gt;.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;Set of all n*n unitary matrices&lt;/span&gt;&lt;br /&gt;A unitary matrix is one where &lt;pre lang="eq.latex" style="display: inline;"&gt;U^{-1} = U^\dagger = (U^\star)^T&lt;/pre&gt;, i.e. the inverse of a unitary matrix is its transpose complex-conjugate.&lt;br /&gt;&lt;br /&gt;To check closure, we require &lt;pre lang="eq.latex" style="display: inline;"&gt;AB = M ~,~ M^{-1}=M^\dagger&lt;/pre&gt;, where A and B are two unitary matrices (i.e. if A and B are members of the set, we need to check that their product M is also):&lt;br /&gt;&lt;pre lang="eq.latex"&gt;&lt;br /&gt;\begin{align*}&lt;br /&gt;AB = M\\&lt;br /&gt;M^\dagger = (AB)^\dagger = B^\dagger A^\dagger\\&lt;br /&gt;\mathrm{If~M~is~unitary,~~~~}\\&lt;br /&gt;MM^\dagger = ABB^\dagger A^\dagger\\&lt;br /&gt;= AI_nA^\dagger = I_n \\&lt;br /&gt;\Rightarrow MM^\dagger = I_n = MM^{-1}&lt;br /&gt;\end{align*}&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;which provides closure of the set.&lt;br /&gt;&lt;br /&gt;The other thing to check is the inverse. Since A is unitary, &lt;pre lang="eq.latex" style="display: inline;"&gt;AA^\dagger = I = A^\dagger A&lt;/pre&gt; implies that &lt;pre lang="eq.latex" style="display: inline;"&gt;A^\dagger&lt;/pre&gt; is unitary, and therefore &lt;pre lang="eq.latex" style="display: inline;"&gt;A^{-1} = A^\dagger&lt;/pre&gt; is unitary!&lt;br /&gt;&lt;br /&gt;Thus, the set of all n*n unitary matrices forms a group, known as U(n).&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;Set of all n*n unitary matrices with determinant +1&lt;/span&gt;&lt;br /&gt;To determine closure, we already know that the product of two unitary matrices is unitary, from above. All we need to check is that the determinant remains +1:&lt;br /&gt;&lt;pre lang="eq.latex"&gt;&lt;br /&gt;\begin{align*}&lt;br /&gt;\mathrm{det}(AB) = \mathrm{det}(A)~\mathrm{det}(B) \\&lt;br /&gt;\Rightarrow \mathrm{det}(AB) = 1\times1 = 1&lt;br /&gt;\end{align*}&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;And for the inverse, since &lt;pre lang="eq.latex" style="display: inline;"&gt;A^{-1} = A^\dagger&lt;/pre&gt;, and &lt;pre lang="eq.latex" style="display: inline;"&gt;AA^\dagger = I&lt;/pre&gt;, and &lt;pre lang="eq.latex" style="display: inline;"&gt;\mathrm{det}(I) = +1&lt;/pre&gt;, then &lt;pre lang="eq.latex" style="display: inline;"&gt;\mathrm{det}(AA^\dagger) = \mathrm{det}(A)~\mathrm{det}(A^\dagger) = +1&lt;/pre&gt;. Since we know that &lt;pre lang="eq.latex" style="display: inline;"&gt;\mathrm{det}(A) = +1&lt;/pre&gt; as it is a member of the set of unitary matrices with determinant +1, then &lt;pre lang="eq.latex" style="display: inline;"&gt;\mathrm{det}(A^\dagger}) = +1 \Rightarrow \mathrm{det}(A^{-1}) = +1&lt;/pre&gt; as required.&lt;br /&gt;&lt;br /&gt;This forms the group SU(n).&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;Set of all n*n orthogonal matrices&lt;/span&gt;&lt;br /&gt;Orthogonal matrices are just real unitary matrices. Since I showed above that the set of all unitary matrices forms a group, the set of orthogonal matrices clearly forms a (sub) group too! If you want to be convinced, follow exactly the steps from above, replacing &lt;pre lang="eq.latex" style="display: inline;"&gt;A^\dagger&lt;/pre&gt; with &lt;pre lang="eq.latex" style="display: inline;"&gt;A^T&lt;/pre&gt;, the matrix transpose.&lt;br /&gt;&lt;br /&gt;This forms the group O(n).&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;Set of all n*n orthogonal matrices with determinant +1&lt;/span&gt;&lt;br /&gt;Exactly as above for the unitary (or orthogonal) matrices, and exactly as above for the matrices of determinant +1. This forms the group SO(n).&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4470666517647633822-1800796290535882109?l=physical-thought.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://physical-thought.blogspot.com/feeds/1800796290535882109/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4470666517647633822&amp;postID=1800796290535882109' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4470666517647633822/posts/default/1800796290535882109'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4470666517647633822/posts/default/1800796290535882109'/><link rel='alternate' type='text/html' href='http://physical-thought.blogspot.com/2008/08/groups-and-matrix-fun.html' title='Groups and Matrix Fun'/><author><name>Andrew J. Bennieston</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://bp2.blogger.com/_zi39n2uYgqg/R3f879w2IHI/AAAAAAAAAAY/IsPK0LU5Duc/S220/avatar.png'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4470666517647633822.post-8957229985369998684</id><published>2008-08-21T14:58:00.007+01:00</published><updated>2008-08-21T19:50:32.007+01:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='c++'/><category scheme='http://www.blogger.com/atom/ns#' term='g++'/><category scheme='http://www.blogger.com/atom/ns#' term='gcc'/><category scheme='http://www.blogger.com/atom/ns#' term='programming'/><category scheme='http://www.blogger.com/atom/ns#' term='boost'/><title type='text'>Noncopyable: A C++ class which cannot be copied</title><content type='html'>Yes, I know this is &lt;a href="http://www.boost.org/doc/libs/1_36_0/libs/utility/utility.htm#Class_noncopyable"&gt;reinventing the wheel [boost.org]&lt;/a&gt;, but sometimes reinventing the wheel is a good way of explaining to people why it's round!&lt;br /&gt;&lt;br /&gt;Consider the following problem: you have a handle on some resource (file, memory, socket, database connection, whatever...) and you want to have a single instance of a class responsible for managing that handle, freeing the resource when you're done with it. You want to be able to pass references to this one object around, but you don't want to encounter a situation where something made a copy of the object, so that the handle is still hanging around after the resource itself has been freed. This is, for example, useful in implementing smart pointers, socket libraries, etc. where you do not want to share ownership of the resource, but you want to share access to it, through the wrapper class which owns it.&lt;br /&gt;&lt;br /&gt;In C++, a copy of an object can be made in a number of situations. The most obvious is direct assignment:&lt;br /&gt;&lt;pre name="code" class="cpp"&gt;struct X {&lt;br /&gt;  int foo;&lt;br /&gt;};&lt;br /&gt;&lt;br /&gt;X a, b;&lt;br /&gt;a.foo = 2;&lt;br /&gt;b = a;&lt;br /&gt;// We now expect b.foo == 2&lt;br /&gt;&lt;/pre&gt;Less obvious, but equally valid, is a function call using pass-by-value:&lt;br /&gt;&lt;pre name="code" class="cpp"&gt;int Square(X object) { return object.foo*object.foo; }&lt;br /&gt;&lt;br /&gt;X a;&lt;br /&gt;std::cout &amp;lt;&amp;lt; Square(a) &amp;lt;&amp;lt; "\n";&lt;br /&gt;&lt;/pre&gt;In the examples above, the copy is harmless (though passing by reference could be more efficient!) If, however, the object contained a pointer you don't wish to relinquish ownership of, or if copying doesn't make sense for a certain class, you can prevent it altogether!&lt;br /&gt;&lt;br /&gt;Copying in C++ is handled in two ways. The first example above uses the copy assignment operator, and the second example uses a copy constructor. Both of these are provided implicitly by the compiler if a class does not declare its own. Here are some relevant quotes from the C++ standard:&lt;br /&gt;&lt;ul&gt;&lt;li&gt;12.1.10 A &lt;span style="font-style: italic;"&gt;copy constructor&lt;/span&gt; for a class &lt;span style="color: rgb(0, 0, 153);"&gt;X&lt;/span&gt; is a constructor with a first parameter of type &lt;span style="color: rgb(0, 0, 153);"&gt;X&amp;amp;&lt;/span&gt; or of type &lt;span style="color: rgb(0, 0, 153);"&gt;const X&amp;amp;&lt;/span&gt;.&lt;/li&gt;&lt;li&gt;12.8.2 A non-template constructor for class &lt;span style="color: rgb(0, 0, 153);"&gt;X&lt;/span&gt; is a &lt;span style="font-style: italic;"&gt;copy&lt;/span&gt; constructor if its first parameter is of type &lt;span style="color: rgb(0, 0, 153);"&gt;X&amp;amp;&lt;/span&gt;, &lt;span style="color: rgb(0, 0, 153);"&gt;const X&amp;amp;&lt;/span&gt;, &lt;span style="color: rgb(0, 0, 153);"&gt;volatile X&amp;amp;&lt;/span&gt; or &lt;span style="color: rgb(0, 0, 153);"&gt;const volatile X&amp;amp;&lt;/span&gt;, and either there are no other parameters or else all other parameters have default arguments.&lt;/li&gt;&lt;li&gt;12.8.4 If the class definition does not explicitly declare a copy constructor, one is declared &lt;span style="font-style: italic;"&gt;implicitly&lt;/span&gt;...&lt;/li&gt;&lt;li&gt;12.8.9 A user-declared &lt;span style="font-style: italic;"&gt;copy&lt;/span&gt; assignment operator &lt;span style="color: rgb(0, 0, 153);"&gt;X::operator=&lt;/span&gt; is a non-static non-template member function of class &lt;span style="color: rgb(0, 0, 153);"&gt;X&lt;/span&gt; with exactly one parameter of type &lt;span style="color: rgb(0, 0, 153);"&gt;X&lt;/span&gt;, &lt;span style="color: rgb(0, 0, 153);"&gt;X&amp;amp;&lt;/span&gt;, &lt;span style="color: rgb(0, 0, 153);"&gt;const X&amp;amp;&lt;/span&gt;, &lt;span style="color: rgb(0, 0, 153);"&gt;volatile X&amp;amp;&lt;/span&gt; or &lt;span style="color: rgb(0, 0, 153);"&gt;const volatile X&amp;amp;&lt;/span&gt;...&lt;/li&gt;&lt;li&gt;12.8.10 If the class definition does not explicitly declare a copy assignment operator, one is declared &lt;span style="font-style: italic;"&gt;implicitly&lt;/span&gt;...&lt;/li&gt;&lt;/ul&gt;&lt;br /&gt;&lt;br /&gt;The standard tells us exactly what we need to know here: the copy constructor should take a form similar to &lt;pre name="code" class="cpp"&gt;X::X(const X&amp;);&lt;/pre&gt; and the copy assignment operator should take a form similar to &lt;pre name="code" class="cpp"&gt;X&amp; X::operator=(const X&amp;);&lt;/pre&gt; If either of the two are not defined, the compiler provides an implicit version which is a &lt;span style="font-style:italic;"&gt;public member&lt;/span&gt; function.&lt;br /&gt;&lt;br /&gt;How does this help us to make an object which is noncopyable? Well, if we declare our own copy constructor and our own copy assignment operator, we prevent the compiler from generating its own. What is more, we can choose the visibility of our manually-declared versions. In particular, we can make them private (or protected, if it makes sense for derived classes to be able to implement copy semantics somehow...)&lt;br /&gt;&lt;br /&gt;By making the copy constructor and the copy assignment operator private, we prevent their use outside of the class itself, and therefore prevent the rest of the program from being able to make copies of the class!&lt;br /&gt;&lt;br /&gt;Now, if we want to make a class noncopyable, we can simply define its copy constructor and copy assignment operator as private members, documenting why we did that so that future maintainers don't make them public and screw up our best efforts to prevent copying, or we can do as they do in boost, and make a noncopyable base class!&lt;br /&gt;&lt;br /&gt;If a class derives from the noncopyable base class, it too will be noncopyable, since the copy of an object of a derived class must necessarily invoke the copy constructor or copy assignment operator of the corresponding base class, and in this case they are private, so that can't be done!&lt;br /&gt;&lt;br /&gt;Here's our noncopyable class:&lt;br /&gt;&lt;pre name="code" class="cpp"&gt;&lt;br /&gt;class noncopyable {&lt;br /&gt; private:&lt;br /&gt;  noncopyable(const noncopyable&amp; x);&lt;br /&gt;  noncopyable&amp; operator=(const noncopyable&amp; x);&lt;br /&gt; public:&lt;br /&gt;  noncopyable() {}; // Default constructor&lt;br /&gt;};&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;And here's a class which is derived from it, and a program which tries to make copies, first using the copy constructor as part of a function call, then using the copy assignment operator.&lt;br /&gt;&lt;pre name="code" class="cpp"&gt;&lt;br /&gt;#include &amp;lt;iostream&amp;gt;&lt;br /&gt;&lt;br /&gt;class noncopyable {&lt;br /&gt; private:&lt;br /&gt;  noncopyable(const noncopyable&amp; x);&lt;br /&gt;  noncopyable&amp; operator=(const noncopyable&amp; x)};&lt;br /&gt; public:&lt;br /&gt;  noncopyable() {}; // Default constructor&lt;br /&gt;};&lt;br /&gt;&lt;br /&gt;class X : noncopyable {&lt;br /&gt; public:&lt;br /&gt;  int c;&lt;br /&gt;};&lt;br /&gt;&lt;br /&gt;void print(const X x)&lt;br /&gt;{&lt;br /&gt; std::cout &amp;lt;&amp;lt; x.c &amp;lt;&amp;lt; "\n";&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;int main()&lt;br /&gt;{&lt;br /&gt; X x1;&lt;br /&gt; x1.c = 3;&lt;br /&gt; print(x1);&lt;br /&gt; X x2;&lt;br /&gt; x2 = x1;&lt;br /&gt; return 0;&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;And finally, here's what GCC spits out when we try to compile this, not only informing us that what we're trying to do won't work, but also clearly stating why in the error message -- the class name noncopyable is clearly visible!&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;loki:~$ g++ -o nocopy nocopy.cpp &lt;br /&gt;nocopy.cpp: In copy constructor 'X::X(const X&amp;)':&lt;br /&gt;nocopy.cpp:5: error: 'noncopyable::noncopyable(const noncopyable&amp;)' is private&lt;br /&gt;nocopy.cpp:11: error: within this context&lt;br /&gt;nocopy.cpp: In function 'int main()':&lt;br /&gt;nocopy.cpp:24: note: synthesized method 'X::X(const X&amp;)' first required here &lt;br /&gt;nocopy.cpp:24: error:   initializing argument 1 of 'void print(X)'&lt;br /&gt;nocopy.cpp: In member function 'X&amp; X::operator=(const X&amp;)':&lt;br /&gt;nocopy.cpp:6: error: 'noncopyable&amp; noncopyable::operator=(const noncopyable&amp;)' is private&lt;br /&gt;nocopy.cpp:11: error: within this context&lt;br /&gt;nocopy.cpp: In function 'int main()':&lt;br /&gt;nocopy.cpp:26: note: synthesized method 'X&amp; X::operator=(const X&amp;)' first required here&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;By contrast, this version passes the object by reference, and compiles cleanly:&lt;br /&gt;&lt;pre name="code" class="cpp"&gt;&lt;br /&gt;#include &amp;lt;iostream&amp;gt;&lt;br /&gt;&lt;br /&gt;class noncopyable {&lt;br /&gt; private:&lt;br /&gt;  noncopyable(const noncopyable&amp; x);&lt;br /&gt;  noncopyable&amp; operator=(const noncopyable&amp; x);&lt;br /&gt; public:&lt;br /&gt;  noncopyable() {}; // Default constructor&lt;br /&gt;};&lt;br /&gt;&lt;br /&gt;class X : noncopyable {&lt;br /&gt; public:&lt;br /&gt;  int c;&lt;br /&gt;};&lt;br /&gt;&lt;br /&gt;void print(const X&amp; x)&lt;br /&gt;{&lt;br /&gt; std::cout &amp;lt;&amp;lt; x.c &amp;lt;&amp;lt; "\n";&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;int main()&lt;br /&gt;{&lt;br /&gt; X x1;&lt;br /&gt; x1.c = 3;&lt;br /&gt; print(x1);&lt;br /&gt; return 0;&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;Output:&lt;pre&gt;loki:~$ ./nocopy &lt;br /&gt;3&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4470666517647633822-8957229985369998684?l=physical-thought.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://physical-thought.blogspot.com/feeds/8957229985369998684/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4470666517647633822&amp;postID=8957229985369998684' title='6 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4470666517647633822/posts/default/8957229985369998684'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4470666517647633822/posts/default/8957229985369998684'/><link rel='alternate' type='text/html' href='http://physical-thought.blogspot.com/2008/08/noncopyable-c-class-which-cannot-be.html' title='Noncopyable: A C++ class which cannot be copied'/><author><name>Andrew J. Bennieston</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://bp2.blogger.com/_zi39n2uYgqg/R3f879w2IHI/AAAAAAAAAAY/IsPK0LU5Duc/S220/avatar.png'/></author><thr:total>6</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4470666517647633822.post-5317901933512003034</id><published>2008-08-21T14:45:00.003+01:00</published><updated>2008-08-21T14:54:30.841+01:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='the plan'/><title type='text'>The Plan: The Update</title><content type='html'>In my &lt;a href="http://physical-thought.blogspot.com/2007/12/plan.html"&gt;second ever blog post&lt;/a&gt;, I outlined the reasons I started this blog. To recap, I planned to write about my ideas and projects in the hope that it would in some way document them, and that I might keep them alive long enough to make some actual progress.&lt;br /&gt;&lt;br /&gt;Over the course of the last eight months, the blog has evolved in a very different direction. Some of it is about posting my ideas and projects. In fact, that constitutes a large proportion of the posts. What I didn't foresee, however, was that my interest in writing and explaining things would take over somewhat.&lt;br /&gt;&lt;br /&gt;In the time this blog has been running, I've posted about electrodynamics, quantum mechanics, relativity and several other physics topics, as well as discussing fairly well-known but interesting aspects of a number of programming languages, often including small examples to demonstrate. In some cases, I've been playing with this stuff for the first time. In others, I've known about it for a while, but someone has asked me to explain it, or refreshed my interest, and I've felt like posting about it here.&lt;br /&gt;&lt;br /&gt;In short, this blog has expanded beyond my original reason for creating it, and has become a vast collection of whatever I happened to be thinking about on any given day. I've also started to get comments on some of the posts, which can only imply that people actually bother to read this stuff. I'm amazed, and I'd like to thank everyone who has made a comment, especially if it has been to point out something I forgot!&lt;br /&gt;&lt;br /&gt;As for the success of the original goal, reminding me about my projects and ideas, it has been of mixed worth. Some of the things I've returned to numerous times, others I simply haven't had time to look over again. At least I now have a written record of what I was thinking the first time around, now, so that should I ever decide to take up one of these projects, I can refer back to my original thoughts (and probably laugh at how wrong they were!)&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4470666517647633822-5317901933512003034?l=physical-thought.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://physical-thought.blogspot.com/feeds/5317901933512003034/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4470666517647633822&amp;postID=5317901933512003034' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4470666517647633822/posts/default/5317901933512003034'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4470666517647633822/posts/default/5317901933512003034'/><link rel='alternate' type='text/html' href='http://physical-thought.blogspot.com/2008/08/plan-update.html' title='The Plan: The Update'/><author><name>Andrew J. Bennieston</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://bp2.blogger.com/_zi39n2uYgqg/R3f879w2IHI/AAAAAAAAAAY/IsPK0LU5Duc/S220/avatar.png'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4470666517647633822.post-4149895797408703276</id><published>2008-08-21T14:27:00.002+01:00</published><updated>2008-08-21T14:33:32.253+01:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='python'/><category scheme='http://www.blogger.com/atom/ns#' term='programming'/><category scheme='http://www.blogger.com/atom/ns#' term='c'/><title type='text'>Slight modifications to Python/C sizeof program</title><content type='html'>I've made a few small changes to the sizeof.py program I posted &lt;a href="http://physical-thought.blogspot.com/2008/08/python-c-program-to-display-size-of-c.html"&gt;here&lt;/a&gt;. The first is in response to a comment on the original post, noting that I should change&lt;br /&gt;&lt;pre name="code" class="python"&gt;&lt;br /&gt;os.system(binfilename) # old&lt;br /&gt;os.system('./' + binfilename) # new&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;so that the program works on systems where the current working directory, ".", is not in the $PATH environment variable.&lt;br /&gt;&lt;br /&gt;The second change was to make the behaviour a bit better when you pass an undefined type to the sizeof program. The behaviour of the old version was to try to compile, showing the gcc errors resulting. This was not a problem, but the unlink(binfilename) line was before the unlink(cfilename) line, and if gcc failed, the binfile did not exist, so this unlink() failed, and the deletion of the source file never happened. I've now changed the order so that the .c file is deleted first, and sizeof.py should now leave no temporary files lying around, even if there's a compile error!&lt;br /&gt;&lt;br /&gt;The third change was to merge two lines into one. The old version had&lt;br /&gt;&lt;pre name="code" class="python"&gt;&lt;br /&gt;types = sys.argv[1:]&lt;br /&gt;for type in types:&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;and the new version merges these into&lt;br /&gt;&lt;pre name="code" class="python"&gt;&lt;br /&gt;for type in sys.argv[1:]:&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;In all, not big changes, but the second change at least is fairly important behaviour for handling cleanup of temporary files!&lt;br /&gt;&lt;br /&gt;Here's the full source again:&lt;br /&gt;&lt;pre name="code" class="python"&gt;&lt;br /&gt;#!/usr/bin/env python&lt;br /&gt;&lt;br /&gt;import sys, time, string, os&lt;br /&gt;&lt;br /&gt;code_pre = '#include &amp;lt;stdio.h&amp;gt;\nint main() {\n'&lt;br /&gt;code_post = '\treturn 0;\n}'&lt;br /&gt;code_mid = '\tprintf("TYPE: %d\\n", sizeof(TYPE));\n'&lt;br /&gt;&lt;br /&gt;if len(sys.argv) &amp;gt; 1:&lt;br /&gt; binfilename = 'pyctypes_' + str(time.time())&lt;br /&gt; cfilename = binfilename + '.c'&lt;br /&gt; out = open(cfilename, 'w')&lt;br /&gt; out.write(code_pre)&lt;br /&gt; for type in sys.argv[1:]:&lt;br /&gt;  out.write(code_mid.replace('TYPE', type))&lt;br /&gt; out.write(code_post)&lt;br /&gt; out.close()&lt;br /&gt; os.system('gcc -o ' + binfilename + ' ' + cfilename)&lt;br /&gt; os.system('./' + binfilename)&lt;br /&gt; os.unlink(cfilename)&lt;br /&gt; os.unlink(binfilename)&lt;br /&gt;&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4470666517647633822-4149895797408703276?l=physical-thought.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://physical-thought.blogspot.com/feeds/4149895797408703276/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4470666517647633822&amp;postID=4149895797408703276' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4470666517647633822/posts/default/4149895797408703276'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4470666517647633822/posts/default/4149895797408703276'/><link rel='alternate' type='text/html' href='http://physical-thought.blogspot.com/2008/08/slight-modifications-to-pythonc-sizeof.html' title='Slight modifications to Python/C sizeof program'/><author><name>Andrew J. Bennieston</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://bp2.blogger.com/_zi39n2uYgqg/R3f879w2IHI/AAAAAAAAAAY/IsPK0LU5Duc/S220/avatar.png'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4470666517647633822.post-1254648203368700442</id><published>2008-08-21T02:23:00.003+01:00</published><updated>2008-09-18T11:47:12.461+01:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='c++'/><category scheme='http://www.blogger.com/atom/ns#' term='programming'/><title type='text'>C++ Function Objects</title><content type='html'>I had a conversation with a computer scientist this evening about object-oriented stuff you can do in C++. Unfortunately, it seems that most comp. sci. teaching is through Java, which I find severely lacking in many respects when it comes to good object-oriented programming (multiple-inheritance and operator overloading, to name two things C++ has which Java doesn't).&lt;br /&gt;&lt;br /&gt;Anyway, one of the things that came up was the use of function objects, something which can't be done (at least in the same way) in Java because of the lack of operator overloading. Here is an example:&lt;br /&gt;&lt;br /&gt;You have a vector of numbers and you want to get the total. You could do something involving iterators and a for() or while() loop, or you could create a nice generic class for future use. The basic idea is simple... the constructor initialises some private member variable to zero (or whatever makes sense for the type in question), then you provide an operator() which allows objects of that class to be called as though they were functions. Define operator() such that it adds its argument to the private member variable representing the total, and call the whole thing in a for_each().&lt;br /&gt;&lt;br /&gt;The only point to consider is that std::for_each() takes a function-like-object as its fourth-argument, but does so by value. This means that if you create an accumulator object and pass it to for_each(), then a copy is made, for_each() acts using that copy, and the copy is destroyed when for_each() is finished. The original never gets its status updated.&lt;br /&gt;&lt;br /&gt;There are two ways around this. The first is to pass the function object by reference, which means explicitly stating the template arguments to for_each(), something like:&lt;br /&gt;&lt;pre name="code" class="cpp"&gt;&lt;br /&gt;std::for_each&amp;lt;std::vector&amp;lt;int&amp;gt;::iterator, Accumulator&amp;lt;int&amp;gt;&amp;amp;&amp;gt;(vec.begin(), vec.end(), acc);&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;The second method relies on the fact that for_each() returns its function object! None of the other standard algorithms do this, so you can only apply this neat trick with for_each(), but it is what I used in the code below, which represents a simple yet fairly comprehensive solution to the problem of adding each item in a container, regardless of the actual type of the item.&lt;br /&gt;&lt;br /&gt;&lt;pre name="code" class="cpp"&gt;&lt;br /&gt;#include &amp;lt;algorithm&amp;gt;&lt;br /&gt;#include &amp;lt;functional&amp;gt;&lt;br /&gt;#include &amp;lt;iostream&amp;gt;&lt;br /&gt;#include &amp;lt;vector&amp;gt;&lt;br /&gt;&lt;br /&gt;template&amp;lt;typename T&amp;gt; class Accumulator {&lt;br /&gt; T total;&lt;br /&gt;public:&lt;br /&gt; Accumulator() : total() {};&lt;br /&gt; void operator()(T&amp;amp; x) { total += x; };&lt;br /&gt; T&amp;amp; getTotal() { return total; };&lt;br /&gt;};&lt;br /&gt;&lt;br /&gt;int main()&lt;br /&gt;{&lt;br /&gt;std::vector&amp;lt;int&amp;gt; foo;&lt;br /&gt;foo.push_back(1);&lt;br /&gt;foo.push_back(2);&lt;br /&gt;foo.push_back(3);&lt;br /&gt;&lt;br /&gt;Accumulator&amp;lt;int&amp;gt; acc;&lt;br /&gt;acc = std::for_each(foo.begin(), foo.end(), Accumulator&amp;lt;int&amp;gt;() );&lt;br /&gt;std::cout &amp;lt;&amp;lt; acc.getTotal() &amp;lt;&amp;lt; std::endl;&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;The output of this program is, as expected, the number 6.&lt;br /&gt;&lt;br /&gt;The template class Accumulator constructs its total variable using the default constructor, which should provide a sensible default "zero" value. The getTotal() and operator() use references to avoid copying potentially large objects.&lt;br /&gt;&lt;br /&gt;The call to for_each() assigns its result to an Accumulator object and uses a temporary Accumulator as the function passed in.&lt;br /&gt;&lt;br /&gt;This is a fairly simple example of C++ function objects, and there are much more powerful (and much more complicated) possibilities. I wanted to present this example since it should be fairly easy to follow.&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(102, 0, 0);"&gt;Please note that at no point do I claim to have invented this technique. I'm discussing it here to inform others, and for no other reason. You see, I've always thought it was important to pass on knowledge, to help others to understand things. That is all I'm doing here. If you have a problem with that, I don't care.&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4470666517647633822-1254648203368700442?l=physical-thought.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://physical-thought.blogspot.com/feeds/1254648203368700442/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4470666517647633822&amp;postID=1254648203368700442' title='4 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4470666517647633822/posts/default/1254648203368700442'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4470666517647633822/posts/default/1254648203368700442'/><link rel='alternate' type='text/html' href='http://physical-thought.blogspot.com/2008/08/c-function-objects.html' title='C++ Function Objects'/><author><name>Andrew J. Bennieston</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://bp2.blogger.com/_zi39n2uYgqg/R3f879w2IHI/AAAAAAAAAAY/IsPK0LU5Duc/S220/avatar.png'/></author><thr:total>4</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4470666517647633822.post-5600526854609238854</id><published>2008-08-20T16:38:00.004+01:00</published><updated>2008-08-20T16:42:39.952+01:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='latex'/><category scheme='http://www.blogger.com/atom/ns#' term='feynman'/><category scheme='http://www.blogger.com/atom/ns#' term='particle physics'/><category scheme='http://www.blogger.com/atom/ns#' term='physics'/><title type='text'>FeynMF: Feynman Diagrams in LaTeX</title><content type='html'>When I posted the seventeen fourth-order Compton Scattering Feynman Diagrams, I was asked in a comment to show the LaTeX code responsible for generating them. I can't find the file for those diagrams, but I've drawn a QCD diagram here; quark-antiquark annihilation and production, with a gluon propagator.&lt;br /&gt;&lt;br /&gt;Here is the diagram:&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_zi39n2uYgqg/SKw635YKfBI/AAAAAAAAAMY/0BTCF5oR7lg/s1600-h/qcd.png"&gt;&lt;img style="display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;" src="http://4.bp.blogspot.com/_zi39n2uYgqg/SKw635YKfBI/AAAAAAAAAMY/0BTCF5oR7lg/s400/qcd.png" border="0" alt=""id="BLOGGER_PHOTO_ID_5236625198694431762" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;And here is the LaTeX code:&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;\documentclass{article}&lt;br /&gt;\usepackage{feynmf}&lt;br /&gt;\begin{document}&lt;br /&gt; \setlength{\unitlength}{1mm}&lt;br /&gt; &lt;br /&gt; \begin{fmffile}{feyn}&lt;br /&gt;  \begin{fmfgraph*}(40,25)&lt;br /&gt;   \fmfleft{q1,q2}&lt;br /&gt;   \fmfright{q3,q4}&lt;br /&gt;   \fmf{fermion}{q1,v1,q2}&lt;br /&gt;   \fmf{fermion}{q3,v2,q4}&lt;br /&gt;   \fmf{gluon}{v1,v2}&lt;br /&gt;   \fmflabel{$q$}{q1}&lt;br /&gt;   \fmflabel{$\bar{q}$}{q2}&lt;br /&gt;   \fmflabel{$q^\prime$}{q4}&lt;br /&gt;   \fmflabel{$\bar{q}^\prime$}{q3}&lt;br /&gt;   \fmfdot{v1,v2}&lt;br /&gt;  \end{fmfgraph*}&lt;br /&gt; \end{fmffile}&lt;br /&gt; &lt;br /&gt;\end{document}&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;In order for this to work, MetaFont and FeynMF need to be installed into the LaTeX distribution on your system. The commands to generate the (PDF, in this case) output are:&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;pdflatex quark&lt;br /&gt;mf '\mode=localfont; input feyn;'&lt;br /&gt;pdflatex quark&lt;br /&gt;pdflatex quark&lt;br /&gt;&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4470666517647633822-5600526854609238854?l=physical-thought.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://physical-thought.blogspot.com/feeds/5600526854609238854/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4470666517647633822&amp;postID=5600526854609238854' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4470666517647633822/posts/default/5600526854609238854'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4470666517647633822/posts/default/5600526854609238854'/><link rel='alternate' type='text/html' href='http://physical-thought.blogspot.com/2008/08/feynmf-feynman-diagrams-in-latex.html' title='FeynMF: Feynman Diagrams in LaTeX'/><author><name>Andrew J. Bennieston</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://bp2.blogger.com/_zi39n2uYgqg/R3f879w2IHI/AAAAAAAAAAY/IsPK0LU5Duc/S220/avatar.png'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://4.bp.blogspot.com/_zi39n2uYgqg/SKw635YKfBI/AAAAAAAAAMY/0BTCF5oR7lg/s72-c/qcd.png' height='72' width='72'/><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4470666517647633822.post-359580412044323468</id><published>2008-08-20T16:02:00.004+01:00</published><updated>2008-08-21T09:49:17.420+01:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='python'/><category scheme='http://www.blogger.com/atom/ns#' term='programming'/><category scheme='http://www.blogger.com/atom/ns#' term='c'/><title type='text'>Python / C Program to display size of C types</title><content type='html'>The code below is a Python program which takes a number of command-line arguments, each representing a C type-name. It constructs a C program which prints the size (in bytes) of each of the given data types, compiles (using gcc) that program, and runs it, then deletes the temporary source and binary files. It is useful if you want to know the size of a particular type on a given architecture but don't want to manually write out a C file that looks something like:&lt;br /&gt;&lt;pre name="code" class="cpp"&gt;&lt;br /&gt;#include &amp;lt;stdio.h&amp;gt;&lt;br /&gt;int main() {&lt;br /&gt;    printf("int: %d\n", sizeof(int));&lt;br /&gt;    return 0;&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;every time you want to know! In fact, the code above is exactly what this Python script produces and executes, but it inserts a printf line for each type you tell it you want to know the size of!&lt;br /&gt;&lt;br /&gt;Here's the code:&lt;br /&gt;&lt;pre name="code" class="python"&gt;&lt;br /&gt;#!/usr/bin/env python&lt;br /&gt;&lt;br /&gt;import sys, time, string, os&lt;br /&gt;&lt;br /&gt;code_pre = '#include &amp;lt;stdio.h&amp;gt;\nint main() {\n'&lt;br /&gt;code_post = '\treturn 0;\n}'&lt;br /&gt;code_mid = '\tprintf("TYPE: %d\\n", sizeof(TYPE));\n'&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;if len(sys.argv) &amp;gt; 1:&lt;br /&gt; binfilename = 'pyctypes_' + str(time.time())&lt;br /&gt; cfilename = binfilename + '.c'&lt;br /&gt; out = open(cfilename, 'w')&lt;br /&gt; out.write(code_pre)&lt;br /&gt; types = sys.argv[1:]&lt;br /&gt; for type in types:&lt;br /&gt;  out.write(code_mid.replace('TYPE', type))&lt;br /&gt; out.write(code_post)&lt;br /&gt; out.close()&lt;br /&gt; os.system('gcc -o ' + binfilename + ' ' + cfilename)&lt;br /&gt; os.system('./' + binfilename)&lt;br /&gt; os.unlink(binfilename)&lt;br /&gt; os.unlink(cfilename)&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;And here's a sample run:&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;loki:~$ ./sizeof.py "signed char" "unsigned long long" double float short&lt;br /&gt;signed char: 1&lt;br /&gt;unsigned long long: 8&lt;br /&gt;double: 8&lt;br /&gt;float: 4&lt;br /&gt;short: 2&lt;br /&gt;&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4470666517647633822-359580412044323468?l=physical-thought.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://physical-thought.blogspot.com/feeds/359580412044323468/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4470666517647633822&amp;postID=359580412044323468' title='3 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4470666517647633822/posts/default/359580412044323468'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4470666517647633822/posts/default/359580412044323468'/><link rel='alternate' type='text/html' href='http://physical-thought.blogspot.com/2008/08/python-c-program-to-display-size-of-c.html' title='Python / C Program to display size of C types'/><author><name>Andrew J. Bennieston</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://bp2.blogger.com/_zi39n2uYgqg/R3f879w2IHI/AAAAAAAAAAY/IsPK0LU5Duc/S220/avatar.png'/></author><thr:total>3</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4470666517647633822.post-7384203087278067521</id><published>2008-08-19T14:45:00.006+01:00</published><updated>2008-08-19T15:16:51.235+01:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='mathematics'/><category scheme='http://www.blogger.com/atom/ns#' term='physics'/><title type='text'>Estimating the volume of water in a shower</title><content type='html'>I noticed this morning (actually, afternoon... I was lazy today and didn't get up until almost 13:00) that in the summer I have showers with the water at about 30C, and in winter I turn it up to about 38C. Ignoring the obvious explanation that I just like to be warmer when it's colder outside, I decided to try to work out the approximate volume of water in the shower at any moment in time from those two temperatures and the air temperatures: around 25C on a warm summer day, and around 20C with the central heating on in winter.&lt;br /&gt;&lt;br /&gt;Assuming that I like a constant heat transfer (and ignoring the actual direction of it... for the values given the heat is actually flowing out of my body, not in) and using &lt;pre lang="eq.latex" style="display: inline;"&gt;Q = mc\Delta T&lt;/pre&gt; for the energy transfer, where m is mass, c is specific heat and dT is temperature difference, we can write:&lt;br /&gt;&lt;pre lang="eq.latex"&gt;&lt;br /&gt;\begin{align*}&lt;br /&gt;Q_\mathrm{Winter} = c_A\rho_{A20}V_A(20-37) + c_W\rho_{W38}V_W(38-37) \\&lt;br /&gt;Q_\mathrm{Summer} = c_A\rho_{A25}V_A(25-37) + c_W\rho_{W30}V_W(30-37)&lt;br /&gt;\end{align*}&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;where &lt;pre lang="eq.latex" style="display: inline;"&gt;\rho&lt;/pre&gt; is the density of air (A) and water (W) at the given temperature, V is the volume of air or water and c is the specific heat.&lt;br /&gt;&lt;br /&gt;Assuming that Q(Winter) = Q(Summer),&lt;br /&gt;&lt;pre lang="eq.latex"&gt;&lt;br /&gt;\begin{align*}&lt;br /&gt;-17c_A\rho_{A20}V_A + c_W\rho_{W38}V_W = -12c_A\rho_{A25}V_A - 7c_W\rho_{W30}V_W \\&lt;br /&gt;\left(7\rho_{W30} + \rho_{W38} \right)c_WV_W = \left(17\rho_{A20} - 12\rho_{A25}\right)c_AV_A&lt;br /&gt;\end{align*}&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;pre lang="eq.latex"&gt;&lt;br /&gt;\frac{c_W V_W}{c_A V_A} = \frac{17\rho_{A20} - 12\rho_{A25}}{7\rho_{W30}-\rho{W_38}}&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;The specific heats are: &lt;pre lang="eq.latex" style="display: inline;"&gt;c_W = 4.18~\mathrm{kJ~kg^{-1}~K^{-1}} ~~,~~ c_A = 1.005~\mathrm{kJ~kg^{-1}~K^{-1}}&lt;/pre&gt;, giving:&lt;br /&gt;&lt;pre lang="eq.latex"&gt;&lt;br /&gt;V_W = 0.24 V_A \left( \frac{17\rho_{A20} - 12\rho_{A25}}{7\rho_{W30}-\rho{W_38}} \right)&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;And finally, the densities:&lt;br /&gt;Air at 20C: 1.200870572 kg/m^3&lt;br /&gt;Air at 25C: 1.180721737 kg/m^3&lt;br /&gt;&lt;br /&gt;Water at 30C: 995.7 kg/m^3&lt;br /&gt;Water at 35C: 992.4 kg/m^3&lt;br /&gt;&lt;br /&gt;The total volume of the shower I stand in is about 1.27 m^3, and ignoring the volume of my body, this gives a volume of water as:&lt;br /&gt;&lt;pre lang="eq.latex"&gt;&lt;br /&gt;V_W = 2.39\times 10^{-4} ~\mathrm{m^3}&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;1 m^3 is 1000 litres, so this is a volume of 0.23 litres of water in the shower at any given time.&lt;br /&gt;&lt;br /&gt;Considering that a shower is a fairly fine spray of continuously falling water, this is not a bad estimate. I don't know the actual water delivery rate of the average shower, but I am willing to bet it isn't far off this value.&lt;br /&gt;&lt;br /&gt;However, there are a number of problems with this model:&lt;br /&gt;&lt;ol&gt;&lt;br /&gt;&lt;li&gt;The densities quoted for air are valid only for dry air. Water vapour reduces the air density, and in a shower there's going to be a fair amount of waver vapour around!&lt;/li&gt;&lt;br /&gt;&lt;li&gt;I have neglected the volume, mass and specific heat of the human body&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Not all of the air in the shower is in contact with the body, similarly not all of the water is&lt;/li&gt;&lt;br /&gt;&lt;li&gt;The water tends to form a film around the body, insulating it from the air, so the effect of water temperature is likely to be much more exaggerated than that of air temperature&lt;/li&gt;&lt;br /&gt;&lt;/ol&gt;&lt;br /&gt;&lt;br /&gt;I'm sure there are more flaws with this model, those were just the obvious ones. In any case, it was an interesting exercise and the number I got out of it sounds vaguely sensible, if perhaps a little on the low side! I'd say it was more likely that there was perhaps getting on for a litre of water in the shower, at any given time.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4470666517647633822-7384203087278067521?l=physical-thought.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://physical-thought.blogspot.com/feeds/7384203087278067521/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4470666517647633822&amp;postID=7384203087278067521' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4470666517647633822/posts/default/7384203087278067521'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4470666517647633822/posts/default/7384203087278067521'/><link rel='alternate' type='text/html' href='http://physical-thought.blogspot.com/2008/08/estimating-volume-of-water-in-shower.html' title='Estimating the volume of water in a shower'/><author><name>Andrew J. Bennieston</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://bp2.blogger.com/_zi39n2uYgqg/R3f879w2IHI/AAAAAAAAAAY/IsPK0LU5Duc/S220/avatar.png'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4470666517647633822.post-6951014361866076173</id><published>2008-08-19T00:35:00.002+01:00</published><updated>2008-08-19T00:40:10.189+01:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='c++'/><category scheme='http://www.blogger.com/atom/ns#' term='gcc'/><category scheme='http://www.blogger.com/atom/ns#' term='programming'/><category scheme='http://www.blogger.com/atom/ns#' term='gdb'/><category scheme='http://www.blogger.com/atom/ns#' term='c'/><title type='text'>Multiplying a number by -1: the NEG instruction</title><content type='html'>I completely forgot about the NEG instruction available on IA32 CPUs... it, well, negates things. gdb was more than happy to remind me about it when I wrote this test code:&lt;br /&gt;&lt;pre name="code" class="cpp"&gt;&lt;br /&gt;int f(int x) {&lt;br /&gt; return 2*x;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;int main() {&lt;br /&gt; int x = 2;&lt;br /&gt; int y = -f(x);&lt;br /&gt; return 0;&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;I compiled it using &lt;span style="font-style:italic;"&gt;gcc -ggdb&lt;/span&gt; and then fired up gdb. I instructed gdb to disassemble main, and the relevant lines are quite clear:&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;0x0804837c &amp;lt;main+30&amp;gt;:   call   0x8048354 &lt;f&gt;&lt;br /&gt;0x08048381 &amp;lt;main+35&amp;gt;:   neg    %eax&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;The compiler translates the negation of the result of a function call into a call followed by a negation of its return value using the NEG instruction. This is so obvious I don't know why I didn't realise it immediately, but hey, now I know!&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4470666517647633822-6951014361866076173?l=physical-thought.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://physical-thought.blogspot.com/feeds/6951014361866076173/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4470666517647633822&amp;postID=6951014361866076173' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4470666517647633822/posts/default/6951014361866076173'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4470666517647633822/posts/default/6951014361866076173'/><link rel='alternate' type='text/html' href='http://physical-thought.blogspot.com/2008/08/multiplying-number-by-1-neg-instruction.html' title='Multiplying a number by -1: the NEG instruction'/><author><name>Andrew J. Bennieston</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://bp2.blogger.com/_zi39n2uYgqg/R3f879w2IHI/AAAAAAAAAAY/IsPK0LU5Duc/S220/avatar.png'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4470666517647633822.post-6980635361474516106</id><published>2008-08-19T00:23:00.005+01:00</published><updated>2008-08-19T00:30:08.599+01:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='c++'/><category scheme='http://www.blogger.com/atom/ns#' term='programming'/><category scheme='http://www.blogger.com/atom/ns#' term='mathematics'/><category scheme='http://www.blogger.com/atom/ns#' term='c'/><title type='text'>Multiplying a number by -1: A bitwise approach</title><content type='html'>In my &lt;a href="http://physical-thought.blogspot.com/2008/08/profiling-minimum-maximum-finding.html"&gt;previous post&lt;/a&gt;, I mentioned that when the compiler encounters a line such as&lt;br /&gt;&lt;pre name="code" class="cpp"&gt;&lt;br /&gt;fx = -f(x);&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;it has to multiply the result of f(x) by -1. This can be interpreted in a number of ways, for example:&lt;br /&gt;&lt;pre name="code" class="cpp"&gt;&lt;br /&gt;// multiply by -1&lt;br /&gt;fx = -1 * f(x);&lt;br /&gt;// or subtract from 0&lt;br /&gt;fx = 0 - f(x);&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;Since compilers are tricky beasts, and processors are trickier still, it's entirely possible a bitwise approach is taken. Indeed, the processor may have a single instruction for "multiply by -1". I can't be bothered to check the Intel manual right now, but in any case, here's a program for bitwise multiplication by -1, and the output it produces:&lt;br /&gt;&lt;br /&gt;&lt;pre name="code" class="cpp"&gt;&lt;br /&gt;#include &amp;lt;stdio.h&amp;gt;&lt;br /&gt;&lt;br /&gt;int main()&lt;br /&gt;{&lt;br /&gt; int x;&lt;br /&gt; for(x = -5; x &lt; 5; ++x)&lt;br /&gt;  printf("x: %d\t-x: %d\n", x, ~x + 1);&lt;br /&gt; return 0;&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;loki:~$ ./neg-trial&lt;br /&gt;x: -5   -x: 5&lt;br /&gt;x: -4   -x: 4&lt;br /&gt;x: -3   -x: 3&lt;br /&gt;x: -2   -x: 2&lt;br /&gt;x: -1   -x: 1&lt;br /&gt;x: 0    -x: 0&lt;br /&gt;x: 1    -x: -1&lt;br /&gt;x: 2    -x: -2&lt;br /&gt;x: 3    -x: -3&lt;br /&gt;x: 4    -x: -4&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;It would be interesting to find out exactly how a line like y = -f(x); is compiled... perhaps I'll dig around a little more and post again about this!&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4470666517647633822-6980635361474516106?l=physical-thought.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://physical-thought.blogspot.com/feeds/6980635361474516106/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4470666517647633822&amp;postID=6980635361474516106' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4470666517647633822/posts/default/6980635361474516106'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4470666517647633822/posts/default/6980635361474516106'/><link rel='alternate' type='text/html' href='http://physical-thought.blogspot.com/2008/08/multiplying-number-by-1-bitwise.html' title='Multiplying a number by -1: A bitwise approach'/><author><name>Andrew J. Bennieston</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://bp2.blogger.com/_zi39n2uYgqg/R3f879w2IHI/AAAAAAAAAAY/IsPK0LU5Duc/S220/avatar.png'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4470666517647633822.post-2537205853222509219</id><published>2008-08-18T23:47:00.004+01:00</published><updated>2008-08-19T00:14:48.845+01:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='valgrind'/><category scheme='http://www.blogger.com/atom/ns#' term='double-beta'/><category scheme='http://www.blogger.com/atom/ns#' term='c++'/><category scheme='http://www.blogger.com/atom/ns#' term='projects'/><category scheme='http://www.blogger.com/atom/ns#' term='event generator'/><category scheme='http://www.blogger.com/atom/ns#' term='particle physics'/><category scheme='http://www.blogger.com/atom/ns#' term='programming'/><category scheme='http://www.blogger.com/atom/ns#' term='graph'/><category scheme='http://www.blogger.com/atom/ns#' term='physics'/><category scheme='http://www.blogger.com/atom/ns#' term='pebble'/><title type='text'>Profiling a Minimum / Maximum finding algorithm</title><content type='html'>Today I extracted the Minima/Maxima finding algorithm from Pebble v1 and re-implemented the necessary parts to make it work in a more-or-less standalone manner. The min/max class itself requires only some functor class representing the function it operates on. For this I created a base class Function with a virtual double operator()(double x);&lt;br /&gt;&lt;br /&gt;In addition, the min/max algorithm in Pebble throws a Pebble::Exception on certain error conditions, so I had to provide an Exception class as well.&lt;br /&gt;&lt;br /&gt;The reason for doing this is twofold. First, it's the best algorithm I've found for finding the minima of a function, so it'll be useful in Pebble v2. Second, Pebble v1 uses a minimum finder to locate maxima. It does this because if a function f(x) has a maximum at some x, then the function -f(x) has a minimum at the same x. In order to use the minima-finder, then, we had to pass "negated" versions of the functions to it. Pebble v1 does this using a Negater class which derives publically from the Pebble::Math::Calculus::Integrand class, a functor representing the mathematical functions handled within Pebble.&lt;br /&gt;&lt;br /&gt;In the code I extracted today, I replaced Pebble::Math::Calculus::Integrand by Pebble::Math::Function. As I said above, this is an abstract base class with virtual public member functions (I don't want to say methods, it sounds too Java-esque). Anyway, in the new Pebble::Math::Minimiser, I provided two equivalent functions, getMinimum() and getMaximum(). The code is exactly the same between the two, apart from the calls to the function itself. In getMinimum(), the function is called as-is, so a function wrapped in a Negater object will have its maxima found through the getMinimum() function.&lt;br /&gt;&lt;br /&gt;However, getMaximum() changes the calls to -f(x), eliminating a whole level of indirection and virtual member function lookup. I expected this version to be faster, but to check this I profiled a test-case, finding the maximum of a probability distribution function used in the original Pebble code. The test-case performs one million constructions and maximum-finding operations on this distribution, and valgrind --tool=callgrind was used to profile the execution for a version using a Negater and for a version directly using getMaximum().&lt;br /&gt;&lt;br /&gt;Here are the call graphs, first for the getMinimum(Negater(fn)):&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_zi39n2uYgqg/SKn-1aSN7qI/AAAAAAAAAME/d-NUg1cWzG4/s1600-h/with-neg.png"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer;" src="http://2.bp.blogspot.com/_zi39n2uYgqg/SKn-1aSN7qI/AAAAAAAAAME/d-NUg1cWzG4/s400/with-neg.png" alt="" id="BLOGGER_PHOTO_ID_5235996235337166498" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;and then for getMaximum(fn):&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_zi39n2uYgqg/SKn_AVcwxkI/AAAAAAAAAMQ/d5pRrzNYH4s/s1600-h/without-neg.png"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer;" src="http://1.bp.blogspot.com/_zi39n2uYgqg/SKn_AVcwxkI/AAAAAAAAAMQ/d5pRrzNYH4s/s400/without-neg.png" alt="" id="BLOGGER_PHOTO_ID_5235996423017776706" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;The numbers in the graphs are the absolute cost of execution, measured in terms of instruction fetch (for those who know what that means... I'm only partly sure myself!) As I expected, the version which uses -f(x) is faster than the version that uses a Negater to wrap f(x), and the execution cost shows this. The absolute cost of getMinimum() is 5,539,000,000 with the Negater, and 4,947,000,000 without. Looking at the source-code profiling information, the lines in which f(x) are evaluated actually have a higher direct cost for the -f(x) version. This is to be expected, since there's a multiplication by -1 going on (or a subtraction from zero, or some cunning bitwise trick to make a number negative). Both versions involve a virtual function call, so the direct overhead of that is the same.&lt;br /&gt;&lt;br /&gt;The difference comes from the overhead introduced by the Negater object. The cost of a line containing the source:&lt;br /&gt;&lt;pre name="code" class="cpp"&gt;&lt;br /&gt;fx = (*f)(x);&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;has a cost of 874,000,000 for 19,000,000 calls to Pebble::Math::Negater::operator().&lt;br /&gt;&lt;br /&gt;By contrast, the equivalent line in the getMaximum() version:&lt;br /&gt;&lt;pre name="code" class="cpp"&gt;&lt;br /&gt;fx = -(*f)(x);&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;only has a cost of 551,000,000 for the same 19 million calls directly to Mode1::operator().&lt;br /&gt;&lt;br /&gt;If you didn't understand a word of the above, I'll summarise the key points here:&lt;br /&gt;&lt;ul&gt;&lt;li&gt;Obviously, eliminating a level of indirection makes things faster, with fewer overheads&lt;/li&gt;&lt;li&gt;Duplicating the code, changing only one or two lines, in this way, is generally considered to be a bad thing&lt;/li&gt;&lt;li&gt;Having the Negater class around could be useful for other situations where one cannot easily just put a negative sign into the code, especially if I decide to use dynamic libraries, where one will not be able to simply change the code at leisure&lt;/li&gt;&lt;li&gt;In this case, considering that in my previous profiling of Pebble v1, the Minimiser and Integrator are the biggest bottlenecks, the speed increase benefit outweighs the code-duplication drawback, so I'm going to leave it in there!&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4470666517647633822-2537205853222509219?l=physical-thought.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://physical-thought.blogspot.com/feeds/2537205853222509219/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4470666517647633822&amp;postID=2537205853222509219' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4470666517647633822/posts/default/2537205853222509219'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4470666517647633822/posts/default/2537205853222509219'/><link rel='alternate' type='text/html' href='http://physical-thought.blogspot.com/2008/08/profiling-minimum-maximum-finding.html' title='Profiling a Minimum / Maximum finding algorithm'/><author><name>Andrew J. Bennieston</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://bp2.blogger.com/_zi39n2uYgqg/R3f879w2IHI/AAAAAAAAAAY/IsPK0LU5Duc/S220/avatar.png'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://2.bp.blogspot.com/_zi39n2uYgqg/SKn-1aSN7qI/AAAAAAAAAME/d-NUg1cWzG4/s72-c/with-neg.png' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4470666517647633822.post-6470419666752331593</id><published>2008-08-18T12:52:00.008+01:00</published><updated>2008-08-18T13:07:36.383+01:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='hash functions'/><category scheme='http://www.blogger.com/atom/ns#' term='gnuplot'/><category scheme='http://www.blogger.com/atom/ns#' term='cryptography'/><category scheme='http://www.blogger.com/atom/ns#' term='graph'/><category scheme='http://www.blogger.com/atom/ns#' term='google'/><title type='text'>Googling MD5 Hashes</title><content type='html'>It occurred to me last night that it's likely there are a lot of MD5 hashes floating around on web pages with the associated plaintext right next to them, and that Google, by indexing most of the web, would perhaps be one of the world's most comprehensive lookup tables for MD5 (or other cryptographic function) data.&lt;br /&gt;&lt;br /&gt;This morning, I set out to generate the MD5 hashes of a number of "commonly used passwords". Personally, I can't believe anyone uses these in the real world, but there's plenty of evidence to suggest they do!&lt;br /&gt;&lt;br /&gt;Once I'd generated the hashes, I Googled each hash and made a note of the number of search results returned. Additionally, I checked that within the first page of Foogle results, the plaintext appeared clearly in such a way that it is obviously the plaintext corresponding to that hash value. Every single hash I tried (except those for which no results were found) had its plaintext within the first page of Google results.&lt;br /&gt;&lt;br /&gt;Here's the word list, hash for each word, and number of Google results as of about 11:30 this morning.&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_zi39n2uYgqg/SKlkGcm4KoI/AAAAAAAAALs/lbC23i10P5U/s1600-h/wordtable.png"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer;" src="http://1.bp.blogspot.com/_zi39n2uYgqg/SKlkGcm4KoI/AAAAAAAAALs/lbC23i10P5U/s400/wordtable.png" alt="" id="BLOGGER_PHOTO_ID_5235826103716162178" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;And here's a graph representing these results. The last 'word' is a character sequence I made up on the spot, and reassuringly it returned no results!&lt;br /&gt;&lt;br /&gt;&lt;div style="text-align: center;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_zi39n2uYgqg/SKlkGS1hbNI/AAAAAAAAAL0/G_dwBIdK9os/s1600-h/graph.png"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer;" src="http://2.bp.blogspot.com/_zi39n2uYgqg/SKlkGS1hbNI/AAAAAAAAAL0/G_dwBIdK9os/s400/graph.png" alt="" id="BLOGGER_PHOTO_ID_5235826101093231826" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;span style="font-size:85%;"&gt;(Click image for larger version)&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;It would appear that I'm not the only person (and certainly not the first) to have had this idea. In fact, there exists a proof-of-concept web site at Google Hash ( &lt;a href="http://www.nth-dimension.org.uk/utils/ghash.php"&gt;http://www.nth-dimension.org.uk/utils/ghash.php&lt;/a&gt; ) where the aim is to get Google to index the hash and its associated plaintext!&lt;br /&gt;&lt;br /&gt;For those that care about such things, the graph was produced from columns 1 and 3 (plaintext and search result count) of the data I posted above in a file with the hash column removed. The gnuplot command was:&lt;br /&gt;&lt;pre&gt;plot 'counts.txt' using ($0-0.2):2:xticlabels(1) with boxes title '',&lt;br /&gt;'counts.txt' using 0:2:2 with labels center offset 0,1 notitle&lt;br /&gt;&lt;/pre&gt;Of course, there were also titles, axis labels and PostScript output settings, but they're not important here.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4470666517647633822-6470419666752331593?l=physical-thought.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://physical-thought.blogspot.com/feeds/6470419666752331593/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4470666517647633822&amp;postID=6470419666752331593' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4470666517647633822/posts/default/6470419666752331593'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4470666517647633822/posts/default/6470419666752331593'/><link rel='alternate' type='text/html' href='http://physical-thought.blogspot.com/2008/08/googling-md5-hashes.html' title='Googling MD5 Hashes'/><author><name>Andrew J. Bennieston</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://bp2.blogger.com/_zi39n2uYgqg/R3f879w2IHI/AAAAAAAAAAY/IsPK0LU5Duc/S220/avatar.png'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://1.bp.blogspot.com/_zi39n2uYgqg/SKlkGcm4KoI/AAAAAAAAALs/lbC23i10P5U/s72-c/wordtable.png' height='72' width='72'/><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4470666517647633822.post-8160029971566276704</id><published>2008-08-17T14:43:00.003+01:00</published><updated>2008-08-17T17:10:13.887+01:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='photography'/><category scheme='http://www.blogger.com/atom/ns#' term='photoshop'/><category scheme='http://www.blogger.com/atom/ns#' term='surfing'/><title type='text'>Surf Photography: Rip Curl Boardmasters 2008</title><content type='html'>I took this on Thursday August 7th, 2008 at Fistral Beach, Newquay Cornwall. The Rip Curl Boardmasters is a surf competition and festival which has been at Fistral for as long as I can remember, and it's a great atmosphere.&lt;br /&gt;&lt;br /&gt;This was taken at the 300mm end of my 70-300mm lens with a shutter speed of 1/640 s, aperture f/8.0 and ISO 200. It was subsequently adjusted in Photoshop to improve the contrast a little, then cropped to remove a bit of empty sea.&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_zi39n2uYgqg/SKgsD9ulTZI/AAAAAAAAALk/gFTtmbYqf18/s1600-h/img_3673-cropped.jpg"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer;" src="http://3.bp.blogspot.com/_zi39n2uYgqg/SKgsD9ulTZI/AAAAAAAAALk/gFTtmbYqf18/s400/img_3673-cropped.jpg" alt="" id="BLOGGER_PHOTO_ID_5235483013439376786" border="0" /&gt;&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4470666517647633822-8160029971566276704?l=physical-thought.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://physical-thought.blogspot.com/feeds/8160029971566276704/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4470666517647633822&amp;postID=8160029971566276704' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4470666517647633822/posts/default/8160029971566276704'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4470666517647633822/posts/default/8160029971566276704'/><link rel='alternate' type='text/html' href='http://physical-thought.blogspot.com/2008/08/surf-photography-rip-curl-boardmasters.html' title='Surf Photography: Rip Curl Boardmasters 2008'/><author><name>Andrew J. Bennieston</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://bp2.blogger.com/_zi39n2uYgqg/R3f879w2IHI/AAAAAAAAAAY/IsPK0LU5Duc/S220/avatar.png'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://3.bp.blogspot.com/_zi39n2uYgqg/SKgsD9ulTZI/AAAAAAAAALk/gFTtmbYqf18/s72-c/img_3673-cropped.jpg' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4470666517647633822.post-615181965975902583</id><published>2008-08-17T13:12:00.003+01:00</published><updated>2008-08-17T13:26:36.833+01:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='valgrind'/><category scheme='http://www.blogger.com/atom/ns#' term='double-beta'/><category scheme='http://www.blogger.com/atom/ns#' term='c++'/><category scheme='http://www.blogger.com/atom/ns#' term='random numbers'/><category scheme='http://www.blogger.com/atom/ns#' term='projects'/><category scheme='http://www.blogger.com/atom/ns#' term='event generator'/><category scheme='http://www.blogger.com/atom/ns#' term='particle physics'/><category scheme='http://www.blogger.com/atom/ns#' term='monte carlo'/><category scheme='http://www.blogger.com/atom/ns#' term='programming'/><category scheme='http://www.blogger.com/atom/ns#' term='graph'/><category scheme='http://www.blogger.com/atom/ns#' term='physics'/><category scheme='http://www.blogger.com/atom/ns#' term='pebble'/><title type='text'>Pebble v1 Call Graph</title><content type='html'>Following up on my recent post about a C++ implementation of the Mersenne Twister pseudo-random number generator (PRNG), I decided to find out just how much the performance of the PRNG actually affects a Monte Carlo system such as Pebble. Clearly, the random number generation is a critical part of the procedure, but as I'm about to show, it is definitely not the slowest part of Pebble, by a long way.&lt;br /&gt;&lt;br /&gt;The &lt;a href="http://valgrind.org/"&gt;valgrind&lt;/a&gt; tool allows a programmer to check their programs for many things, including memory leaks (the original goal of the valgrind project). One of the neat things it does is function call profiling and graphing. The idea is simple, you run a program inside valgrind using the &lt;span style="font-style: italic;"&gt;callgrind&lt;/span&gt;  option, and it tracks every function call made within the program. This lets you figure out how many times a function is being called, and how much of the program execution time is spent within a given function, allowing you to easily profile the code and determine functions or classes which are good candidates for optimisation.&lt;br /&gt;&lt;br /&gt;Here is the call graph for Pebble v1, which uses a C++ implementation of the Mersenne Twister which I wrote last summer, rather than the new one I have recently posted about.&lt;br /&gt;&lt;br /&gt;&lt;div style="text-align: center;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_zi39n2uYgqg/SKgXCoVV7HI/AAAAAAAAALc/RZksgZOfUzo/s1600-h/pebble.png"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer;" src="http://2.bp.blogspot.com/_zi39n2uYgqg/SKgXCoVV7HI/AAAAAAAAALc/RZksgZOfUzo/s400/pebble.png" alt="" id="BLOGGER_PHOTO_ID_5235459900772314226" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;span style="font-size:85%;"&gt;(Click for larger version)&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;The random number generation, performed by &lt;span style="color: rgb(0, 102, 0);"&gt;Pebble::Math::Random::MersenneTwister::getDouble&lt;/span&gt; and &lt;span style="color: rgb(0, 102, 0);"&gt;getLong&lt;/span&gt;, account for a mere 3.33% of the time spent in the event generator function &lt;span style="color: rgb(0, 102, 0);"&gt;Pebble::EventGenerator::generate&lt;/span&gt;. In contrast, finding minima of the probability distribution functions (using &lt;span style="color: rgb(0, 102, 0);"&gt;Pebble::Math::Utility::Minimiser::getMinimum&lt;/span&gt;) accounts for 31.29%, and integrating the PDFs for normalisation purposes (using &lt;span style="color: rgb(0, 102, 0);"&gt;Pebble::Math::Calculus::RombergIntegrator::integrate&lt;/span&gt;) accounts for 50.82% of the time spent generating events.&lt;br /&gt;&lt;br /&gt;It is clear from this that, if I want to improve on the speed of generation in "Pebble v2", I need to focus my efforts on efficient minimia-finding and numerical integration functions.&lt;br /&gt;&lt;br /&gt;There is also 7.47% of the time taken to generate events spent adding particles to an Event object, using the &lt;span style="color: rgb(0, 102, 0);"&gt;Pebble::Event::addParticle&lt;/span&gt; function. A lot of this time is accounted for by the memory allocation, and as I mentioned in my previous post, eliminating such object-oriented extravagances, while maintaining a sensible object-oriented design for the important parts of the program, should help to boost the speed of any new version.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4470666517647633822-615181965975902583?l=physical-thought.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://physical-thought.blogspot.com/feeds/615181965975902583/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4470666517647633822&amp;postID=615181965975902583' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4470666517647633822/posts/default/615181965975902583'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4470666517647633822/posts/default/615181965975902583'/><link rel='alternate' type='text/html' href='http://physical-thought.blogspot.com/2008/08/pebble-v1-call-graph.html' title='Pebble v1 Call Graph'/><author><name>Andrew J. Bennieston</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://bp2.blogger.com/_zi39n2uYgqg/R3f879w2IHI/AAAAAAAAAAY/IsPK0LU5Duc/S220/avatar.png'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://2.bp.blogspot.com/_zi39n2uYgqg/SKgXCoVV7HI/AAAAAAAAALc/RZksgZOfUzo/s72-c/pebble.png' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4470666517647633822.post-3304006069369295513</id><published>2008-08-15T16:21:00.004+01:00</published><updated>2008-08-15T16:51:19.250+01:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='c++'/><category scheme='http://www.blogger.com/atom/ns#' term='random numbers'/><category scheme='http://www.blogger.com/atom/ns#' term='projects'/><category scheme='http://www.blogger.com/atom/ns#' term='particle physics'/><category scheme='http://www.blogger.com/atom/ns#' term='monte carlo'/><category scheme='http://www.blogger.com/atom/ns#' term='programming'/><category scheme='http://www.blogger.com/atom/ns#' term='graph'/><category scheme='http://www.blogger.com/atom/ns#' term='c'/><category scheme='http://www.blogger.com/atom/ns#' term='physics'/><category scheme='http://www.blogger.com/atom/ns#' term='pebble'/><title type='text'>Mersenne Twister</title><content type='html'>A key part of the Pebble program was the ability to generate lots of good-quality pseudo-random numbers for Monte Carlo (MC). The &lt;a href="http://www.math.sci.hiroshima-u.ac.jp/%7Em-mat/MT/emt.html"&gt;Mersenne Twister&lt;/a&gt; (MT) algorithm is ideally suited to this, and is indeed the algorithm we used. The original author, Makoto Matsumoto, has published C source for the algorithm, which I converted into a C++ class for the project, using the same interface as several other random number generators (RNGs) provided within Pebble.&lt;br /&gt;&lt;br /&gt;So, following my post yesterday about considering building a "Pebble v2" or similar, I've spent the afternoon looking back into Mersenne Twister. The C code is fairly small, and reasonably easy to understand (surprisingly for something as complicated as a PRNG!) and I had no difficulty converting it to C++ the first time around. This time, I've ignored a lot of the complicated interface I built in the first time, since I no longer intend to provide other RNGs -- Mersenne Twister is more than good enough for any MC purposes.&lt;br /&gt;&lt;br /&gt;Anyway, I modified the MT code to encapsulate it in a C++ class (code below), then ran some timing tests against the C version. In order to get useful timing data, I had to generate 1 million integers and 1 million real numbers, timing the program run for the entire thing. A real number is generated from a single integer, so this is roughly equivalent to two million integer number generations, plus a little overhead in converting half of them to a number between 0 and 1.&lt;br /&gt;&lt;br /&gt;For the purposes of this test, I removed all the program output code from both the original C code and my new C++ version, timing the programs as they generated and threw away two million random numbers. The reason for removing output code was to prevent any skew in the results from the different output systems used by C and C++.&lt;br /&gt;&lt;br /&gt;The test itself consisted of running a program to generate 1M integers and 1M reals, using the C or C++ versions of the MT algorithm, respectively. Each test was run ten times, using the bash &lt;span style="font-style: italic;"&gt;time&lt;/span&gt; command to provide timing details. I discarded the &lt;span style="font-style: italic;"&gt;real&lt;/span&gt; time taken, which refers to what is known as wall time -- the amount of actual elapsed time according to a clock on the wall -- and focused only on the user and system times, which are the number of seconds the CPU actually spent running the program in user-space and in system-calls, respectively.&lt;br /&gt;&lt;br /&gt;The graph below shows the results. Both are incredibly fast, with the slowest taking a mere 0.156 seconds of CPU time. If I can generate two million random numbers in 0.2 seconds, this will certainly not be a bottleneck in any MC system!&lt;br /&gt;&lt;br /&gt;&lt;div style="text-align: center;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_zi39n2uYgqg/SKWij9yJTtI/AAAAAAAAALU/EWdB85NQC0U/s1600-h/mt-graph.png"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer;" src="http://4.bp.blogspot.com/_zi39n2uYgqg/SKWij9yJTtI/AAAAAAAAALU/EWdB85NQC0U/s400/mt-graph.png" alt="" id="BLOGGER_PHOTO_ID_5234768880652078802" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;span style="font-size:85%;"&gt;(Click image for larger version)&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;The comparison, however, is slightly discouraging. The system times are incredibly low, 0.002 and 0.001 seconds for C and C++ respectively, averaged over ten runs. This is almost certainly because I removed all of the I/O, so the only time spent in the "system" would be the initial memory allocation and the final deallocation. In fact, I'd expect the C++ variant to take longer here, as the MersenneTwister object must be constructed. Still, these times are so close to zero it's hard to talk about them meaningfully.&lt;br /&gt;&lt;br /&gt;The "user" times tell a different story. These are also averaged over ten runs, and show that the C++ version took almost twice as long as the C version. I expected there to be a little overhead from dynamically allocating the array used to store the internal state of the MT generator, but that should be a one-time thing, and the rest of the code is almost identical. I can only assume that the discrepancy arises from the function calls being mapped to member functions in C++ rather than global functions in C.&lt;br /&gt;&lt;br /&gt;Many would argue that the factor of 2 slowdown is completely unacceptable, even if the C++ version does hide the details of MT (no defines, no global variables, just a few member variables). I agree that the reduction in speed is quite dramatic here, but compared to other components of a functioning Monte Carlo system, this overhead is negligible, and for any program written predominantly in C++, encapsulating the functionality and hiding the details is a good idea. This is where the hardcore C fans would argue that no system which requires speed or efficiency should be written in C++, but I disagree, backed up by plenty of evidence for C++ development in the physical sciences, and in particle physics in particular!&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold; color: rgb(204, 0, 0);"&gt;MersenneTwister.hpp&lt;/span&gt;&lt;br /&gt;&lt;pre name="code" class="cpp"&gt;&lt;br /&gt;/*&lt;br /&gt; A C++ program for MT19937, with initialization improved 2002/1/26.&lt;br /&gt; Original C Coded by Takuji Nishimura and Makoto Matsumoto.&lt;br /&gt; Converted to a C++ class by Andrew J. Bennieston&lt;br /&gt;&lt;br /&gt; Before using, initialize the state by using init(seed)&lt;br /&gt; or initArray(init_key, key_length).&lt;br /&gt;&lt;br /&gt; Copyright (C) 1997 - 2002, Makoto Matsumoto and Takuji Nishimura,&lt;br /&gt; All rights reserved.&lt;br /&gt; C++ Class modifications copyright (C) 2008, Andrew J. Bennieston.&lt;br /&gt;&lt;br /&gt; Redistribution and use in source and binary forms, with or without&lt;br /&gt; modification, are permitted provided that the following conditions&lt;br /&gt; are met:&lt;br /&gt;&lt;br /&gt;   1. Redistributions of source code must retain the above copyright&lt;br /&gt;      notice, this list of conditions and the following disclaimer.&lt;br /&gt;&lt;br /&gt;   2. Redistributions in binary form must reproduce the above copyright&lt;br /&gt;      notice, this list of conditions and the following disclaimer in the&lt;br /&gt;      documentation and/or other materials provided with the distribution.&lt;br /&gt;&lt;br /&gt;   3. The names of its contributors may not be used to endorse or promote&lt;br /&gt;      products derived from this software without specific prior written&lt;br /&gt;      permission.&lt;br /&gt;&lt;br /&gt; THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS&lt;br /&gt; "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT&lt;br /&gt; LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR&lt;br /&gt; A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR&lt;br /&gt; CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,&lt;br /&gt; EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,&lt;br /&gt; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR&lt;br /&gt; PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF&lt;br /&gt; LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING&lt;br /&gt; NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS&lt;br /&gt; SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt; Any feedback is very welcome.&lt;br /&gt; http://www.math.sci.hiroshima-u.ac.jp/~m-mat/MT/emt.html&lt;br /&gt; email: m-mat @ math.sci.hiroshima-u.ac.jp (remove space)&lt;br /&gt;&lt;br /&gt; Feedback on the C++ modifications to andrew @ physical - thought . com (remove spaces)&lt;br /&gt;*/&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;class MersenneTwister {&lt;br /&gt;  private:&lt;br /&gt;      const int N;&lt;br /&gt;      const int M;&lt;br /&gt;      const unsigned long MATRIX_A;&lt;br /&gt;      const unsigned long UPPER_MASK;&lt;br /&gt;      const unsigned long LOWER_MASK;&lt;br /&gt;      int mti;&lt;br /&gt;      unsigned long* mt;&lt;br /&gt;  public:&lt;br /&gt;      // Constructors&lt;br /&gt;      MersenneTwister()&lt;br /&gt;          : N(624), M(397), MATRIX_A(0x9908b0dfUL),&lt;br /&gt;          UPPER_MASK(0x80000000UL), LOWER_MASK(0x7fffffffUL),&lt;br /&gt;          mti(N+1)&lt;br /&gt;          { mt = new unsigned long[N]; };&lt;br /&gt;&lt;br /&gt;      // Destructor&lt;br /&gt;      ~MersenneTwister() { delete[] mt; };&lt;br /&gt;   &lt;br /&gt;      // Initialisation&lt;br /&gt;      void init(unsigned long s);&lt;br /&gt;      void initArray(unsigned long init_key[], int key_length);&lt;br /&gt;&lt;br /&gt;      // Random number generation&lt;br /&gt;      unsigned long genInt32(); // Random integer on [0,0xffffffff]&lt;br /&gt;      long genInt31(); // Random integer on [0,0x7fffffff]&lt;br /&gt;      double genRealClosed(); // Random real on closed range [0,1]&lt;br /&gt;      double genReal(); // Random real on half-open range [0,1) (i.e. not including 1)&lt;br /&gt;      double genRealOpen(); // Random real on open range (0,1) (i.e. not including 0 or 1)&lt;br /&gt;      double genReal53(); // Random 53-bit real on [0,1)&lt;br /&gt;};&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(204, 0, 0); font-weight: bold;"&gt;MersenneTwister.cpp&lt;/span&gt;&lt;br /&gt;&lt;pre name="code" class="cpp"&gt;&lt;br /&gt;#include "MersenneTwister.hpp"&lt;br /&gt;&lt;br /&gt;/*&lt;br /&gt;* Initialise mt[N] with a seed&lt;br /&gt;*/&lt;br /&gt;void MersenneTwister::init(unsigned long s)&lt;br /&gt;{&lt;br /&gt;mt[0] = s &amp;amp; 0xffffffffUL;&lt;br /&gt;  for (mti=1; mti&amp;lt;N; mti++) {&lt;br /&gt;      mt[mti] =&lt;br /&gt;    (1812433253UL * (mt[mti-1] ^ (mt[mti-1] &amp;gt;&amp;gt; 30)) + mti);&lt;br /&gt;      /* See Knuth TAOCP Vol2. 3rd Ed. P.106 for multiplier.&lt;br /&gt;       * In the previous versions, MSBs of the seed affect&lt;br /&gt;       * only MSBs of the array mt[].                   &lt;br /&gt;       * 2002/01/09 modified by Makoto Matsumoto&lt;br /&gt;  */&lt;br /&gt;      mt[mti] &amp;amp;= 0xffffffffUL;&lt;br /&gt;      /* for &amp;gt;32 bit machines */&lt;br /&gt;  }&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;/*&lt;br /&gt;* Initialise by an array with length given by key_length&lt;br /&gt;*/&lt;br /&gt;void MersenneTwister::initArray(unsigned long init_key[], int key_length)&lt;br /&gt;{&lt;br /&gt;int i, j, k;&lt;br /&gt;  init(19650218UL);&lt;br /&gt;  i=1; j=0;&lt;br /&gt;  k = (N&amp;gt;key_length ? N : key_length);&lt;br /&gt;  for (; k; k--) {&lt;br /&gt;      mt[i] = (mt[i] ^ ((mt[i-1] ^ (mt[i-1] &amp;gt;&amp;gt; 30)) * 1664525UL))&lt;br /&gt;        + init_key[j] + j; /* non linear */&lt;br /&gt;      mt[i] &amp;amp;= 0xffffffffUL; /* for WORDSIZE &amp;gt; 32 machines */&lt;br /&gt;      i++; j++;&lt;br /&gt;      if (i&amp;gt;=N) { mt[0] = mt[N-1]; i=1; }&lt;br /&gt;      if (j&amp;gt;=key_length) j=0;&lt;br /&gt;  }&lt;br /&gt;  for (k=N-1; k; k--) {&lt;br /&gt;      mt[i] = (mt[i] ^ ((mt[i-1] ^ (mt[i-1] &amp;gt;&amp;gt; 30)) * 1566083941UL))&lt;br /&gt;        - i; /* non linear */&lt;br /&gt;      mt[i] &amp;amp;= 0xffffffffUL; /* for WORDSIZE &amp;gt; 32 machines */&lt;br /&gt;      i++;&lt;br /&gt;      if (i&amp;gt;=N) { mt[0] = mt[N-1]; i=1; }&lt;br /&gt;  }&lt;br /&gt;&lt;br /&gt;  mt[0] = 0x80000000UL; /* MSB is 1; assuring non-zero initial array */&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;/*&lt;br /&gt;* Generate random number on [0,0xffffffff]&lt;br /&gt;*/&lt;br /&gt;unsigned long MersenneTwister::genInt32()&lt;br /&gt;{&lt;br /&gt;unsigned long y;&lt;br /&gt;  static unsigned long mag01[2]={0x0UL, MATRIX_A};&lt;br /&gt;  /* mag01[x] = x * MATRIX_A  for x=0,1 */&lt;br /&gt;&lt;br /&gt;  if (mti &amp;gt;= N) { /* generate N words at one time */&lt;br /&gt;      int kk;&lt;br /&gt;&lt;br /&gt;      if (mti == N+1)   /* if init() has not been called, */&lt;br /&gt;          init(5489UL); /* a default initial seed is used */&lt;br /&gt;&lt;br /&gt;      for (kk=0;kk&amp;lt;N-M;kk++) {&lt;br /&gt;          y = (mt[kk]&amp;amp;UPPER_MASK)|(mt[kk+1]&amp;amp;LOWER_MASK);&lt;br /&gt;          mt[kk] = mt[kk+M] ^ (y &amp;gt;&amp;gt; 1) ^ mag01[y &amp;amp; 0x1UL];&lt;br /&gt;      }&lt;br /&gt;      for (;kk&amp;lt;N-1;kk++) {&lt;br /&gt;          y = (mt[kk]&amp;amp;UPPER_MASK)|(mt[kk+1]&amp;amp;LOWER_MASK);&lt;br /&gt;          mt[kk] = mt[kk+(M-N)] ^ (y &amp;gt;&amp;gt; 1) ^ mag01[y &amp;amp; 0x1UL];&lt;br /&gt;      }&lt;br /&gt;      y = (mt[N-1]&amp;amp;UPPER_MASK)|(mt[0]&amp;amp;LOWER_MASK);&lt;br /&gt;      mt[N-1] = mt[M-1] ^ (y &amp;gt;&amp;gt; 1) ^ mag01[y &amp;amp; 0x1UL];&lt;br /&gt;&lt;br /&gt;      mti = 0;&lt;br /&gt;  }&lt;br /&gt;&lt;br /&gt;  y = mt[mti++];&lt;br /&gt;&lt;br /&gt;  /* Tempering */&lt;br /&gt;  y ^= (y &amp;gt;&amp;gt; 11);&lt;br /&gt;  y ^= (y &amp;lt;&amp;lt; 7) &amp;amp; 0x9d2c5680UL;&lt;br /&gt;  y ^= (y &amp;lt;&amp;lt; 15) &amp;amp; 0xefc60000UL;&lt;br /&gt;  y ^= (y &amp;gt;&amp;gt; 18);&lt;br /&gt;&lt;br /&gt;  return y;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;/*&lt;br /&gt;* Generate a random number on [0,0x7fffffff]&lt;br /&gt;*/&lt;br /&gt;long MersenneTwister::genInt31()&lt;br /&gt;{&lt;br /&gt;return (long)(genInt32() &amp;gt;&amp;gt; 1);&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;/*&lt;br /&gt;* Generate a random number on [0,1]-real&lt;br /&gt;*/&lt;br /&gt;double MersenneTwister::genRealClosed()&lt;br /&gt;{&lt;br /&gt;return genInt32() * (1.0 / 4294967295.0);&lt;br /&gt;  /* divided by 2^32 - 1 */&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;/*&lt;br /&gt;* Generate a random number on [0,1)-real&lt;br /&gt;*/&lt;br /&gt;double MersenneTwister::genReal()&lt;br /&gt;{&lt;br /&gt;return genInt32() * (1.0 / 4294967296.0);&lt;br /&gt;  /* divided by 2^32 */&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;/*&lt;br /&gt;* Generate a random number on (0,1)-real&lt;br /&gt;*/&lt;br /&gt;double MersenneTwister::genRealOpen()&lt;br /&gt;{&lt;br /&gt;return (((double)genInt32()) + 0.5) * (1.0 / 4294967296.0);&lt;br /&gt;  /* divided by 2^32 */&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;/*&lt;br /&gt;* Generate a random number on [0,1)-real with 53-bit resolution&lt;br /&gt;*/&lt;br /&gt;double MersenneTwister::genReal53()&lt;br /&gt;{&lt;br /&gt;unsigned long a = genInt32() &amp;gt;&amp;gt; 5;&lt;br /&gt;unsigned long b = genInt32() &amp;gt;&amp;gt; 6;&lt;br /&gt;  return(a * 67108864.0 + b) * (1.0 / 9007199254740992.0);&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4470666517647633822-3304006069369295513?l=physical-thought.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://physical-thought.blogspot.com/feeds/3304006069369295513/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4470666517647633822&amp;postID=3304006069369295513' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4470666517647633822/posts/default/3304006069369295513'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4470666517647633822/posts/default/3304006069369295513'/><link rel='alternate' type='text/html' href='http://physical-thought.blogspot.com/2008/08/mersenne-twister.html' title='Mersenne Twister'/><author><name>Andrew J. Bennieston</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://bp2.blogger.com/_zi39n2uYgqg/R3f879w2IHI/AAAAAAAAAAY/IsPK0LU5Duc/S220/avatar.png'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://4.bp.blogspot.com/_zi39n2uYgqg/SKWij9yJTtI/AAAAAAAAALU/EWdB85NQC0U/s72-c/mt-graph.png' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4470666517647633822.post-7409882495520978166</id><published>2008-08-14T17:47:00.004+01:00</published><updated>2008-08-14T18:23:29.105+01:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='double-beta'/><category scheme='http://www.blogger.com/atom/ns#' term='c++'/><category scheme='http://www.blogger.com/atom/ns#' term='event generator'/><category scheme='http://www.blogger.com/atom/ns#' term='namespaces'/><category scheme='http://www.blogger.com/atom/ns#' term='particle physics'/><category scheme='http://www.blogger.com/atom/ns#' term='monte carlo'/><category scheme='http://www.blogger.com/atom/ns#' term='warwick'/><category scheme='http://www.blogger.com/atom/ns#' term='mathematics'/><category scheme='http://www.blogger.com/atom/ns#' term='physics'/><category scheme='http://www.blogger.com/atom/ns#' term='pebble'/><title type='text'>Thoughts on a Pebble... and the 100th post!</title><content type='html'>This is my 100th blog post here at Physical Thought. To mark the occasion I've decided to write what promises to be a fairly lengthy textual post, in contrast to the large number of diagrams, images and photographs which have made their way onto the blog recently.&lt;br /&gt;&lt;br /&gt;I've been thinking about software development recently, particularly in the field of high energy physics (hep). In the summer of 2007, I developed an event generator for double beta-decay events with colleague Sam Smith. It was written in C++ and the work was carried out as part of a summer research project with the particle physics group at Warwick.&lt;br /&gt;&lt;br /&gt;Now, a year on, I've been thinking about that code and how it could be improved, retrospectively. With these thoughts in mind, I intend to write not only this blog post, but also to look into improving or rewriting the event generator, which we called Pebble.&lt;br /&gt;&lt;br /&gt;I'm not saying that I'll definitely rewrite it, or that if I do I will come up with anything better than the original, but for the time being, here are some thoughts on the architecture of "Pebble v1", including what worked and what didn't.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;The 'Mode' Functions&lt;/span&gt;&lt;br /&gt;At the core of Pebble, probability distribution functions (PDFs) were sampled using Monte Carlo techniques. We implemented one- and two-dimensional PDFs as realisations of abstract interfaces for each dimensionality, and passed them through various mathematical algorithms to integrate (for normalisation) and find the minima or maxima.&lt;br /&gt;&lt;br /&gt;On the whole, this approach worked well and provided the flexibility to support nine different decay modes with a single event generator function. The class hierarchy allowed us to separate mode selection from event generation, and the event generation code didn't have to care about the exact PDF being used.&lt;br /&gt;&lt;br /&gt;There were also some problems (one or two of which were unavoidable). Notably, delta functions and straight lines caused problems which we had to build in workarounds for. Better core support for discontinuities or other weirdness in a mathematical function could have helped out here. Another issue was that, for the two-dimensional function, one could not normalise and find maxima until the first parameter had been fixed, which means that normalisation and maximum finding had to be performed once-per-event rather than once-per-run c.f. the one-dimensional PDF. This is unavoidable; you need to fix the first value before you can evaluate the PDF with a randomly chosen second parameter, but the overheads in initialisation, normalisation (i.e. integration) and finding maxima made this a bottleneck in Pebble v1.&lt;br /&gt;&lt;br /&gt;The bottleneck mentioned above is perhaps the single biggest point of failure of Pebble v1, and any upated version ought to consider very carefully the instantiation overhead of the classes used in event generation, moving as much work as possible to an initialisation step which occurs just once, before event generation begins.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Mathematical Facilities&lt;/span&gt;&lt;br /&gt;The basic mathematical facilities provided by Pebble v1 include integration of one- and two-dimensional functions, minimisation and normalisation. The original plan was to allow these to be templated and chained together such that one might be able to obtain a (pointer to a) function representing the normalised version of a raw PDF. This didn't work out so well in the original design, but the mathematical facilities themselves worked just fine, and carried relatively low overhead! Since normalisation of a 2D PDF has to happen for every event, the integration function really could have done with some more optimisation.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Input and Output&lt;/span&gt;&lt;br /&gt;Program input was through command-line parameters while output was to tab-separated text files. Originally, we planned to create an Event object for each generated event, containing a Particle object for each particle involved in the event. In turn, the Particle objects would contain information about their energy and momentum (as a four-vector), particle type, etc. The creation of so many objects proved to be a huge time-sink and we eventually resorted to a flat data format, but the interface had already been geared up for this highly OO approach and it could have been handled better.&lt;br /&gt;&lt;br /&gt;The PDFs form part of the C++ code and are compiled in directly. This means that, in Pebble v1, to add a PDF or modify its behaviour, the code must be completely recompiled. Unfortunately, it is hard to get around the need to compile the PDFs if one wishes to retain the event generation speed, but a library interface for adding additional PDFs as shared objects could have made things easier here without losing much (or any!) speed.&lt;br /&gt;&lt;br /&gt;As for input, the eventual plan was to separate the interface and the event generation sufficiently to create an event generator library which could be tied to a large number of interfaces. This would have been possible, but we ran out of time. A better approach would have been to develop the library from the outset, adding interfaces as standalone programs which link (dynamically, ideally) to the library. The same point stands for output, for example providing a graphical interface or an interface to the CERN GEANT4 software for particle tracking, which was planned but time did not permit.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Thoughts on a possible Pebble v2&lt;/span&gt;&lt;br /&gt;These are random bits and pieces that are currently swimming through my head, so I'll present them as a bulleted list rather than in full paragraph form.&lt;br /&gt;&lt;ul&gt;&lt;li&gt;Separate functionality from interface, &lt;span style="font-style: italic;"&gt;completely&lt;/span&gt;. This should be done right from the beginning, and everything should be replacable without losing any speed or power. The key here is the ability to not only switch interface, but to switch out the PDFs, the integrator or the random number generator (for example) to obtain completely different behaviour from the same core codebase.&lt;/li&gt;&lt;li&gt;Don't overdo the object orientation; data is best left as data, not as Particle objects&lt;/li&gt;&lt;li&gt;Provide Particle objects "just in case"; some interfaces may require them. Ideally make these compatible with known software (e.g. GEANT4) so that there is minimal interface overhead in translating between disparate object formats.&lt;/li&gt;&lt;li&gt;Make extensive use of modern C++ features including namespaces, templates and the standard library containers / algorithms. These not only help the core programmer but also provide a standard set of tools for anyone working with the library.&lt;/li&gt;&lt;li&gt;Provide helpers for repetetive or complicated tasks, similar to the ModeMaker program in Pebble v1, which generated Pebble Mode Functions (PDFs) from a mathematical expression suitable for use in C++. Perhaps a Python (or similar) program to automate the generation of C++ functions from a mathematical expression, or even an interface with a Python interpreter allowing mode functions to be compiled into a shared library and dynamically linked to the currently running Pebble v2 backend. This would be slower (on first run) than the built-in mode functions, but would allow a fully interactive form of event generation.&lt;/li&gt;&lt;li&gt;Emphasise computational speed throughout. Spitting out a lot of events in a short time is a good thing!&lt;/li&gt;&lt;li&gt;Keep track of every last byte of memory. Valgrind is an excellent tool and the feeling you get when it tells you your program isn't leaking a single byte of memory is good too!&lt;/li&gt;&lt;/ul&gt;That is about all I can think of for now. I may play about with a bit of code over the next few days and see if I can come up with a basic framework on which to build something like Pebble v2... maybe.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4470666517647633822-7409882495520978166?l=physical-thought.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://physical-thought.blogspot.com/feeds/7409882495520978166/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4470666517647633822&amp;postID=7409882495520978166' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4470666517647633822/posts/default/7409882495520978166'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4470666517647633822/posts/default/7409882495520978166'/><link rel='alternate' type='text/html' href='http://physical-thought.blogspot.com/2008/08/thoughts-on-pebble-and-100th-post.html' title='Thoughts on a Pebble... and the 100th post!'/><author><name>Andrew J. Bennieston</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://bp2.blogger.com/_zi39n2uYgqg/R3f879w2IHI/AAAAAAAAAAY/IsPK0LU5Duc/S220/avatar.png'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4470666517647633822.post-2169253428758724741</id><published>2008-08-13T21:17:00.004+01:00</published><updated>2008-08-13T21:32:31.557+01:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='feynman'/><category scheme='http://www.blogger.com/atom/ns#' term='particle physics'/><category scheme='http://www.blogger.com/atom/ns#' term='physics'/><title type='text'>J/Psi Decay Again</title><content type='html'>So I haven't posted in a while... that is because I've been away&lt;span style="font-style: italic;"&gt; sans computer&lt;/span&gt; (well, &lt;span style="font-style: italic;"&gt;sans internet&lt;/span&gt;, anyway) for the past three weeks!&lt;br /&gt;&lt;br /&gt;In the meantime, I've been reading &lt;span style="font-style: italic;"&gt;Introduction to Elementary Particles (Griffiths)&lt;/span&gt; and I've found a Feynman diagram which really encapsulates the name of the J/Psi (well, the Psi part anyway) particle (charm-anticharm). These diagrams (although looking slightly like they should belong in an anatomy book...) are by far the nicest presentation of the decay of this particle that I've seen, made possible simply by using curved lines rather than straight ones!&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(204, 0, 0);"&gt;NOTE: In order for these diagrams to look like the letter Psi, I had to adopt the convention used in the Griffiths book, which is for time to progress upwards. This is in contrast to my usual (and preferred) format for Feynman diagrams, in which time runs from left to right!&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;The top diagram is the OZI-suppressed decay of a ground-state J/Psi to three pions. The bottom one is the decay of an excited state particle to a D+ and a D-. Admittedly my drawing skills are somewhat lacking, but I didn't want to scan / photograph directly from the book, so this'll have to do!&lt;br /&gt;&lt;br /&gt;&lt;div style="text-align: center;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_zi39n2uYgqg/SKNDM9jG-_I/AAAAAAAAALM/qYw4YOLyGXw/s1600-h/J-Psi.jpg"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer;" src="http://3.bp.blogspot.com/_zi39n2uYgqg/SKNDM9jG-_I/AAAAAAAAALM/qYw4YOLyGXw/s400/J-Psi.jpg" alt="" id="BLOGGER_PHOTO_ID_5234101081893960690" border="0" /&gt;&lt;/a&gt;(Click on the image for a larger version)&lt;br /&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4470666517647633822-2169253428758724741?l=physical-thought.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://physical-thought.blogspot.com/feeds/2169253428758724741/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4470666517647633822&amp;postID=2169253428758724741' title='6 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4470666517647633822/posts/default/2169253428758724741'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4470666517647633822/posts/default/2169253428758724741'/><link rel='alternate' type='text/html' href='http://physical-thought.blogspot.com/2008/08/jpsi-decay-again.html' title='J/Psi Decay Again'/><author><name>Andrew J. Bennieston</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://bp2.blogger.com/_zi39n2uYgqg/R3f879w2IHI/AAAAAAAAAAY/IsPK0LU5Duc/S220/avatar.png'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://3.bp.blogspot.com/_zi39n2uYgqg/SKNDM9jG-_I/AAAAAAAAALM/qYw4YOLyGXw/s72-c/J-Psi.jpg' height='72' width='72'/><thr:total>6</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4470666517647633822.post-1845122782219750564</id><published>2008-07-21T17:47:00.003+01:00</published><updated>2008-07-21T18:02:24.804+01:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='latex'/><category scheme='http://www.blogger.com/atom/ns#' term='feynman'/><category scheme='http://www.blogger.com/atom/ns#' term='particle physics'/><category scheme='http://www.blogger.com/atom/ns#' term='physics'/><title type='text'>Some more complicated Feynman diagrams</title><content type='html'>I decided to test FeynMF with a few more complicated diagrams (not necessarily because of the process involved, but because they're difficult to lay out nicely).&lt;br /&gt;&lt;br /&gt;The first diagram is the strong decay of an excited state of the J/Psi meson. It has to be an excited state otherwise the c/anti-c doesn't have enough energy (mass) to produce the extra d/anti-d needed for the final state:&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://bp0.blogger.com/_zi39n2uYgqg/SIS--16DVLI/AAAAAAAAAK0/d1grdARvhQY/s1600-h/psi-prime-decay.PNG"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer;" src="http://bp0.blogger.com/_zi39n2uYgqg/SIS--16DVLI/AAAAAAAAAK0/d1grdARvhQY/s320/psi-prime-decay.PNG" alt="" id="BLOGGER_PHOTO_ID_5225511454488351922" border="0" /&gt;&lt;/a&gt;This diagram turned out to be easy enough for FeynMF to draw. The next one, however, is the decay of the ground-state of the J/Psi. This has to go via c/anti-c annihilation then production of more stuff from the resulting gluons. The ground-state of the J/Psi has a longer lifetime than typical strongly-decaying particles because this decay mode is OZI suppressed; the QCD coupling of gluons to fermions is a function of the momentum transfer. At low momentum transfer (equivalently, large separation) the coupling is large, but at high momentum transfer (or small separations) the coupling is very small. This leads to the asymptotic freedom that quarks enjoy within nucleons (where they are essentially free particles) but also leads to the relatively small amplitude for the following Feynman diagram, where all the mass energy of a c/anti-c pair is transferred through gluons to the final state. This is a high momentum-transfer process, so the QCD coupling is small, and we have three gluons, so it's smaller still!&lt;br /&gt;&lt;br /&gt;Qualitatively, the OZI rule states that Feynman diagrams which can be cut in half between incoming and outgoing particles by cutting only internal gluon lines, and without cutting quark lines, are suppressed with respect to those which cannot.&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://bp3.blogger.com/_zi39n2uYgqg/SIS--7LKb_I/AAAAAAAAAK8/Zu5kRap-gDY/s1600-h/psi-decay.PNG"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer;" src="http://bp3.blogger.com/_zi39n2uYgqg/SIS--7LKb_I/AAAAAAAAAK8/Zu5kRap-gDY/s320/psi-decay.PNG" alt="" id="BLOGGER_PHOTO_ID_5225511455902298098" border="0" /&gt;&lt;/a&gt;FeynMF had trouble with this diagram. Well, that isn't true - it drew it just fine, but it didn't look very good. I had to change various tensions of the particle lines to get it to look like this, and it still isn't great. I am sure I could play some more and get it looking better, but since I wanted to test FeyMF's layout capabilities here, I didn't want to do too much over and above the "default" rendering it provides.&lt;br /&gt;&lt;br /&gt;Finally, our old friend: Beta Decay! This is a simple process, down quark changing to an up quark, emitting a W- which turns into an electron and a neutrino. The difficulty arises in putting in the spectator quark lines for the other two nucleons present.&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://bp1.blogger.com/_zi39n2uYgqg/SIS--2NE7JI/AAAAAAAAALE/4TTBrp106L0/s1600-h/beta-decay.PNG"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer;" src="http://bp1.blogger.com/_zi39n2uYgqg/SIS--2NE7JI/AAAAAAAAALE/4TTBrp106L0/s320/beta-decay.PNG" alt="" id="BLOGGER_PHOTO_ID_5225511454568148114" border="0" /&gt;&lt;/a&gt;To do this I had to resort to the FeynMF "Immediate" mode, after freezing the d -&gt; e + nu part of the diagram. With a bit more manipulation I could probably make this look much better!&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4470666517647633822-1845122782219750564?l=physical-thought.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://physical-thought.blogspot.com/feeds/1845122782219750564/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4470666517647633822&amp;postID=1845122782219750564' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4470666517647633822/posts/default/1845122782219750564'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4470666517647633822/posts/default/1845122782219750564'/><link rel='alternate' type='text/html' href='http://physical-thought.blogspot.com/2008/07/some-more-complicated-feynman-diagrams.html' title='Some more complicated Feynman diagrams'/><author><name>Andrew J. Bennieston</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://bp2.blogger.com/_zi39n2uYgqg/R3f879w2IHI/AAAAAAAAAAY/IsPK0LU5Duc/S220/avatar.png'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://bp0.blogger.com/_zi39n2uYgqg/SIS--16DVLI/AAAAAAAAAK0/d1grdARvhQY/s72-c/psi-prime-decay.PNG' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4470666517647633822.post-2205831380199276654</id><published>2008-07-21T15:04:00.010+01:00</published><updated>2008-07-21T15:25:21.948+01:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='latex'/><category scheme='http://www.blogger.com/atom/ns#' term='feynman'/><category scheme='http://www.blogger.com/atom/ns#' term='particle physics'/><category scheme='http://www.blogger.com/atom/ns#' term='physics'/><title type='text'>Compton Scattering Feynman Diagrams</title><content type='html'>I've started working through the problems in Griffiths' &lt;span style="font-style: italic;"&gt;Introduction to Elementary Particles&lt;/span&gt;. One such problem is to draw the 17 fourth-order (that is, 4-vertices) Feynman diagrams for &lt;a href="http://en.wikipedia.org/wiki/Compton_Scattering"&gt;Compton Scattering&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;The basic (2-vertex) diagram is shown below. An electron absorbs a photon and re-emits it at a later time.&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(204, 0, 0);"&gt;NOTE: In all of my Feynman diagrams, time runs from left to right. The vertical axis does &lt;span style="font-style: italic;"&gt;not&lt;/span&gt;, however, correspond to "space". Time runs left to right, nothing else matters.&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://bp2.blogger.com/_zi39n2uYgqg/SISYFhOGf9I/AAAAAAAAAIk/UQERmFMYT34/s1600-h/compton.png"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer;" src="http://bp2.blogger.com/_zi39n2uYgqg/SISYFhOGf9I/AAAAAAAAAIk/UQERmFMYT34/s320/compton.png" alt="" id="BLOGGER_PHOTO_ID_5225468688240902098" border="0" /&gt;&lt;/a&gt;I set about drawing all of the fourth-order diagrams, and eventually decided that I'd use them as an opportunity to learn FeynMF properly. FeynMF is a package for drawing Feynman diagrams in LaTeX (as the above diagram was, and several that I've posted previously). Until now, I'd been copying snippets from various examples to produce the simple diagrams I needed.&lt;br /&gt;&lt;br /&gt;So I set about drawing all seventeen diagrams using FeynMF. And now I'm going to post them here, explaining what is special about each one (or rather, each related set). If you can see any reason that one of these diagrams isn't allowed, let me know. As far as I'm aware they're all valid, but I could be wrong. Seventeen is a lot of diagrams to keep track of, and although I don't think I've done the same thing twice, it is entirely possible!&lt;br /&gt;&lt;br /&gt;The first set are related by the self-interaction between charged particles; QED loops. Here, each charged fermion can emit a photon and re-absorb it at a later time:&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://bp3.blogger.com/_zi39n2uYgqg/SISZNt13j3I/AAAAAAAAAIs/sIM9TbD2h80/s1600-h/compton01.png"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer;" src="http://bp3.blogger.com/_zi39n2uYgqg/SISZNt13j3I/AAAAAAAAAIs/sIM9TbD2h80/s320/compton01.png" alt="" id="BLOGGER_PHOTO_ID_5225469928579501938" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://bp3.blogger.com/_zi39n2uYgqg/SISZNkR3hCI/AAAAAAAAAI0/9J4Ecg7ja7w/s1600-h/compton07.png"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer;" src="http://bp3.blogger.com/_zi39n2uYgqg/SISZNkR3hCI/AAAAAAAAAI0/9J4Ecg7ja7w/s320/compton07.png" alt="" id="BLOGGER_PHOTO_ID_5225469926012584994" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://bp2.blogger.com/_zi39n2uYgqg/SISZN_i16FI/AAAAAAAAAI8/61uljbP7Mm0/s1600-h/compton08.png"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer;" src="http://bp2.blogger.com/_zi39n2uYgqg/SISZN_i16FI/AAAAAAAAAI8/61uljbP7Mm0/s320/compton08.png" alt="" id="BLOGGER_PHOTO_ID_5225469933331540050" border="0" /&gt;&lt;/a&gt;The next set involve interactions between the incoming or outgoing fermions and the propagator fermion:&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://bp1.blogger.com/_zi39n2uYgqg/SISZkuj1qkI/AAAAAAAAAJE/MVOKKvQBPcE/s1600-h/compton02.png"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer;" src="http://bp1.blogger.com/_zi39n2uYgqg/SISZkuj1qkI/AAAAAAAAAJE/MVOKKvQBPcE/s320/compton02.png" alt="" id="BLOGGER_PHOTO_ID_5225470323909306946" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://bp3.blogger.com/_zi39n2uYgqg/SISZkwqq5KI/AAAAAAAAAJM/5kzeCzjPmnM/s1600-h/compton03.png"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer;" src="http://bp3.blogger.com/_zi39n2uYgqg/SISZkwqq5KI/AAAAAAAAAJM/5kzeCzjPmnM/s320/compton03.png" alt="" id="BLOGGER_PHOTO_ID_5225470324474832034" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;And, since we can equivalently have Z0 exchange instead of photon exchange, the previous five diagrams with the photon replaced by a Z0:&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://bp3.blogger.com/_zi39n2uYgqg/SISZ_smLFBI/AAAAAAAAAJU/N0EzOT5CvnU/s1600-h/compton04.png"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer;" src="http://bp3.blogger.com/_zi39n2uYgqg/SISZ_smLFBI/AAAAAAAAAJU/N0EzOT5CvnU/s320/compton04.png" alt="" id="BLOGGER_PHOTO_ID_5225470787238695954" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://bp1.blogger.com/_zi39n2uYgqg/SISZ_tDtVII/AAAAAAAAAJc/eQEvhSPmXLM/s1600-h/compton09.png"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer;" src="http://bp1.blogger.com/_zi39n2uYgqg/SISZ_tDtVII/AAAAAAAAAJc/eQEvhSPmXLM/s320/compton09.png" alt="" id="BLOGGER_PHOTO_ID_5225470787362575490" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://bp3.blogger.com/_zi39n2uYgqg/SISZ_irfo-I/AAAAAAAAAJk/KAvYA-JpzyQ/s1600-h/compton10.png"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer;" src="http://bp3.blogger.com/_zi39n2uYgqg/SISZ_irfo-I/AAAAAAAAAJk/KAvYA-JpzyQ/s320/compton10.png" alt="" id="BLOGGER_PHOTO_ID_5225470784576660450" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://bp3.blogger.com/_zi39n2uYgqg/SISZ_4t6utI/AAAAAAAAAJs/X44DL3cGhZI/s1600-h/compton05.png"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer;" src="http://bp3.blogger.com/_zi39n2uYgqg/SISZ_4t6utI/AAAAAAAAAJs/X44DL3cGhZI/s320/compton05.png" alt="" id="BLOGGER_PHOTO_ID_5225470790492404434" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://bp0.blogger.com/_zi39n2uYgqg/SISZ_0uLGVI/AAAAAAAAAJ0/9noPEShUTDc/s1600-h/compton06.png"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer;" src="http://bp0.blogger.com/_zi39n2uYgqg/SISZ_0uLGVI/AAAAAAAAAJ0/9noPEShUTDc/s320/compton06.png" alt="" id="BLOGGER_PHOTO_ID_5225470789419735378" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;Next,we must consider pair production from the incoming or outgoing photons. We can construct production/annihilation loops for fermions (either electron/positron, or quark/antiquark):&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://bp3.blogger.com/_zi39n2uYgqg/SISaZNptnSI/AAAAAAAAAJ8/4qgGlJ98zcI/s1600-h/compton11.png"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer;" src="http://bp3.blogger.com/_zi39n2uYgqg/SISaZNptnSI/AAAAAAAAAJ8/4qgGlJ98zcI/s320/compton11.png" alt="" id="BLOGGER_PHOTO_ID_5225471225608641826" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://bp0.blogger.com/_zi39n2uYgqg/SISaZAFe9mI/AAAAAAAAAKE/_4scGSjPCwk/s1600-h/compton12.png"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer;" src="http://bp0.blogger.com/_zi39n2uYgqg/SISaZAFe9mI/AAAAAAAAAKE/_4scGSjPCwk/s320/compton12.png" alt="" id="BLOGGER_PHOTO_ID_5225471221967025762" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;We also have to consider the fact that the W bosons are charged, so they can couple to the photon also. This allows us to have a boson loop in the pair production/annihilation:&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://bp1.blogger.com/_zi39n2uYgqg/SISapKwLEzI/AAAAAAAAAKM/6aBjWcr8V2M/s1600-h/compton13.png"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer;" src="http://bp1.blogger.com/_zi39n2uYgqg/SISapKwLEzI/AAAAAAAAAKM/6aBjWcr8V2M/s320/compton13.png" alt="" id="BLOGGER_PHOTO_ID_5225471499708338994" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://bp0.blogger.com/_zi39n2uYgqg/SISapGiWxAI/AAAAAAAAAKU/mutbeAS2ZcY/s1600-h/compton14.png"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer;" src="http://bp0.blogger.com/_zi39n2uYgqg/SISapGiWxAI/AAAAAAAAAKU/mutbeAS2ZcY/s320/compton14.png" alt="" id="BLOGGER_PHOTO_ID_5225471498576643074" border="0" /&gt;&lt;/a&gt;And finally, we need to consider coupling between the initial and final state particles. The initial and final electrons can interact by exchange of a photon or a Z0, and the photons can interact by exchange of either a W+ or a W-:&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://bp0.blogger.com/_zi39n2uYgqg/SISbJRCBZcI/AAAAAAAAAKc/ZKcSGAINmyg/s1600-h/compton15.png"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer;" src="http://bp0.blogger.com/_zi39n2uYgqg/SISbJRCBZcI/AAAAAAAAAKc/ZKcSGAINmyg/s320/compton15.png" alt="" id="BLOGGER_PHOTO_ID_5225472051149628866" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://bp2.blogger.com/_zi39n2uYgqg/SISbJiQGWFI/AAAAAAAAAKk/Y7jxcbMbLf0/s1600-h/compton16.png"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer;" src="http://bp2.blogger.com/_zi39n2uYgqg/SISbJiQGWFI/AAAAAAAAAKk/Y7jxcbMbLf0/s320/compton16.png" alt="" id="BLOGGER_PHOTO_ID_5225472055772076114" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://bp0.blogger.com/_zi39n2uYgqg/SISbJ_VvEpI/AAAAAAAAAKs/idELbMr6sjw/s1600-h/compton17.png"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer;" src="http://bp0.blogger.com/_zi39n2uYgqg/SISbJ_VvEpI/AAAAAAAAAKs/idELbMr6sjw/s320/compton17.png" alt="" id="BLOGGER_PHOTO_ID_5225472063580344978" border="0" /&gt;&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4470666517647633822-2205831380199276654?l=physical-thought.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://physical-thought.blogspot.com/feeds/2205831380199276654/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4470666517647633822&amp;postID=2205831380199276654' title='14 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4470666517647633822/posts/default/2205831380199276654'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4470666517647633822/posts/default/2205831380199276654'/><link rel='alternate' type='text/html' href='http://physical-thought.blogspot.com/2008/07/compton-scattering-feynman-diagrams.html' title='Compton Scattering Feynman Diagrams'/><author><name>Andrew J. Bennieston</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://bp2.blogger.com/_zi39n2uYgqg/R3f879w2IHI/AAAAAAAAAAY/IsPK0LU5Duc/S220/avatar.png'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://bp2.blogger.com/_zi39n2uYgqg/SISYFhOGf9I/AAAAAAAAAIk/UQERmFMYT34/s72-c/compton.png' height='72' width='72'/><thr:total>14</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4470666517647633822.post-5314169996103320356</id><published>2008-07-17T20:33:00.003+01:00</published><updated>2008-07-17T20:40:21.718+01:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='photography'/><category scheme='http://www.blogger.com/atom/ns#' term='panorama'/><category scheme='http://www.blogger.com/atom/ns#' term='autostitch'/><title type='text'>Autostitch</title><content type='html'>After reading about &lt;a href="http://www.cs.ubc.ca/%7Embrown/autostitch/autostitch.html"&gt;Autostitch&lt;/a&gt; on &lt;a href="http://mathendacil.free.fr/blog/"&gt;Pierre's blog&lt;/a&gt;, I decided to try it. I took around 27 photos of one of my bookshelves and let Autostitch loose on them. The result (after cropping the rough edges where it stitched the end photos together): pretty damn impressive.&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://bp1.blogger.com/_zi39n2uYgqg/SH-fttTKmKI/AAAAAAAAAIc/Cwsy5fNzFmc/s1600-h/pano.jpg"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer;" src="http://bp1.blogger.com/_zi39n2uYgqg/SH-fttTKmKI/AAAAAAAAAIc/Cwsy5fNzFmc/s400/pano.jpg" alt="" id="BLOGGER_PHOTO_ID_5224069700375976098" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;I can't wait to try it on some landscapes!&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4470666517647633822-5314169996103320356?l=physical-thought.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://physical-thought.blogspot.com/feeds/5314169996103320356/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4470666517647633822&amp;postID=5314169996103320356' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4470666517647633822/posts/default/5314169996103320356'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4470666517647633822/posts/default/5314169996103320356'/><link rel='alternate' type='text/html' href='http://physical-thought.blogspot.com/2008/07/autostitch.html' title='Autostitch'/><author><name>Andrew J. Bennieston</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://bp2.blogger.com/_zi39n2uYgqg/R3f879w2IHI/AAAAAAAAAAY/IsPK0LU5Duc/S220/avatar.png'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://bp1.blogger.com/_zi39n2uYgqg/SH-fttTKmKI/AAAAAAAAAIc/Cwsy5fNzFmc/s72-c/pano.jpg' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4470666517647633822.post-6841902685617219757</id><published>2008-07-16T21:07:00.004+01:00</published><updated>2009-04-19T18:06:09.555+01:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='cat'/><category scheme='http://www.blogger.com/atom/ns#' term='xkcd'/><category scheme='http://www.blogger.com/atom/ns#' term='mathematica'/><category scheme='http://www.blogger.com/atom/ns#' term='fourier transform'/><title type='text'>Mathematica Notebook: Fourier Transform of a Cat</title><content type='html'>&lt;span style="font-weight: bold; font-style: italic;"&gt;UPDATE (April 19, 2009):&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;The Mathematica notebook is no longer available online. If you want it, you'll have to e-mail me and ask. It is left as an exercise for the reader to find my e-mail address.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;I was asked in a comment on the &lt;a href="http://physical-thought.blogspot.com/2008/06/fourier-transform-of-cat.html"&gt;Fourier Transform of a Cat&lt;/a&gt; post whether I was planning on uploading the Mathematica notebook. Since I can't upload it directly to Blogger, I have had to find an alternative hosting location. It's currently hosted in the physical-thought.com domain, which doesn't hold much else right now.&lt;br /&gt;&lt;br /&gt;The notebook is now available in a ZIP file at &lt;a href="http://www.physical-thought.com/files/fourier-cat.zip"&gt;http://www.physical-thought.com/files/fourier-cat.zip&lt;/a&gt; and the original post has been edited to reflect this. I stripped the output from the notebook to keep it small, so anyone who wants to use it will have to re-evaluate the cells. The original tiger.jpg is provided in the ZIP file too.&lt;br /&gt;&lt;br /&gt;I also found the following image in the Mathematica notebook; it's a combination of Fourier transforms with some image data subtracted from it, and it's a rather striking visual effect.&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://bp0.blogger.com/_zi39n2uYgqg/SH5WGJbYUAI/AAAAAAAAAIU/HjFbrr2RXSc/s1600-h/tiger.png"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer;" src="http://bp0.blogger.com/_zi39n2uYgqg/SH5WGJbYUAI/AAAAAAAAAIU/HjFbrr2RXSc/s400/tiger.png" alt="" id="BLOGGER_PHOTO_ID_5223707281406316546" border="0" /&gt;&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4470666517647633822-6841902685617219757?l=physical-thought.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://physical-thought.blogspot.com/feeds/6841902685617219757/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4470666517647633822&amp;postID=6841902685617219757' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4470666517647633822/posts/default/6841902685617219757'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4470666517647633822/posts/default/6841902685617219757'/><link rel='alternate' type='text/html' href='http://physical-thought.blogspot.com/2008/07/mathematica-notebook-fourier-transform.html' title='Mathematica Notebook: Fourier Transform of a Cat'/><author><name>Andrew J. Bennieston</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://bp2.blogger.com/_zi39n2uYgqg/R3f879w2IHI/AAAAAAAAAAY/IsPK0LU5Duc/S220/avatar.png'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://bp0.blogger.com/_zi39n2uYgqg/SH5WGJbYUAI/AAAAAAAAAIU/HjFbrr2RXSc/s72-c/tiger.png' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4470666517647633822.post-8343307271913864749</id><published>2008-07-15T22:54:00.002+01:00</published><updated>2008-07-15T23:07:34.782+01:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='particle physics'/><category scheme='http://www.blogger.com/atom/ns#' term='books'/><category scheme='http://www.blogger.com/atom/ns#' term='physics'/><title type='text'>Book: Introduction to Elementary Particles</title><content type='html'>The other book I ordered, &lt;i&gt;Introduction to Elementary Particles&lt;/i&gt; (Griffiths) arrived today. In what appears to be a consistent trend on the &lt;a href="http://www.amazon.co.uk/"&gt;Amazon&lt;/a&gt; Marketplace, the seller claimed that the book was shipped from the UK in 3 to 5 working days, yet the packaging it arrived in bore postage stamps and markings from Korea. Nevermind, at least it did arrive, and arrived before I leave for Cornwall later this month.&lt;br /&gt;&lt;br /&gt;From my preliminary flick through the pages, it looks like a very detailed, yet very readable book. The thing that impressed me most was the particle data tables printed inside the front and rear covers. Many particle physics books gloss over the exact values of quark masses, particle constituents, spin and various other important quantum numbers, forcing you to look online for a more comprehensive reference for anything beyond up and down quarks, electrons and the W or Z bosons!&lt;br /&gt;&lt;br /&gt;The tables presented here seem to be very useful, and will prove valuable when I'm sitting on a beach working through the book, without access to a computer to google the mass of the something meson, or the quark content of a [Greek letter here] baryon.&lt;br /&gt;&lt;br /&gt;Cover image below.&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://bp1.blogger.com/_zi39n2uYgqg/SH0fdNT6NuI/AAAAAAAAAIM/XnxgMKvhPhw/s1600-h/DSC00273.JPG"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer;" src="http://bp1.blogger.com/_zi39n2uYgqg/SH0fdNT6NuI/AAAAAAAAAIM/XnxgMKvhPhw/s400/DSC00273.JPG" alt="" id="BLOGGER_PHOTO_ID_5223365729469478626" border="0" /&gt;&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4470666517647633822-8343307271913864749?l=physical-thought.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://physical-thought.blogspot.com/feeds/8343307271913864749/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4470666517647633822&amp;postID=8343307271913864749' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4470666517647633822/posts/default/8343307271913864749'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4470666517647633822/posts/default/8343307271913864749'/><link rel='alternate' type='text/html' href='http://physical-thought.blogspot.com/2008/07/book-introduction-to-elementary.html' title='Book: Introduction to Elementary Particles'/><author><name>Andrew J. Bennieston</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://bp2.blogger.com/_zi39n2uYgqg/R3f879w2IHI/AAAAAAAAAAY/IsPK0LU5Duc/S220/avatar.png'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://bp1.blogger.com/_zi39n2uYgqg/SH0fdNT6NuI/AAAAAAAAAIM/XnxgMKvhPhw/s72-c/DSC00273.JPG' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4470666517647633822.post-3479193425574195445</id><published>2008-07-12T22:59:00.004+01:00</published><updated>2008-07-12T23:10:09.752+01:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='photography'/><title type='text'>Close-Up Photography</title><content type='html'>The company I ordered my step-up ring adapter from, &lt;a href="http://www.srb-griturn.com/"&gt;SRB-Griturn&lt;/a&gt;, sell adapters which I'd never even considered before. Amongst them are adapters to reverse-mount a lens to a camera body, supposedly for close-up photography. The idea is that you take your lens off the camera body, and reverse mount it to the body using the lens filter thread into one side of this adapter, and the other side fits into the camera where the lens would normally go.&lt;br /&gt;&lt;br /&gt;And they recommend you "try it first", by holding the lens in reverse up against the body and taking a photo of something.&lt;br /&gt;&lt;br /&gt;Now, here is a photo taken using my Canon 18-55mm lens mounted normally. This is about the closest focus I can get to an object:&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://bp3.blogger.com/_zi39n2uYgqg/SHkqV9x5bbI/AAAAAAAAAHQ/USyI1h2lG1A/s1600-h/IMG_3193-smaller.jpg"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer;" src="http://bp3.blogger.com/_zi39n2uYgqg/SHkqV9x5bbI/AAAAAAAAAHQ/USyI1h2lG1A/s400/IMG_3193-smaller.jpg" alt="" id="BLOGGER_PHOTO_ID_5222251799762267570" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;After taking that photo, I removed the lens, turned it round, and put it up against the hole in the camera. There are a number of obstacles to overcome here.&lt;br /&gt;&lt;br /&gt;&lt;ol&gt;&lt;li&gt;You lose autofocus functionality, meaning you have to manually focus the lens&lt;/li&gt;&lt;li&gt;The lens focussing isn't really sufficient in this configuration, so you end up moving the camera backwards and forwards anyway&lt;/li&gt;&lt;li&gt;While holding the lens against the body with one hand, and leaving the other hand poised over the shutter button, you need a third hand to change the lens focus&lt;/li&gt;&lt;li&gt;With the camera so close to the subject, light is an issue. There's not enough of it. I switched on a spot-light to get enough light in&lt;/li&gt;&lt;/ol&gt;After all that, I managed to take the photo below. This was with the lens rather close to the phone, and the results speak for themselves:&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://bp2.blogger.com/_zi39n2uYgqg/SHkrUMS_3iI/AAAAAAAAAHY/EmwGQ4U0hnA/s1600-h/IMG_3197-smaller.jpg"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer;" src="http://bp2.blogger.com/_zi39n2uYgqg/SHkrUMS_3iI/AAAAAAAAAHY/EmwGQ4U0hnA/s400/IMG_3197-smaller.jpg" alt="" id="BLOGGER_PHOTO_ID_5222252868811087394" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;There's a fairly small area which is in focus. This is to be expected, given this configuration, and could probably be improved if I had enough hands. I suspect that is what these reverse-mounting adapters are for; freeing up the hand that is holding the lens, so you can focus with it instead!&lt;br /&gt;&lt;br /&gt;Even so, I'm amazed by how close this gets you, and of the image quality resulting from it (fuzzy focus aside!)&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4470666517647633822-3479193425574195445?l=physical-thought.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://physical-thought.blogspot.com/feeds/3479193425574195445/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4470666517647633822&amp;postID=3479193425574195445' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4470666517647633822/posts/default/3479193425574195445'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4470666517647633822/posts/default/3479193425574195445'/><link rel='alternate' type='text/html' href='http://physical-thought.blogspot.com/2008/07/close-up-photography.html' title='Close-Up Photography'/><author><name>Andrew J. Bennieston</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://bp2.blogger.com/_zi39n2uYgqg/R3f879w2IHI/AAAAAAAAAAY/IsPK0LU5Duc/S220/avatar.png'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://bp3.blogger.com/_zi39n2uYgqg/SHkqV9x5bbI/AAAAAAAAAHQ/USyI1h2lG1A/s72-c/IMG_3193-smaller.jpg' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4470666517647633822.post-2323831889360278372</id><published>2008-07-12T18:42:00.002+01:00</published><updated>2008-07-12T18:48:20.013+01:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='games'/><category scheme='http://www.blogger.com/atom/ns#' term='audiosurf'/><category scheme='http://www.blogger.com/atom/ns#' term='music'/><category scheme='http://www.blogger.com/atom/ns#' term='windows'/><title type='text'>Audiosurf</title><content type='html'>As I'm sure most people already know, &lt;a href="http://www.audio-surf.com/"&gt;Audiosurf&lt;/a&gt; is a game which can be installed through &lt;a href="http://steampowered.com/v/index.php"&gt;Steam&lt;/a&gt;. It allows you to "ride your music" by generating a track from your MP3 files. The tempo and beat of the music alter the gradient of the track, and thus how fast you go, while other characteristics affect other aspects of the track generation. There are a number of different play modes, though my personal favourite is Mono Pro, in which you have to avoid grey blocks, and hit coloured blocks to get points. It's all fairly self-explanatory.&lt;br /&gt;&lt;br /&gt;Anyway, a couple of months ago (i.e. in the middle of revision) my flatmates all started playing it, and I downloaded the demo and tried it on my somewhat old computer. It didn't work so well, so I gave up. Since then, however, I reinstalled Windows, as my previous installation was quite broken (to say the least). Since then, Audiosurf seems to work passably, albeit not in full-screen mode. As a result, I shelled out the $11 or so to buy Audiosurf, so I could continue to play beyond four tracks, and it's definitely great fun!&lt;br /&gt;&lt;br /&gt;Here's a screenshot of the 'Freeride' mode, which lets you play music with the visualisation of the Audiosurf track (and even move the vehicle around) but you don't get points, and there is nothing to avoid.&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://bp2.blogger.com/_zi39n2uYgqg/SHjuTCB49jI/AAAAAAAAAHI/mPGyszuao_8/s1600-h/audiosurf.jpg"&gt;&lt;img style="display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;" src="http://bp2.blogger.com/_zi39n2uYgqg/SHjuTCB49jI/AAAAAAAAAHI/mPGyszuao_8/s400/audiosurf.jpg" border="0" alt=""id="BLOGGER_PHOTO_ID_5222185778665813554" /&gt;&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4470666517647633822-2323831889360278372?l=physical-thought.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://physical-thought.blogspot.com/feeds/2323831889360278372/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4470666517647633822&amp;postID=2323831889360278372' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4470666517647633822/posts/default/2323831889360278372'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4470666517647633822/posts/default/2323831889360278372'/><link rel='alternate' type='text/html' href='http://physical-thought.blogspot.com/2008/07/audiosurf.html' title='Audiosurf'/><author><name>Andrew J. Bennieston</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://bp2.blogger.com/_zi39n2uYgqg/R3f879w2IHI/AAAAAAAAAAY/IsPK0LU5Duc/S220/avatar.png'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://bp2.blogger.com/_zi39n2uYgqg/SHjuTCB49jI/AAAAAAAAAHI/mPGyszuao_8/s72-c/audiosurf.jpg' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4470666517647633822.post-7582117846005401699</id><published>2008-07-11T11:42:00.004+01:00</published><updated>2008-07-11T11:52:08.635+01:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='visual studio'/><category scheme='http://www.blogger.com/atom/ns#' term='firefox'/><category scheme='http://www.blogger.com/atom/ns#' term='xkcd'/><category scheme='http://www.blogger.com/atom/ns#' term='questionable content'/><category scheme='http://www.blogger.com/atom/ns#' term='cerenkov'/><title type='text'>Starting the Day</title><content type='html'>I appear to have fallen into a well-defined routine every morning. It starts with getting up, whenever that happens to be, then showering of course.&lt;br /&gt;&lt;br /&gt;After that, I get a bowl of bran flakes and cut up some fresh strawberries from the garden onto them, apply milk, and pour a glass of orange juice. I take the cereal and orange juice up to my computer, which I switched on after showering, and log in.&lt;br /&gt;&lt;br /&gt;The next ten or fifteen minutes are a careful balance of eating and the following, roughly in order:&lt;br /&gt;&lt;br /&gt;1. Start MSN&lt;br /&gt;2. Start Xchat and log into IRC&lt;br /&gt;3. Start Audacious (or Winamp, if I'm on Windows) and get some music playing&lt;br /&gt;4. Open Firefox&lt;br /&gt;5. Open the following websites:&lt;br /&gt;    - If (Monday || Wednesday || Friday) &lt;a href="http://xkcd.com/"&gt;xkcd&lt;/a&gt;&lt;br /&gt;    - &lt;a href="http://www.gmail.com/"&gt;Gmail&lt;/a&gt;&lt;br /&gt;    - &lt;a href="http://www.facebook.com/"&gt;Facebook&lt;/a&gt;&lt;br /&gt;    - &lt;a href="http://www.questionablecontent.net"&gt;Questionable Content&lt;/a&gt;&lt;br /&gt;6. Read xkcd and QC&lt;br /&gt;7. Check email&lt;br /&gt;8. Return pokes on Facebook, Decline being turned into a zombie, seeing how my friends rate me or other such crap, and finally close Firefox (albeit usually only briefly).&lt;br /&gt;&lt;br /&gt;About this time, I manage to finish my cereal and go back downstairs to boil the kettle for tea or (if it's after 11am) coffee.&lt;br /&gt;&lt;br /&gt;Upon returning to the computer with my tea or coffee, I'm ready to actually do something useful. At the moment I'm doing some paid programming work, which means working in Windows on Visual Studio 2008. Otherwise, I might play with some C++ or Python code, write a new class or plugin for &lt;a href="http://www.cerenkov.org/"&gt;Cerenkov&lt;/a&gt; or do something else I thought up.&lt;br /&gt;&lt;br /&gt;I somehow manage to waste a lot of time during the day, so even though I have lots of ideas for projects, many of them are never finished and some don't even get started. This is a bit of a problem, since I'd quite like to see some of these things through to completion, but there are just far too many distractions around these days.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4470666517647633822-7582117846005401699?l=physical-thought.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://physical-thought.blogspot.com/feeds/7582117846005401699/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4470666517647633822&amp;postID=7582117846005401699' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4470666517647633822/posts/default/7582117846005401699'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4470666517647633822/posts/default/7582117846005401699'/><link rel='alternate' type='text/html' href='http://physical-thought.blogspot.com/2008/07/starting-day.html' title='Starting the Day'/><author><name>Andrew J. Bennieston</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://bp2.blogger.com/_zi39n2uYgqg/R3f879w2IHI/AAAAAAAAAAY/IsPK0LU5Duc/S220/avatar.png'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4470666517647633822.post-8173664165829511396</id><published>2008-07-10T10:51:00.002+01:00</published><updated>2008-07-10T11:20:44.322+01:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='nmap tutorial'/><category scheme='http://www.blogger.com/atom/ns#' term='firefox'/><category scheme='http://www.blogger.com/atom/ns#' term='internet explorer'/><category scheme='http://www.blogger.com/atom/ns#' term='linux'/><category scheme='http://www.blogger.com/atom/ns#' term='windows'/><category scheme='http://www.blogger.com/atom/ns#' term='google'/><title type='text'>Google Analytics</title><content type='html'>I own and operate two domains, one of which I don't particularly use (but plan to in the future) -- physical-thought.com. The other is &lt;a href="http://www.nmap-tutorial.com/"&gt;nmap-tutorial.com&lt;/a&gt;, home to a comprehensive guide to the Nmap port scanner, and the number 1 result on google for the words &lt;i&gt;nmap tutorial&lt;/i&gt;. It's also generally in the first page of results for the term &lt;i&gt;nmap&lt;/i&gt; itself!&lt;br /&gt;&lt;br /&gt;A while ago (a year or two) I added Google Analytics to the site, allowing me to track visitor trends, page views, unique visitors, their web browser and other similar data. &lt;a href="http://www.nmap-tutorial.com/"&gt;nmap-tutorial.com&lt;/a&gt; receives an average of 3,000 unique visitors a month, and around 4,000 page views. 70% of that traffic comes from search engines, around 20% from referring sites (it is linked from the nmap documentation page, as well as several other locations that older versions of the tutorial have been posted), and around 10% direct hits.&lt;br /&gt;&lt;br /&gt;Most visitors come from the US (1,206 in the past month), Canada (120) or the UK (223). India also features prominently with 160 visitors in the past month, and the rest of the world also played their parts.&lt;br /&gt;&lt;br /&gt;A massive 58% of my visitors use Firefox, compared to only 30% on Internet Explorer. Opera falls into third place with 5% of the visitors, and Safari takes a mere 3%. Other browsers account for the rest but no single browser seems to dominate in the obscure end of the market!&lt;br /&gt;&lt;br /&gt;A more interesting report is the Browser/Operating System combination. Over 34% of my visitors use Firefox on Windows. 30% use Internet Explorer on Windows, and 20% use Firefox on Linux. The rest aren't really worth mentioning. This was interesting mainly because I would have expected far more Linux users on a site like &lt;a href="http://www.nmap-tutorial.com/"&gt;nmap-tutorial.com&lt;/a&gt;. Perhaps the "tutorial" nature attracts those just getting into security, and hence still clinging to their Windows operating systems!&lt;br /&gt;&lt;br /&gt;Anyway, today I added Google Analytics code to this blog. There are two reasons for doing this; firstly I want to keep track of how many readers I have. My current mechanism for doing this is to use the Adsense page hits count, which is not a particularly accurate indicator since I may visit a page several times in the course of writing a new post.&lt;br /&gt;&lt;br /&gt;Secondly, I'm intrigued as to the browser/OS combination of readers of this blog, given its fairly technical nature incorporating programming, physics and other such stuff, I'm expecting Firefox/Linux to feature prominently, but we'll see.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4470666517647633822-8173664165829511396?l=physical-thought.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://physical-thought.blogspot.com/feeds/8173664165829511396/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4470666517647633822&amp;postID=8173664165829511396' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4470666517647633822/posts/default/8173664165829511396'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4470666517647633822/posts/default/8173664165829511396'/><link rel='alternate' type='text/html' href='http://physical-thought.blogspot.com/2008/07/google-analytics.html' title='Google Analytics'/><author><name>Andrew J. Bennieston</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://bp2.blogger.com/_zi39n2uYgqg/R3f879w2IHI/AAAAAAAAAAY/IsPK0LU5Duc/S220/avatar.png'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4470666517647633822.post-2170933650035933441</id><published>2008-07-09T20:12:00.005+01:00</published><updated>2008-07-09T22:44:55.739+01:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='photography'/><title type='text'>Filter Ring Step Adapters</title><content type='html'>This morning I was running round Nottingham trying to find somewhere that sold filter ring adapters; these are devices which attach to the filter thread of a camera lens and provide another filter thread of a different size, allowing you to use smaller or larger filters than the lens ordinarily permits.&lt;br /&gt;&lt;br /&gt;In my case, I wanted to be able to use my 62mm circular polarising filter on my 58mm thread lens, so I needed a 58-62mm step-up ring. This proved impossible to find. &lt;a href="http://www.jacobsdigital.co.uk/"&gt;Jacobs&lt;/a&gt; had some adapters, but most were step-down (which surely would obscure part of the lens and thus be of very little use at all). The few step-up adapters they did have were the wrong sizes, so I moved on to &lt;a href="http://www.lcegroup.co.uk/"&gt;London Camera Exchange&lt;/a&gt;, who informed me they did not keep adapters in stock, but could order them in.&lt;br /&gt;&lt;br /&gt;Onwards to &lt;a href="http://www.jessops.com/"&gt;Jessops&lt;/a&gt;, who also do not stock them. It was here, however, that I received the most useful response; that a company called SRB, based in Luton, produced every kind of adapter imaginable, and took online orders!&lt;br /&gt;&lt;br /&gt;So, after returning home, I Googled SRB Luton, and found the most useful photographic adapter producer in the world: &lt;a href="http://www.srb-griturn.com/"&gt;http://www.srb-griturn.com/&lt;/a&gt;. They stock step-up and step-down ring adapters as well as a whole range of other more exotic things; adapters to make a macro lens out of two lenses, adapters for telescopes and microscopes... the list is almost endless.&lt;br /&gt;&lt;br /&gt;I placed my order this afternoon, selecting 1st class delivery. Hopefully the adapter should arrive soon, and I can certainly recommend the website if you're looking for an adapter. In fact, if they don't have what you need, you can ask them to quote you a price for making it! It really doesn't get any better.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4470666517647633822-2170933650035933441?l=physical-thought.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://physical-thought.blogspot.com/feeds/2170933650035933441/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4470666517647633822&amp;postID=2170933650035933441' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4470666517647633822/posts/default/2170933650035933441'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4470666517647633822/posts/default/2170933650035933441'/><link rel='alternate' type='text/html' href='http://physical-thought.blogspot.com/2008/07/filter-ring-step-adapters.html' title='Filter Ring Step Adapters'/><author><name>Andrew J. Bennieston</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://bp2.blogger.com/_zi39n2uYgqg/R3f879w2IHI/AAAAAAAAAAY/IsPK0LU5Duc/S220/avatar.png'/></author><thr:total>0</thr:total></entry></feed>
