Table of Contents

[23-Aug-2013] Redberry version 1.1.5 released


Features highlights:

This update contains the following important features:

To update your Redberry simply change version in your Groovy Grapes:

@Grab(group = 'cc.redberry', module = 'groovy', version = '1.1.5')

or download new .jar from the downloads page.

Derivatives

Now you can use derivatives in Redberry. For example, in order to represent   $f'''(x^2)$ in Redberry, one just should replace primes with ~(3):

def d = 'f~(3)[x**2]'.t

In the case of multivariate functions, one should specify how many times to differentiate with respect to each slot (argument). For example:

def d = 'f~(2, 3, 0)[a**2, w, q]'.t
represents \(\left. \frac{\partial^5}{\partial x^2 \partial y^3} f\left(x, y, q\right) \right|_{x =a^2 ,\, y =w}\).

In the case of indexed objects the inverted indices of differentiation variables should be appended to the indices of pure tensor field. For example, the following expression

def d = 'F~(2)_{mn ab}^{cd}[f_ab]'.t

represents \(\left. \frac{\delta}{\delta t^{ab}} \frac{\delta}{\delta t_{cd}} F_{mn} \left(t_{ab}\right) \right|_{t_{ab} = f_{ab}}\). This tensor will be automatically set to be symmetric with respect to transposition of differentiation indices _ab^cd.

Lean more about derivatives in Redberry documentation.

Transformations

Collect[var1, var2, …, transformations] collects together terms involving the same powers of specified vars and applies specified transformation to the expression that forms the coefficient of each term obtained. Consider the examples:

def t = 'A_m*B_n + A_n*C_m'.t
println Collect['A_m'.t] >> t
   > A_i*(d^i_m*B_n + d^i_n*C_m)

def t = 'D[x][x*f[x, x**2] + f[x, x**2]]'.t
def tr = Collect['f~(0,1)[x, y]'.t, 'f~(1,0)[x, y]'.t, Factor]
println tr >> t
   > f[x,x**2]+(x+1)*f~(1,0)[x,x**2]+2*x*(x+1)*f~(0,1)[x,x**2]

PowerExpand[var1, var2, …] expands all powers of products and powers with respect to specified vars:

def t = '(a*b*c)**d'.t
println PowerExpand >> t
   > a**d*b**d*c**d

def t = '(a*b*c)**d'.t
println PowerExpand['a'] >> t
   > a**d*(b*c)**d

Mappings facade

The very important update of mappings API. The old mutual mapping class is now private. All objects returned by the comparison via % are now immutual. Consider cases:

setAntiSymmetric 'f_abc'
def from = 'f_abc'.t, to = 'f_mnp'.t
def mappings = from % to
//get the first mapping
println mappings.first
      > {_a->_m,_b->_n,_c->_p}

//apply the first mapping
assert mappings >> from == to
//the same as
assert mappings.first >> from == to 
               
def k = 0
//iterate over all mappings
mappings.each{ ++k }
// gives the number of possible mappings
println k
      > 6

//find first negative mapping
def neg = mappings.find{ it.sign == true }
println neg
          > -{_a->_n,_b->_m,_c->_p}

Tensor generator

Allows to generate tensor of the most general form from a given samples. For example, the most general tensor with three indices that can be assembled from metric tensor $g_mn$ and vector $k_m$ is $$ c_1 k_a k_b k_c + c_2 g_{ac} k_b + c_3 g_{ab} k_c + c_4 g_{bc} k_a $$ With Redberry one can do the following

def t = GenerateTensor('_abc'.si, ['g_mn', 'k_a'])
println t
 
   > C[0]*k_{a}*k_{b}*k_{c}+C[1]*g_{ac}*k_{b}+C[2]*g_{ab}*k_{c}+C[4]*g_{bc}*k_{a}

For further reading about this feature see GenerateTensor.

Equations with tensors

A new function Reduce(equations, vars) allows to reduce a system of tensorial equations to a system of symbolic equations and to solve it with external solver (Maple or Mathematica). Solve a system of equations with special symmetries of unknown tensor: \[ \left\{ \begin{array}{l} T^{abe}{}_{rba}-x\,T^{bea}{}_{rba} = 8\,d_{r}^{e}\\ T^{pqr}{}_{klm} T^{abc}{}_{pqr} = d^{a}_{m}\,g^{bc}\,g_{lk} \end{array} \right. \] where $x$ and $T^{abe}{}_{rba}$ are unknown variables and the last one has symmetry [1, 5, 0, 4, 3, 2]. Redberry code:

addSymmetry('T^abc_pqr', 1, 5, 0, 4, 3, 2)

def eq1 = 'T^{abe}_{rba}-x*T^{bea}_{rba} = 8*d_{r}^{e}'.t
def eq2 = 'T^{pqr}_{klm}*T^{abc}_{pqr} = d^{a}_{m}*g^{bc}*g_{lk}'

def options = [Transformations: 'd_n^n = 4'.t, ExternalSolver:
                  [Solver: 'Mathematica',
                   Path: '/usr/local/bin']]

def s = Reduce([eq1, eq2], ['T^abc_pqr', 'x'], options)
println s
   > [[T^{abc}_{pqr} = -d^{a}_{r}*g^{cb}*g_{qp}, x = 12],
       [T^{abc}_{pqr} = d^{a}_{r}*g^{cb}*g_{qp}, x = -4]]

For further reading about Reduce(equations, vars) in Reduce.