Mathematica Stack Exchange is a question and answer site for users of Mathematica. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Is it possible to solve Killing equations in Mathematica for a general vector?

I am looking for a way to create Killing equations and then find what the vectors are, but I have a problem with this.


First of all what they are. Without going in to the all gory details of general relativity, in short, Killing vectors are vectors that satisfy Killing equations:

$\nabla_\mu X_\nu+\nabla_\nu X_\mu=0$

Killing vector, according to the dimensions we are working in (3D, 4D etc.), and what coordinates, is a list with number of elements equating the number of dimension. So If I'm working in 2D sperical coordinate system, and I'm only interested in radial and polar coordinates, I'll have a Killing vector of the form

X = { Xθ[θ,ϕ], Xϕ[θ,ϕ]}

If I'm working in 4D spherical coordinate system with coordinates $\{t,r,\theta,\phi\}$, I'll have a Killing vector with components

X = { Xt[t,r,θ,ϕ], Xr[t,r,θ,ϕ], Xθ[t,r,θ,ϕ], Xϕ[t,r,θ,ϕ]}

The above equation is given in terms of covariant derivative, and for covariant vector (with indices down) is

$\nabla_\mu X_\nu=\frac{\partial X_\nu}{\partial x^\mu}-\Gamma^\lambda_{\mu \nu}X_\lambda$

Now $x^\mu$ is just coordinate for $\mu=t,r,\theta,\phi$, so $x^t=t, x^r=r$ etc. And $\Gamma^\lambda_{\mu \nu}$ are Christofell symbols that I can easily find. Oh, and sometimes the partial derivative is noted as $\partial_\mu$.


I'm working on an easy example, a 2D sphere. It's metric is given by

$\begin{pmatrix} 1 & 0\\ 0 & \sin^2\theta \end{pmatrix}$

My code is this

xIN = {θ, ϕ};
n = 2;
met = {{1, 0}, {0, Sin[θ]^2}};
inversemetric := Inverse[met] // FullSimplify
coord = xIN;

(*Christoffel symbols*)

affine := 
 affine = Simplify[
   Table[(1/2) Sum[
      inversemetric[[μ, ρ]] (D[met[[ρ, ν]], 
          coord[[λ]]] + 
         D[met[[ρ, λ]], coord[[ν]]] - 
         D[met[[ν, λ]], coord[[μ]]]), {ρ, 1, 
       n}], {ν, 1, n}, {λ, 1, n}, {μ, 1, n}]]

listaffine := 
       Row[{coord[[ν]], coord[[λ]]}], coord[[μ]]], 
      18], Style[affine[[λ, ν, μ]], 14]}, {λ, 
     1, n}, {ν, 1, n}, {μ, 1, n}] // FullSimplify;

data = {#[[1]], "=", #[[2]], #[[3]], "=", #[[4]]} & /@ 
   Partition[DeleteCases[Flatten[listaffine], Null], 4];

data = Insert[data[[#]], #, 1] & /@ Range[Length[data]];


der[f_, σ_] := D[f, xIN[[σ]]]

derxU[xU_, μ_, ν_] := 
   der[xU[[μ]], ν] + 
    Sum[affine[[ν, μ, λ]] xU[[λ]], {λ,
       1, 2}]] // FullSimplify

derxd[xd_, μ_, ν_] := 
   der[xd[[μ]], ν] - 
    Sum[affine[[ν, λ, μ]] xd[[λ]], {λ,
       1, 2}]] // FullSimplify

derxUup[xU_, μ_, ν_] := 
 Module[{λ, ρ}, 
   Sum[inversemetric[[ν, ρ]] (der[xU[[μ]], ρ] + 
       Sum[affine[[ρ, μ, λ]] xU[[λ]], {\
λ, 1, 4}]), {ρ, 1, 4}]] // FullSimplify

derxdup[xd_, μ_, ν_] := 
 Module[{λ, ρ}, 
   Sum[inversemetric[[ν, ρ]] (der[xd[[μ]], ρ] - 
       Sum[affine[[ρ, λ, μ]] xd[[λ]], {\
λ, 1, 4}]), {ρ, 1, 4}]] // FullSimplify

Now, I have specified the general form of my Killing vector:

ξ = { ξθ[θ, ϕ], ξϕ[θ, ϕ]};

And I've set up Killing equations:

Killeq = Table[ derxd[ξ, ν, μ] + derxd[ξ, μ, ν] == 0, 
                                 {μ, 1, 2}, {ν, 1, 2}] // Flatten

And I get my equations, in Table form

$$ \begin{array}{c} 2 \xi \theta ^{(1,0)}(\theta ,\phi )=0 \\ \xi \theta ^{(0,1)}(\theta ,\phi )+\xi \phi ^{(1,0)}(\theta ,\phi )-2 \cot (\theta ) \xi \phi (\theta ,\phi )=0 \\ \xi \theta ^{(0,1)}(\theta ,\phi )+\xi \phi ^{(1,0)}(\theta ,\phi )-2 \cot (\theta ) \xi \phi (\theta ,\phi )=0 \\ 2 \sin (\theta ) \cos (\theta ) \xi \theta (\theta ,\phi )+2 \xi \phi ^{(0,1)}(\theta ,\phi )=0 \\ \end{array} $$

And that's what I should get, so the code is working (yaaaay! :D)

Now, even though I could just specify Killeq[[1]] = 0 and so on, is there an automatic way for Mathematica to see if there are same, and just give me the list of the ones left (Some kind of If statement)? The problem could be identifying which equation is which later on, but I could just look at the original form of Killeq and see it from there. This would be useful if I need to make TeXForm later on.

And the second part that is bothering me is: How do I solve this?

I tried with

DSolve[{ Killeq[[1]], Killeq[[2]], Killeq[[4]]}, { ξθ[θ, ϕ], ξϕ[θ, ϕ]}, {θ, ϕ}]

But I got the error:

`DSolve::overdet: There are fewer dependent variables than equations, 
so the system is overdetermined.`

Is there a way of finding these kind of things with Mathematica? :\


I tried by separately solving each equation

Flatten[ Table[
    DSolve[ Killeq[[i]], ξθ[θ, ϕ], {θ, ϕ}], {i, 1, 4}]]

And I get this:

$$ \begin{array}{c} \xi \theta (\theta ,\phi )\to c_1(\phi ) \\ \xi \theta (\theta ,\phi )\to \int_1^{\phi } \left(2 \cot (\theta ) \xi \phi (\theta ,K[1])-\xi \phi ^{(1,0)}(\theta ,K[1])\right) \, dK[1]+c_1(\theta ) \\ \xi \theta (\theta ,\phi )\to \int_1^{\phi } \left(2 \cot (\theta ) \xi \phi (\theta ,K[1])-\xi \phi ^{(1,0)}(\theta ,K[1])\right) \, dK[1]+c_1(\theta ) \\ \xi \theta (\theta ,\phi )\to -\csc (\theta ) \sec (\theta ) \xi \phi ^{(0,1)}(\theta ,\phi ) \\ \end{array} $$

Now, given that my 2nd and 3rd equations are repeating, is there any way of solving this with Mathematica?

I am interested, because it would greatly help me find Killing equations in higher dimensions.

share|improve this question
Check here may be you find something useful and – PlatoManiac Sep 22 '13 at 14:16
DeleteDuplicates will remove eqns that are repeated. – Daniel Lichtblau Sep 22 '13 at 15:42
@DanielLichtblau that worked, thanks :) @PlatoManiac I looked there, but all these kind of pages, even the one I've found with RGTC package first give the Killing vectors that have been found by the people in the 1950's and 1960's, and then put them in Killing equation, and check if the Killing equation will yield True after computation... – dingo_d Sep 22 '13 at 15:46
up vote 18 down vote accepted

I don't really know how to automate this. What I show is some form of Cartan-Kuranishi approach: take derivatives (prolongation) and eliminate variables corresponding to higher ones (projection). I took a few based on trial and error.

I'll start with your Killing eqns, except I got rid of the "=0" part so they are now expressions.

Killexpr = 
 Table[derxd[ξ, ν, μ] + derxd[ξ, μ, ν], {μ, 1, 2}, {ν, 1, 2}] // Flatten
{2*Derivative[1, 0][ξθ][θ, ϕ], 
 (-Cot[θ])*ξϕ[θ, ϕ] + Cos[θ]*Sin[θ]*ξϕ[θ, ϕ] + Derivative[0, 1][ξθ][θ, ϕ] + 
     Derivative[1, 0][ξϕ][θ, ϕ], 
 (-Cot[θ])*ξϕ[θ, ϕ] + Cos[θ]*Sin[θ]*ξϕ[θ, ϕ] + Derivative[0, 1][ξθ][θ, ϕ] + 
     Derivative[1, 0][ξϕ][θ, ϕ], 
 -2*Cot[θ]*ξθ[θ, ϕ] + 2*Derivative[0, 1][ξϕ][θ, ϕ]} 
e2 = Join[Killexpr, D[Killexpr, θ], D[Killexpr, ϕ]];
e3 = Union[Join[e2, D[e2, θ], D[e2, ϕ]]];
e4 = Union[Join[e3, D[e3, θ], D[e3, ϕ]]];

Our "variables" are the functions of interest and their various derivatives. We will then eliminate, algebraically, all higher derivs.

vars = Select[ Variables[e4], ! FreeQ[#, ξϕ | ξθ] &];
elim = Cases[vars, Derivative[a_, b_][_][__] /; a + b > 1];
keep = Complement[vars, elim];

Timing[gb = GroebnerBasis[e4, keep, elim, CoefficientDomain -> RationalFunctions, 
                          MonomialOrder -> EliminationOrder];]
{0.140401, Null}
{Derivative[1, 0][ξθ][θ, ϕ],
 Derivative[0, 1][ξϕ][θ, ϕ], 
 Derivative[0, 1][ξθ][θ, ϕ], 
 (-Cot[θ] + Cos[θ]*Sin[θ])*ξϕ[θ, ϕ] + Derivative[1, 0][ξϕ][θ, ϕ], ξθ[θ, ϕ]}*)

Now observe that ξθ is zero (last element in gb) and the next to last is now effectively an ODE.

DSolve[ gb[[-2]] == 0, {ξϕ[θ, ϕ]}, {θ, ϕ}]
{{ξϕ[θ, ϕ] -> E^((1/4)*Cos[2*θ])*Sin[θ]*C[1][ϕ]}}

I realize this is far from an automated approach but I hope it gives some ideas for the problems you have in mind to tackle.

share|improve this answer
So my Killexpr are the DE I obtained from Killing equation? – dingo_d Sep 22 '13 at 16:15
Sorry, I forgot to mention my code alteration. Yes, I simply got rid of the ==0 part. The reason is that the subsequent processing (variable extraction, Groebner bases) is usually happier to work with expressions than equations. – Daniel Lichtblau Sep 22 '13 at 16:37
I did your approach, and with my equations, I ended up at the same result like I got by DSolving each equation separately :\ I have the general look that I need to get (I calculated it by hand), but I'm wondering if I can reproduce that result... – dingo_d Sep 22 '13 at 16:56
I'm confused. From what you originally posted, your result does not have ξθ[θ, ϕ] equal to zero. But mine does (since it shows up as a lone monomial in that Groebner basis). Since we have the same system and use the same method, we should be getting the same result, and that is different from what you showed in the "by hand" computation. – Daniel Lichtblau Sep 22 '13 at 20:14
What did you use for Killexpr? I put $Killexpr =\left\{2 \xi \theta ^{(1,0)}(\theta ,\phi ),\xi \theta ^{(0,1)}(\theta ,\phi )+\xi \phi ^{(1,0)}(\theta ,\phi )-2 \cot (\theta ) \xi \phi (\theta ,\phi ),\xi \theta ^{(0,1)}(\theta ,\phi )+\xi \phi ^{(1,0)}(\theta ,\phi )-2 \cot (\theta ) \xi \phi (\theta ,\phi ),2 \sin (\theta ) \cos (\theta ) \xi \theta (\theta ,\phi )+2 \xi \phi ^{(0,1)}(\theta ,\phi )\right\}$ – dingo_d Sep 22 '13 at 20:40

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.