# Derivatives of a four vector

How can I take partial derivatives of four vectors in Mathematica? For instance I need to evaluate following simple terms;

1. $\frac{\partial x^\beta}{\partial x^\delta} = g^{\beta \delta}$

2. $\frac{\partial }{\partial x^\delta} (\frac{x^\beta}{x^2}) = \frac{g^{\beta \delta} x^2 - 2x^\delta x^\beta}{x^4}$ ; where $x^2$ is actually $x_\mu x^\mu$

Is there a package that does these calculations? If yes, what are the codes in that package? In this way one could decide the simplest way (optimal tool) to evaluate basic derivatives as above.

If there is not such a package, how could I do it by defining my own functions?

There are actually several packages which you might find quite useful. I used the notebooks provided with Hartle's book Gravity: An Introduction to Einstein's General Relativity and liked them very much. You will also get an idea of how to define the covariant derivatives as well.

1. Gravity: An Introduction to Einstein's General Relativity - Mathematica Notebooks

2. Ricci: A Mathematica Package for Doing Tensor Calculations in Differential Geometry

3. GRQUICK

4. General Relativity, Einstein & All That

I found out that FeynCalc has a function for this which is FourDivergence. The above calculations can be done in this package easily as follows ;

1. FourDivergence[FV[x, $\beta$], FV[x, $\delta$]]
2. FourDivergence[FV[x, $\beta$]/SP[x, x], FV[x, $\delta$] // Fullsimplify

where FV is shorthand for FourVector and SP is shorthand for ScalarProduct. If you will not do general relativity calculations, it seems that FeynCalc's FourDivergence function solves the problem.