Tuesday, May 17, 2016

Open Source Computer Algebra Systems.

So, I started to look for computer help. As an open source freak, I have found two different packages available: Maxima and Cadabra. This post is about impressions on both of them. Not sure yet what I am going to use yet, but my hopes go to Maxima in a first approach.



Why CAS?

Because computing tensor expressions by hand is hard and it's easy to fail in calculating terms, expressions and indices. Specially if you are me. So far I have two immediate needs regarding General Relativity:

  1. To obtain a stress-energy tensor from a metric. That is, I imagine a metric (because why not), and I want to know what's the stress-energy tensor that can make it possible.
  2. To obtain a metric from a stress-energy tensor. The inverse problem. It's actually what I did in the past post about Schwarzschild metric, with $R_{\mu\nu}=0$.

Both of these needs require to operate tensors in a generic way, that is, not with numbers but with general expressions. In the end I'll have to deal with systems of differential equations which I will be able to solve numerically or even if I'm lucky, analytically. But, first thing first. Let's get those systems on paper.

Cadabra

My first approach was to use Maxima, since it's similar to Maple and I have worked a little bit with it in my master thesis. It turns out Cadabra is not bad either and there are good tutorials over there.

For General Relativity, our topic, I have found a dedicated tutorial here.

One of the funny things about Cadabra is it works with LaTex syntax. LaTex is the scientific way of processing good looking documents with formulae and math stuff. Almost all scientific papers I know about are published using LaTex. And look at that: it turns out I know LaTex!!
Another feature of Cadabra is that it is coordinate-free. That means its formulation is completely generic. Not sure if this is good or bad, but it looks like bad for now, because I need coordinate systems to compute metrics... Cadabra seems like the kind of thing you use to do very general stuff, like obtaining expressions for a covariant derivative and stuff like that. Not going to use it for the moment, but I'll have an eye on it.  (Edit April 2017) I really should dig up a little bit more into things...

The second problem (from a stress-tensor, compute a metric), maybe is suitable for Cadabra. Got to find out.

(Edit April 2017) As Ghost suggests in the comments, there's a good tutorial here to do component computation in Cadabra, and look at that, it's our old friend Schwarzschild's metric! It seems you can use Cadabra for much more than generic stuff. I'll have a look into it when I had the time, but it really looks much, much, much sexier now...

Maxima

Maxima seems to work for GR with ctensoritensor and atensor. The first package seems to work fine when you have a metric and a coordinate system. You can put the data in it and you can compute all important tensors. In our case, so far, from any metric we imagine we can obtain Ricci tensor elements. Which is nice.

The second package, itensor, do almost the same things. It works differently, though: it works by operating in the indexes of the components, rather than into the components. Documentation says the best approach depends on the problem, so I have to take its word for it, since I don't know yet the details.

The third package seems to be used for weird algebras, like the ones with a noncommutative dot product. Not my fight for now.

Maxima seems like the best approach for now. It has a very rigid structure, though, and I don't know if I'm going to be able to make a good use of it.

Bonus feature: it works on mobile. Not sure how well yet.

What about non Open Source solutions?

There are many. Mathematica, Maple and a lot of different packages between them. I'm not rich, I don't work in a University, so Open Source it is.

You can access to a nice list of tensor software in here. 


2 comments:

  1. Cadabra author here: if you want to compute Riemann tensors and so on for a particular metric (in a particular coordinate system), take a look at Cadabra's Schwarzschild metric tutorial.

    ReplyDelete
    Replies
    1. Thanks! I'll check it out and I'll edit the post. I didn't see the manual and I've been out of the blog for ages now! Maybe it's time to come back,,,

      Delete