Redberry is an open source computer algebra system designed for algebraic manipulations with tensors

Key features:

  tensor symmetries, multiple index types, dummy indices handling, LaTeX-style i/o
  a wide range of tensor-specific transformations and simplification routines
  programming language with internal support of symbolic tensor algebra
  free & open-source with extensive API for developers

Tensors & indices

Input expressions, apply substitutions and other transformations and Redberry will automatically match and relabel indices, resolve dummy indices clashes etc.:

expr = 'F_mn*(F^ma + T^am)'.t
println 'F_ij = A_i*A_j'.t >> expr
   > A_m*A_n*(A^m*A^a + T^am)
subs = 'x = x_a^a'.t
expr = '(x*f_a + y_a)*(x*f_b + z_b)'.t
println subs >> expr
   > (x_d^d*f_a+y_a)*(x_c^c*f_b+z_b)

Transformations

Redberry provides a wide range of general-purpose and tensor-specific transformations:

println Expand >> '(a+b)**2'.t
   > a**2 + 2*a*b + b**2
expr = 'g_mn*A^mn + g_ab*(g^ab + A^ab)'.t
println EliminateMetrics >> expr
   > 2*A^m_m + d^b_b

Symmetries

Define symmetries of tensors and Redberry will take them into account during any manipulation:

// Setting up Riemann symmetries
addSymmetry 'R_abcd', [[0, 2], [1, 3]].p
addSymmetry 'R_abcd', -[[1, 0]].p
println 'R^abc_d*R_abc^m + R_rdqp*R^mrqp'.t
   > 0

HEP features

Calculate trace of Dirac, SU(N) matrices, simplify Levi-Civita tensors, calculate one-loop counterterms etc.:

// Set up gamma matrix
defineMatrices 'G_a', Matrix1.matrix
// DiracTrace transformation
dTrace = DiracTrace['G_a']
expr = 'Tr[(p_a*G^a + m)*(q_a*G^a-m)*G_n]'.t
println dTrace >> expr
   > 4*m*q_n - 4*m*p_n

Permutation groups

The underlying Redberry algorithms are largely based on computational graph and group theory:

perm1 = [[0, 7, 4, 2], [8, 5]].p
perm2 = [[0, 3, 6], [1, 4, 2]].p
group = Group(perm1, perm2)

println group.setwiseStabilizer(0,4,2,5)
   > Group( [[1, 7, 6]], [[1, 3, 7]],
         [[1, 6], [2, 4]], [[0, 2], [1, 6]] )

Programming

Use all features of general-purpose programming language (looping, branching, functions, classes etc.) to implement custom functions and transformations:

//invert indices of expr
invert = { expr ->
    indices = expr.indices
    (indices % indices.inverted) >> expr
} as Transformation

println invert >> ['f_mn'.t, 't^ab'.t]
   > [f^mn, t_ab]