3.3. Expressions and validation
Once we use abstract indices, there is no need to have a special TensorTimes. The usual Times product is enough and has one important advantage: we can use many built-in rules in Mathematica to simplify Times expressions. As usual, contractions are given using Einstein rule of staggered up/down repeated indices.
The order of factors is irrelevant in Times expressions:
In[128]:=
Out[128]=
In[129]:=
Out[129]=
The syntax of any expression can be checked using the function Validate. This function works recursively from the most external structures to the most internal ones, calling private functions ValidateTensor, ValidateCovD, etc. That gives you an idea of which problems will be detected first.
Validate Validate an input expression
Functions that deal with validation.
If we get no errors, the input is syntactically correct:
In[130]:=
Out[130]=
In[131]:=
Out[131]=
Some errors cannot be always localized in a single object. We do not return the expression:
In[132]:=
In[133]:=
Because validation takes up some time, it is not automatic. xTensor` has the command Validate to be used by the user as required. However, if validation is needed in all computations it is possible to switch on automatic validation, by acting on the $Pre variable:
Here, there is not automatic validation:
In[134]:=
Out[134]=
In[135]:=
This switches on automatic validation:
In[136]:=
Out[136]=
In[137]:=
In[138]:=
This switches off automatic validation:
In[139]:=
In[140]:=
Out[140]=
In[141]:=
Created by Mathematica (May 16, 2008) |