Showing posts with label computers. Show all posts
Showing posts with label computers. Show all posts
Tuesday, July 15, 2014
Lecture notes on Mathematica
Last week Filippo Guarneri and I gave a daylong lecture series on the venerable topic of Mathematica. We covered topics ranging from basic evaluation and programming techniques to tensor calculus. Needless to say, we've written up a nice set of lectures notes for those of you who weren't there. Feel free to have a look!
Friday, September 13, 2013
LieLink: a Mathematica interface for LiE
Ever wished that you could easily transfer you computations done in LiE to Mathematica? You now can with LieLink! LieLink is an small Mathematica package that interfaces with LiE, allowing you to directly execute LiE commands in Mathematica and get the result back. Here's an small example:
<<LieLink`
SetDefaultAlgebra["A2"]
LieTensor[{1, 0}, {1, 0}]
(* => {0,1} + {2,0} *)
You can download LieLink from github.com/teake/LieLink.
Thursday, May 30, 2013
xTras v1.1.3
I've just posted a new version of my Mathematica package xTras. It fixes a couple of bugs and introduces some new functions. One of these functions is MakeTraceless, which takes any tensorial expression and returns its traceless version. For example:
As always, you can grab the newest version of xTras from its www.xact.es/xtras, or have a look at the changelog for all the new features.
In: MakeTraceless[RiemannCD[-a,-b,-c,-d]]The output uses the implicit symmetrizations of the SymManipulator package. But we can also symmetrize explicitly by expanding the symmetries:
Out: \( R_{abcd} + \frac{2 R \underset{1234}{Sym}(g_{ac} g_{bd})}{2 -3 d + d^2} + - \frac{4 \underset{1234}{Sym}(g_{bd} R_{ac})}{-2 + d} \)
In: ToCanonical@ExpandSym@MakeTraceless[RiemannCD[-a, -b, -c, -d]]Of course, this is just the Weyl tensor in d dimensions:
Out: \(- \frac{g_{bd} R_{ac}}{-2 + d} + \frac{g_{bc} R_{ad}}{-2 + d} + \frac{g_{ad} R_{bc}}{-2 + d} - \frac{g_{ac} R_{bd}}{-2 + d} - \frac{g_{ad} g_{bc} R}{2 -3 d + d^2} + \frac{g_{ac} g_{bd} R}{2 -3 d + d^2} + R_{abcd} \)
In: Simplification@ RiemannToWeyl@ExpandSym@MakeTraceless[RiemannCD[-a, -b, -c, -d]]Another new function is ConstructDDIs, which construct dimensional dependent identities (DDIs). Say we have a two-dimensional manifold. We can then ask for a list of all DDIs which have one curvature tensor and two free indices:
Out: \(W_{abcd} \)
In: ConstructDDIs[RiemannCD[a,b,c,d],IndexList[a,b]It returns just one DDI, namely the vanishing of the Einstein tensor. This is well know fact, namely that gravity in two dimensions is purely topological, because the Einstein-Hilbert action is equal to the two-dimensional Euler density.
Out: \({R^{ab} - \tfrac{1}{2} g^{ab} R} \)
As always, you can grab the newest version of xTras from its www.xact.es/xtras, or have a look at the changelog for all the new features.
Wednesday, November 7, 2012
xAct notebooks
I put some notebooks for xAct on my website, at http://www.aei.mpg.de/~nutma/. There's an introductory notebook, and two more advanced ones covering the Noether procedure for spin 2 and some calculations for spin 3. Go have a look!
Update (30-04-2016): the above links are dead, but the majority of material in the notebooks have made its way into the xTras documentation as tutorials. The online version can be found here.
Update (30-04-2016): the above links are dead, but the majority of material in the notebooks have made its way into the xTras documentation as tutorials. The online version can be found here.
Sunday, March 25, 2012
xTras for xAct
I'm a big fan of xAct, a tensor algebra package for Mathematica. While there are other tensor packages for Mathematica on the market, xAct is by far the best. It canonicalizes tensorial expressions blazingly fast, and its perturbation capabilities are state-of-the-art. If you've always wanted to do second-order perturbations of four-derivative curvature tensors but were afraid the actual calculation might take you some weeks, xAct is your man. It does it in a few seconds, and more importantly, doesn't mess up minus signs.
In fact, I like xAct so much, I wrote an additional package for. It's aptly called xTras, and its available over on www.xact.es/xtras. It brings some functionality that I found missing in xAct, like computing equations of motion for the metric, perturbations around AdS spaces, and Young projectors (yes, this also includes Bianchi identities).
I'll demonstrate some of the new functionality by computing the linearization of the Einstein tensor around AdS spaces. Here goes!
First, open up Mathematica, and enter the following line:
In fact, I like xAct so much, I wrote an additional package for. It's aptly called xTras, and its available over on www.xact.es/xtras. It brings some functionality that I found missing in xAct, like computing equations of motion for the metric, perturbations around AdS spaces, and Young projectors (yes, this also includes Bianchi identities).
I'll demonstrate some of the new functionality by computing the linearization of the Einstein tensor around AdS spaces. Here goes!
First, open up Mathematica, and enter the following line:
In: <<xAct`xTras`This loads the xTras package (assuming you're managed to download and install it). Next we'll define a manifold and a metric:
In: DefConstantSymbol[dimension,PrintAs->"D"]We'll be doing stuff on AdS spaces, which has a constant curvature. Hence we need to define a constant symbol to indicate that curvature:
In: DefManifold[M,dimension,IndexRange[a,f]]
In: DefMetric[-1,g[-a,-b],CD]
In: DefConstantSymbol[L]Now we're ready to define the standard Lagrangian for gravity with a cosmological constant:
In: lagrangian = RicciScalarCD[] -(dimension-2)(dimension-1)LWe'd like to compute the equations of motion that follow from this Lagrangian. To do so, we first write the command
In: DefMetricVariation[g,h,eps]This command makes it possible to do covariant metric variations. It also registers the command VarL, which varies Lagrangians:
In: eom = VarL[g[a,b]][lagrangian] //TensorCollectThe equations of motion should allow for AdS spaces. To check this, we first generate a list of replacement rules for curvature tensors of the covariant derivative CD on symmetric spaces:
Out: \( \frac{1}{2} (2 - 3 D + D^2) L g_{ab} + R_{ab} - \frac{1}{2} g_{ab} R\)
In: AdSrules = SymmetricSpaceRules[CD,L]And indeed, the equations of motion are zero for this background:
In: eom /. AdSrules // ToCanonicalThis means we can perturb around this solution. So without any further ado, here's the linear perturbation of the Einstein tensor:
Out: \( 0 \)
In: ExpandBackground[eom, BackgroundSolution -> AdSrules] // TensorCollectAnd that's it! Granted, we could also have done this by hand. But the power of xAct is that it can do much more complicated calculations without breaking a sweat. If we would like to know the second order pertubation of the Einstein tensor, we can simply replace the above input by ExpandBackground[eom,2,BackgroundSolution->AdSrules]. Pretty cool, right?
Out: \( (l - D l) h^{1}{}_{ab} + \frac{1}{2} (-1 + D) l g_{ab} h^{1c}{}_{c} - \frac{1}{2} \triangledown_{a}\triangledown_{b}h^{1c}{}_{c} + \frac{1}{2} \triangledown_{c}\triangledown_{a}h^{1}{}_{b}{}^{c} + \frac{1}{2} \triangledown_{c}\triangledown_{b}h^{1}{}_{a}{}^{c} \)
\(- \frac{1}{2} \triangledown_{c}\triangledown^{c}h^{1}{}_{ab} - \frac{1}{2} g_{ab} \triangledown_{d}\triangledown_{c}h^{1cd} + \frac{1}{2} g_{ab} \triangledown_{d}\triangledown^{d}h^{1c}{}_{c} \)
Tuesday, February 16, 2010
Matching fonts in Keynote and LaTeX
LaTeX is great if you want to typeset documents with lots of mathematics in them, but what if you want to make presentations with lots of math? Sure, there are LaTeX packages like Beamer with which you can straightforwardly make decent looking presentations using nothing but LaTeX. But none of those packages lets you easily control where items end up on a page, make subtle changes to overall lay-out, or add some motion to your slides.
Keynote does all of those things, and a bit more. Here's for example a slide of presentation I gave some time ago:
The things in the image are all created within Keynote (not in a separate drawing program like Adobe Illustrator), and some of them are even animated. This is simply impossible to do solely with LaTeX, and that's why I've been using Keynote for quite some time now for all my presentations.
However, there was always something annoying me: the fonts in formulae I got from LaTeXiT (a small program that lets you insert LaTeX formula in Keynote) didn't match the font over the overall presentation. And if you're a typesetting nerd like me, that's pretty annoying. Luckily, I found a solution. Here's an example with both type of fonts:
The difference is subtle, but certainly noticable. The greek letters haven't changed, but the others are in the same font in the second equation. Here is how you change fonts:
And that's it! After restarting LaTeXiT, all new equations you'll typeset will be in the correct font. Enjoy!
Keynote does all of those things, and a bit more. Here's for example a slide of presentation I gave some time ago:
The things in the image are all created within Keynote (not in a separate drawing program like Adobe Illustrator), and some of them are even animated. This is simply impossible to do solely with LaTeX, and that's why I've been using Keynote for quite some time now for all my presentations.
However, there was always something annoying me: the fonts in formulae I got from LaTeXiT (a small program that lets you insert LaTeX formula in Keynote) didn't match the font over the overall presentation. And if you're a typesetting nerd like me, that's pretty annoying. Luckily, I found a solution. Here's an example with both type of fonts:
The difference is subtle, but certainly noticable. The greek letters haven't changed, but the others are in the same font in the second equation. Here is how you change fonts:
- First, go to the LaTeXiT preferences, and change the default configuration to use xelatex instead of pdflatex:
- Next, add the following to the LaTeXiT preamble:
\usepackage{mathspec}
\usepackage{xunicode}
\usepackage{xltxtra}
\setmainfont{Gill Sans}
\setmathsfont(Digits,Latin,Greek){Gill Sans}
Be sure to change the "Gill Sans" to match whatever font you're using in Keynote.
And that's it! After restarting LaTeXiT, all new equations you'll typeset will be in the correct font. Enjoy!
Sunday, November 1, 2009
Mac free software list
Having updated to Snow Leopard this weekend, I once more downloaded and installed the latest version of all the free applications I use. Almost all of them were compatible with Snow Leopard, a thing I checked beforehand for only a few of them. Here's a careful selection of the apps I couldn't live without:
Internet related:
Internet related:
- Adium
The multi-protocol instant messaging client for the Mac. Handy if you have MSN, ICQ, and Google Talk accounts (like me). - GlimmerBlocker
The only adblocker for Safari that isn't implemented as a hack -- this one is actually a proxy that filters out the stuff you don't want to see. - Transmission
Simply the best torrent client for OS X. - Google Notifier + Google + Growl
A menu bar app that notifies you when there's new mail in you Gmail inbox. The Google + Growl utility makes sure the notifications are Growl compliant.
LaTeX:
System tools:
- Growl
A notification system for Mac OS X. Many programs are capable of using it, and it's a functionality that's lacking by default in OS X. - USB Overdrive
The default mouse acceleration is really crappy on OS X. USB Overdrive lets you change it according to your own tastes. - CDto
CDto adds a button to Finder that opens a Terminal window and changes its active directory to the Finder directory.
- Plex
Plex is a home theatre app that is much more versatile than Front Row. Amongst other things, it can pull content directly from the internet to your TV. - Perian
Perian adds playback support to QuickTime for a whole range of media format. - Flip4Mac
Adds WMV support to QuickTime. - ScrobblePod
If you've got a Last.FM account, this little app is for you. It scrobbles all your plays in iTunes.
Other:
- Jin
Jin is the only chess client that runs on a Mac and supports the Free Internet Chess Server. So if you're a cheap bastard like me and enjoy a game of chess, Jin is the way to go.
Friday, September 25, 2009
Last.FM + Google = Convenience
If you're into music and computers, you're probably aware of Last.FM. It's a social music website that "recommends music, videos and concerts based on what you listen to." For the price of giving up a little privacy to the folks at Last.FM (namely the music you listen to) you get quite a lot in return. I mainly use it in tandem with Google's Calendar and Reader to keep updated on concerts in my neighbourhood. Here's how:
- If you don't have a Last.FM account yet, create one and start scrobbling.
- After some scrobbling Last.FM should have enough data to recommend events. Go to the recommend event page, and set your location by clicking on the "change/set location" link:
It's best if you put in your location as "city, country". For example, my location is "Groningen, The Netherlands".
- Still on the recommended events page, click on the RSS feed icon depicted below and add that feed to your Google Reader (or other favourite RSS reader).
You can also directly import your recommended events into your Google Calendar with the "Google" link, that's a bit too much for me. I just want to be informed about interesting events, and only add those to which I'm actually going to my calendar (we'll do that in step 5).
- Google Reader should now recieve event recommondations based on your musical tastes, like this:
Clicking on the headline takes you the Last.FM page of the event. On that page, there's an attendance section at the bottom. Tell Last.FM that you're going:
The event will now appear on your event list (located at http://www.last.fm/user/myUserName/events).
- The last step is to import your event list into Google Calendar, so that you won't forget to actually go. Simply click the Google button at the top your event list:
Your events should now come up in Google Calendar:
And that's it!
Wednesday, August 5, 2009
Setting up TeXlipse and Sumatra PDF
Update (24-03-2012)
Instead of going through the hassle of configuring SumatraPDF (steps 4-8 below), it's way easier to use the Eclipse PDF viewer PDF4Eclipse. It's specifically written for TeXlipse, and has forward- and inverse-search out-of-the-box.
After raving about how brilliant TeXlipse is, it's perhaps time to describe my actual LaTeX setup on Windows. The key ingredients are:
- LaTeX distribution: MikTeX. I currently have version 2.7 installed, which has SyncTeX support (important for forward- and inverse-searching in PDF files). I haven't tried TeX Live, but that should in principle also work (it also has SyncTex support).
- Editor: Eclipse + TeXlipse.
- Previewer: Sumatra PDF. Yes, that's right, no DVI files for me!
- Download and install MikTeX 2.7 (or newer if you're up for it). Shouldn't be too difficult.
- Get a good version of Eclipse. A bit more difficult, since there are gazillion versions floating on the internet. The standard ones come with support for either C++ or Java, which we don't want. The cleanest distribution I could find is the Platform Runtime Binary. Download it and extract the zip file in C:\Program Files\ or the likes. Also put a shortcut to eclipse.exe on the desktop if you're lazy like me.
- Fire up Eclipse and follow the instructions on the TeXlipse website in order to install TeXlipse.
- Download and install Sumatra PDF. Also easy.
- And now the going gets though: it's time to configure TeXlipse. Luckily the TeXlipse folks also have a page for that. The extra ingredient from me is to add the switch "-synctex=1" to the pdflatex command, which enables PDF syncing. The pdflatex config should look something like this:
- Add a new viewer configuration for SumatraPDF, and make it the top of the list so it's the default viewer. Here's how its config should look:
- We're almost done. We still need to configure the inverse search for Sumatra PDF. Create a .BAT file in the Eclipse directory (or somewhere else convenient), with the following line:
java -classpath "%ECLIPSEDIR%\plugins\net.sourceforge.texlipse_1.3.0\texlipse.jar" net.sourceforge.texlipse.viewer.util.FileLocationClient -p 55000 -f %1 -l %2
There are no hard line breaks here, it's just one single line. Also add a environment variable via Control Panel -> System -> Advanced -> Environment variables -> System variables -> New. The variable name should be "ECLIPSEDIR", its value "c:\program files\eclipse" or wherever you installed Eclipse (both without the quotes). - Configure Sumatra PDF for inverse search by running the command
SumatraPDF.exe -inverse-search "\"C:\Program Files\eclipse\inverse_search.bat\" \"%f\" %l"
where you should take care to properly point to the .BAT file you created in the previous step.
Tuesday, August 4, 2009
The perfect LaTeX editor
LaTeX is great. It's math support is the best, and the automatic layout and referencing works perfect. Say if I wanted to write the Einstein field equations, all I'd have to do is type
in a text file (with some appropriate LaTeX specific headers), compile it, and I'd end up with
It's just brilliant.
However, most of the LaTeX editors available are just fancy text editors, with nothing quite special. Sure, they've all got the syntax highlighting and push-button compilation, but I want more. The reason I want more is because I've done some Java coding in the Netbeans IDE. Some of its features are:

Notice the red cross before the line of the error, and the yellow warning sign before the line where there's an underfull hbox. Although it's not visible from the screenshot, the cursor is over the \otimes, causing the popup to appear that describes that particular command.
Although I'm working with it for a only week now, I'm pretty sure I'll stick to TeXlipse. It just makes my LaTeX workflow that much more pleasant.
G_{\mu\nu} + \Lambda g_{\mu\nu} = \frac{8 \pi G}{c^4} T_{\mu\nu}
in a text file (with some appropriate LaTeX specific headers), compile it, and I'd end up with

However, most of the LaTeX editors available are just fancy text editors, with nothing quite special. Sure, they've all got the syntax highlighting and push-button compilation, but I want more. The reason I want more is because I've done some Java coding in the Netbeans IDE. Some of its features are:
- Automatic code formatting. Any LaTeX enthusiast who has worked with multiple people on one file knows that your co-authors invariably mess up the formatting. Automatic formatting comes to the rescue with just one push of the button.
- Live parsing. No more trying to figure out where those damn compilation errors are. Live parsing tells you with a red underline, much like the grammar check in Microsoft Word, the exact position your faulty code.
- Code completion. Try it. Love it. Can't live without it. Why type the whole command when only the first few characters suffice?
- Build-in documentation. Hover over a function or variable, and a nice documentation popup will appear which tells you all you need to know about that function / variable.
- Subversion support. It tracks the changes you've made in the file with nice colors in the sidebar. And it automatically merges your changes with those of your collaborators. How cool is that?

Notice the red cross before the line of the error, and the yellow warning sign before the line where there's an underfull hbox. Although it's not visible from the screenshot, the cursor is over the \otimes, causing the popup to appear that describes that particular command.
Although I'm working with it for a only week now, I'm pretty sure I'll stick to TeXlipse. It just makes my LaTeX workflow that much more pleasant.
Subscribe to:
Posts (Atom)