9.3. Scalar and scalar functions

Another important problem is the following. In the same way that we are using Times for a product of tensors, we shall use Power, Sqrt, Exp and other functions acting on scalar tensor expressions. There is a problem: there are built-in definitions for those functions that could be incorrect for tensors. For example we have (a b)^n = a^n b^n. However (v[a] v[-a])^n is not equal to v[a]^n v[-a]^n. To prevent those problems we have two options: we could define new functions IndexPower, IndexSqrt, etc, or we can introduce a new head Scalar such that the arguments of those functions must be always wrapped with that head.

Scalar                Wrapper to isolate scalar expressions
PutScalar            Wrap scalars with the head Scalar
BreakScalars        Break Scalar expressions into irreducible Scalar expressions
NoScalar            Remove all Scalar heads, introducing new dummies wherever needed

Scalar expressions.

The direct use of Power could lead to unconsistent expressions:

In[915]:=

(v[a] v[-a])^2

Out[915]=

v_a^ ^2 v_ ^a^2

Instead, the right way to write it would be

In[916]:=

Scalar[v[a] v[-a]]^2

Out[916]=

Scalar[v_a^  v_ ^a]^2

xTensor` can work with those objects as usual:

In[917]:=

Scalar[v[a] v[-a]]^2 Scalar[v[b] v[-b]]^3/Scalar[v[c] v[-c]]^4

Out[917]=

(Scalar[v_a^  v_ ^a]^2 Scalar[v_b^  v_ ^b]^3)/Scalar[v_c^  v_ ^c]^4

In[918]:=

Simplification[%]

Out[918]=

Scalar[v_a^  v_ ^a]

Note that Scalar effectively shields its argument from the rest of an expression and therefore there can be repeated indices:

In[919]:=

v[a] Scalar[v[a] v[-a]]

Out[919]=

Scalar[v_a^  v_ ^a] v_ ^a

In[920]:=

Validate[%]

Out[920]=

Scalar[v_a^  v_ ^a] v_ ^a

By default the function Simplification does not add new Scalar heads, because that takes some time for large expressions:

In[921]:=

v[b] v[-b]/Scalar[v[a] v[-a]]//Simplification

Out[921]=

(v_b^  v_ ^b)/Scalar[v_a^  v_ ^a]

You can force it using PutScalar:

In[922]:=

PutScalar[%]

Out[922]=

Scalar[v_b^  v_ ^b]/Scalar[v_a^  v_ ^a]

In[923]:=

Simplification[%]

Out[923]=

1

Two other functions to manipulate Scalar expressions are BreakScalars and NoScalar:

In[924]:=

Scalar[v[a] v[-a] v[b] v[-b]]

Out[924]=

Scalar[v_a^  v_ ^a v_b^  v_ ^b]

In[925]:=

%//BreakScalars

Out[925]=

Scalar[v_a^  v_ ^a] Scalar[v_b^  v_ ^b]

In[926]:=

%//Simplification

Out[926]=

Scalar[v_a^  v_ ^a]^2

In[927]:=

%//NoScalar

Out[927]=

v_a^  v_ ^a v_b^  v_ ^b

DefScalarFunction        Define an inert head
UndefScalarFunction        Undefine an inert head
$ScalarFunctions        List of defined inert heads

Definition of a scalar function.

A scalar function is one that only accepts scalar arguments and returns scalars. Some of them are

In[928]:=

$ScalarFunctions

Out[928]=

{Exp, Log, Sin, Cos, Tan, Csc, Sec, Cot, Power, Factorial}

and we can define new scalar functions:

We define a scalar function SF:

In[929]:=

DefScalarFunction[SF]

** DefScalarFunction: Defining scalar function SF.

In[930]:=

ScalarQ[SF[v[a] v[-a]]]

Out[930]=

True

In[931]:=

$CovDs

Out[931]=

{PD, Cd, ICD, CD}

In[932]:=

CD[-a][1/SF[Scalar[v[a] v[-a]]]]

Out[932]=

-((▽_a^ Scalar[v_a^  v_ ^a]) SF^′[Scalar[v_a^  v_ ^a]])/SF[Scalar[v_a^  v_ ^a]]^2


Created by Mathematica  (May 16, 2008) Valid XHTML 1.1!