Welcome to Cadabra Q&A, where you can ask questions and receive answers from other members of the community.
+1 vote

Hi Cdb experts. Thanks as always for your help.

I am trying to write down a vector field as is common in differential geometry, with a basis of derivatives. For example:

u := u^{\mu} \partial_{\mu};

My difficulty is that any serious calculation I try to do comes out all zeros. For example,

from cdb.relativity.abstract import *
u := u^{\mu} \partial_{\mu};
v := v^{\mu} \partial_{\mu};
ex := @(u)@(v) - @(v)@(u);

Is there any way to make cdb aware that should be considered on operator "waiting" for something to operate upon?

Thank you!

GPN

in General questions by (2.0k points)

2 Answers

+2 votes

I've done similar things, like computing the closure of the supersymmetry algebra, by always giving derivative objects a dummy field X to act upon.

So in your case, you could define \uLie and \vLie as derivatives and compute explicitly

\uLie{\vLie{X}} - \vLie{\uLie{X}}

You could also define a new derivative of X

\uvBracket{X}

and give various substitution rules relating them.

I suppose in your case you'd want u and v to be variable, so something more like \Lie{u}{X}, \Lie{v}{X}, and \Bracket_{u v}{X}, with replacements like

\Lie_{a?}{A??} -> a?^{\mu} \partial_{\mu}{A??}

and so forth. Is that along the lines you're thinking?

by (1.1k points)
+1 vote

@dbutter thank you! I applied your advice and here is what I got. I think some useful ideas are:

  • define a new class VectorField
  • define the operation v(f), where v is a vector field and f is a scalar field, as a python __call__

I hope this helps someone additional.

from cdb.core.manip import multiply_through

\partial{#}::PartialDerivative;
{\mu,\nu}::Indices(spacetime,position=fixed);
{f,}::Depends(\partial{#});
{u^{\mu},v^{\mu}, \partial_{\nu}{f}, \partial_{\mu\nu}{f}, e_{\nu}, f, (1/f)}::SortOrder;

def find_first_index(v):
    for ix in v.top().free_indices():
        if ix.parent_rel==super:
            return ix
    raise TypeError(f'{0} has no contravariant index')

class VectorField:
    def __init__(self, v: Ex):
        self.v = v
    def __call__(self, s: Ex):
        return self.of_scalar(s)
    def of_scalar(self,s):
        ix = find_first_index(self.v)
        ex = self.v
        return $@(ex) \partial_{@(ix)}{@(s)}$

u = VectorField($u^{\mu}$)
v = VectorField($v^{\mu}$)
f := f.
lhs := \commutator{u}{v} f ;
rhs = u(v(f)) - v(u(f));
ex := @(lhs) = @(rhs);
product_rule(ex);
distribute(ex);
sort_product(ex);
meld(ex);
factor_out(ex,$\partial_{\nu}{f}$, right=True);
substitute(ex, $\partial_{\nu}{f} -> e_{\nu} f$);
multiply_through(ex, $1/f$)
collect_factors(ex);

Thanks GPN

by (2.0k points)
...