Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Simple tensor manipulation in Maple or Mathematica

  1. Feb 11, 2007 #1

    nrqed

    User Avatar
    Science Advisor
    Homework Helper
    Gold Member

    I know that this might not be the best forum for the question but I am sure people here can help.

    I want to do some simple tensor contraction using Maple or Mathematica. The calculation is simple but extremely long. All I want is to teach Maple/Mathematica to do tensor contraction without using explicit 4x4 matrices or four-vectors. For example, I want Maple/Mathematica to recognize that [itex] \eta_{\alpha \beta} q^\beta [/itex] must be replaced by [itex] q_\alpha [/itex] . Or that [itex] \eta_{\mu \nu} \eta^{\mu \alpha} [/itex] must be replaced by [itex] \eta^\alpha_\nu [/itex] or that [itex] \eta_{\mu \nu} \eta^{\mu \nu} = 4 [/itex] and so on.

    The calculation involves hundreds of terms (it is in the context of linearized GR quantized as an effective field theory).

    I would highly appreciate if someone could tell me how to tell Maple/Mathematica to do certain substitutions like this.

    Patrick
     
  2. jcsd
  3. Feb 11, 2007 #2
    If you use the grtensor package in Maple all of these calculations are trivial. For example, you can simply load the Minkowski metric into grtensor so that [itex]\eta_{\mu\nu}=\textrm{diag}(-1,1,1,1)[/itex] and then calculate [itex]\eta_\mu^{\phantom{\mu}\mu}[/itex] by passing the following code to it:

    Code (Text):

    grdef(`tracenu := g{a b}*g{^a ^b}`);
    grcalcd(tracenu);
     
    The first command defines an object called tracenu to be equal to [itex]\eta_{\mu\nu}\eta^{\mu\nu}[/itex] while the second calculates its value and displays the result (hence the command `grcalcd`). Reading through the grtensor manual will tell you how to do the rest.
     
  4. Feb 11, 2007 #3

    nrqed

    User Avatar
    Science Advisor
    Homework Helper
    Gold Member


    Thank you for your reply, it is greatly appreciated.

    I have actually been trying to download an executable of GRTensorII from that very site but every time I click on the link, the browser redirects me to a page that can't be loaded. Could anyone double check this?

    Just to be clear, what I have is is the contraction of a large number of terms (something like 80 terms) containing products of four vectors and flat metrics with another large number of similar terms. The final result will be a rank two tensors so it will have the form
    [tex]c_1 \eta^{\mu \nu} q^2 + c_2 \eta^{\mu \nu} k \cdot q p \cdot p' + c_3 q^\mu q^\nu k \cdot p + \dots [/tex]
    you get the idea. Grtensor will give me this result in that form?

    Thanks again
     
  5. Feb 12, 2007 #4

    pervect

    User Avatar
    Staff Emeritus
    Science Advisor

  6. Feb 12, 2007 #5

    George Jones

    User Avatar
    Staff Emeritus
    Science Advisor
    Gold Member

    I downloaded GRTensorII on Saturday. It took me some time to get it working, as the readme file is out of date and gives incorrect instructions. If you are using Maple 8 (or higher?), try this.
     
  7. Feb 12, 2007 #6

    nrqed

    User Avatar
    Science Advisor
    Homework Helper
    Gold Member

    Thanks for your reply. I did click on software and got a page with a list of executables to download. But it's when I click on one of the executable files to download that my browser (IE) tells me that it can't open the page.
    This is exactly one of the executable files I tried to download. But when I click on your link, Iget the same problem: my browser tells me it can't open the page! You do get a page opening up when you click on this link??

    UPDATE: I tried with Mozilla and still can't get the executable files. The browser tells me "Connexion to grtensor.phy.queensu.ca refused" or something to that effect. I am not behind a firewall or anything that could cause any problem. I would like to know if others can access the executable file. Thanks
     
    Last edited: Feb 12, 2007
  8. Feb 12, 2007 #7

    nrqed

    User Avatar
    Science Advisor
    Homework Helper
    Gold Member

    Thanks George, that's very helpful.
    What executable file did you download?? And from where? If you click on the link provided by pervect, do you get a page opening up? Is that the executable file you downloaded?

    Thanks again
     
  9. Feb 12, 2007 #8

    pervect

    User Avatar
    Staff Emeritus
    Science Advisor

    I just clicked on the above link - my browser said:

    "You have chosen to open GRTii6.exe
    which is a Application
    from: ftp://grtensor.phy.queensu.ca

    Would you like to save this file?
    "

    I even get a file when I click on "yes". The link is using a ftp protocol, so if you want to get more error messages, you might have to hunt around to get a true ftp client. If you really want to do some snooping, telnet to grtensor.phy.queensu.ca with port 21 (the ftp port) that might give you some diagnostic messages (about failed connections). You'll probably find it too painful to attempt to use telnet to actually download anything though. (If you get a connection this way, try a true ftp client or try to debug your browser).

    I'll agree with George about the documentation being outdated. I never did find out how to get initialization working automatically, I wind up manually sourcing a script similar to George's. But that's a problem for after you get the software.
     
  10. Feb 12, 2007 #9
    For what it's worth, I have no difficulty downloading from the grtensor site either. Also, I've attached a copy of my mapleinit file - it may be of help to somebody. I'm running OS X, so if you're a Linux user, simply replace the

    Code (Text):
    "/Users/***/Documents/grii/lib/"
    bit with a path that points to your grtensor lib folder. Similarly, replace

    Code (Text):
    "/Users/***/Documents/grii/metrics/"
    with a path that points to your metrics folder. Rename the file as .mapleinit and put it in your home directory. Then when you start up maple all you need to type is

    Code (Text):
    grtw();
    and you're away. I don't use Windows so don't ask me about the corresponding procedure there.
     

    Attached Files:

  11. Feb 12, 2007 #10

    nrqed

    User Avatar
    Science Advisor
    Homework Helper
    Gold Member

    Thanks for checking this out.
    I finally managed to get the file, it worked fine at school! (I have no idea what was wrong with my home computer).


    EDIT: SUCCESS! I finally got it to work.
    Thanks for everybody's help (Thanks George for the file, which I used)

    Stay tuned, as I will probably have questions about how to use it.



    Patrick
     
    Last edited: Feb 12, 2007
  12. Feb 13, 2007 #11

    nrqed

    User Avatar
    Science Advisor
    Homework Helper
    Gold Member

    Thanks for that. Yes, it works as you described.

    Now, what I need to do is to contract a bunch of terms containg various products of the metric and a bunch of four-momenta. Is there any way to have the final result in the form [tex] g^{\mu \nu} q^2 p \cdot k + q^\mu q^\nu k^2 + \ldots [/tex] as opposed to having a very long expression containing the components of all the four vectors, namely something like [tex] q_0 k_1^2 + q_0 k_2^2 + \ldots [/tex]. My problem is that there are 4 different four-vectors involved in my expression so it would be a mess to disentangle a very long expression containing many products of components and figuring out what expression it corresponds to (for example, figuring out that a bunch of terms [itex] q_0 k_1 p_1 p_0 + \ldots [/itex] actually represent [itex] q \cdpot k p^2 + q \cdot p k \cdot q [/itex])

    I have used programs in the past that did that (programs for particle physics calculations) but I unfortunately don't have access to them anymore.

    Thanks for the help
     
  13. Sep 17, 2007 #12
    Problems of the type you mention can easily be tackled with cadabra (available at
    http://www.aei.mpg.de/~peekas/cadabra). For example, after input of the declarations

    Code (Text):
    {\alpha,\beta,\mu,\nu}::Indices(position=fixed).
    {\alpha,\beta,\mu,\nu}::Integer(0..3).
    \eta_{\mu\nu}::Metric.
    \eta^{\mu\nu}::InverseMetric.
    { \eta^{\mu}_{\nu}, \eta_{\nu}^{\mu} }::KroneckerDelta.
    you can do the three examples with

    Code (Text):
    \eta_{\alpha\beta} q^{\beta};
    @eliminate_metric!(%);
    which gives
    [tex]q_{\alpha};[/tex]

    Code (Text):
    \eta_{\mu \nu} \eta^{\mu \alpha};
    @eliminate_metric!(%);
    which gives
    [tex]\eta_{\nu}^{\alpha};[/tex]

    Code (Text):
    \eta_{\mu \nu} \eta^{\mu \nu};
    @eliminate_metric!(%);
    @eliminate_kr!(%);
    which gives
    [tex]4;[/tex];

    Cadabra runs on Linux and Mac OS X. Hope this helps.
     
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook

Have something to add?



Similar Discussions: Simple tensor manipulation in Maple or Mathematica
  1. Maple or Mathematica? (Replies: 5)

  2. Maple / Mathematica (Replies: 4)

  3. Mathematica or Maple (Replies: 11)

  4. Maple or mathematica? (Replies: 7)

  5. Manipulate Mathematica (Replies: 1)

Loading...