summaryrefslogtreecommitdiff
path: root/tensors.mac
blob: 6d7248a21deb298d55413770588fbf9962dc675d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
/* Contract indices in expression */

/* NOTE: buildq works like splicing a list with quasiquote in lisp; escaped
items are defined at start of quote */
contr(expr, var) ::= (
  if listp(var) and length(var) > 1 then
  block([head, tail],
    head : first(var),
    tail : rest(var),
    buildq([expr, head, tail], sum(contr(expr, tail), head, 1, 4)))
  elseif listp(var) and length(var) = 1 then
  block([head],
    head : first(var),
    buildq([expr, head], sum(expr, head, 1, 4)))
  elseif listp(var) then
  expr
  else
  buildq([expr, var], sum(expr, var, 1, 4)))$

/* Differentiate with respect to nth coordinate */
cdiff(func, coord) := diff(func, ct_coords[coord])$

/* Wave operator */
box_op(func) := (
  expand(contr(ug[μ,ν] * cdiff(cdiff(func, ν), μ), [μ,ν])
    - contr(ug[μ,ν] * mcs[μ,ν,ρ] * cdiff(func, ρ), [μ,ν,ρ])))$