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.

  • $\begingroup$ Check here may be you find something useful pages.uoregon.edu/phys600/GRmath.html and inp.demokritos.gr/~sbonano.... $\endgroup$ Commented Sep 22, 2013 at 14:16
  • 2
    $\begingroup$ DeleteDuplicates will remove eqns that are repeated. $\endgroup$ Commented Sep 22, 2013 at 15:42
  • $\begingroup$ @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... $\endgroup$
    – dingo_d
    Commented Sep 22, 2013 at 15:46
  • $\begingroup$ It might be helpful to observe that Killing Vectors are representations of a Lie Group, reflecting symmetries of the metric. $\endgroup$
    – bbgodfrey
    Commented Aug 24, 2018 at 1:51
  • $\begingroup$ @Shiv You should post a new question. Also I recommend against using Subscript, Style, andRow, which are formatting constructs, in defining variables. Styling can wait until one has working code. $\endgroup$ Commented Aug 25, 2018 at 14:45

1 Answer 1


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.

  • $\begingroup$ Yeah, I put wrong stuff in it, sorry, now I got the same result. I have never heard of Groebner basis before. But by this method I should obtain solutions? Because I'm looking at your solution and what I should get, and they differ. $\endgroup$
    – dingo_d
    Commented Sep 23, 2013 at 11:11
  • $\begingroup$ Groebner bases are used, in this case, for the projection step of prolong-and-project. The thing to look into would be the Cartan-Kuranishi method. I can't really say more, not having particular expertise in this realm. $\endgroup$ Commented Sep 23, 2013 at 12:38
  • $\begingroup$ Ok, thank you for helping out, I'll look into this :) $\endgroup$
    – dingo_d
    Commented Sep 23, 2013 at 13:12
  • $\begingroup$ The code posted giving me Killing vectors as follows, ![enter image description here](i.sstatic.net/kO402.png) Please guide or advise me where the codes go wrong, I followed exactly the codes. Regards. $\endgroup$
    – Shiv
    Commented Aug 23, 2018 at 14:26
  • $\begingroup$ @Shiv (1) That is not posted code. It is a picture of code. (2) It is not complete (hard to tell what is wanted). (3) It perhaps belongs in a new question, along with a clear statement of what is wanted. $\endgroup$ Commented Aug 23, 2018 at 20:43

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