Function Repository Resource:

# TensorPureFunction

Get a pure function whose argument is a vector or a matrix for a given tensor

Contributed by: E. Chan-López & Víctor Castellanos
 ResourceFunction["TensorPureFunction"][t,argvars] gives the corresponding pure function representation of a tensor t for a set of variables argvars. ResourceFunction["TensorPureFunction"][t] represents an operator form that can be applied to arguments.

## Details and Options

The t must be a tensor of any rank.
The argvars must be the set of variables of interest and can be either a vector or a matrix.
ResourceFunction["TensorPureFunction"][t,argvars ] can be used to obtain different functions with array arguments in the basic vector calculus and with multilinear functions to study normal forms in applied bifurcation theory.
ResourceFunction["TensorPureFunction"][t,argvars] has an option to specify the method used for indexing the elements of argvars called "IndexingMethod". This option specifies how elements of argvars are indexed within the function. By default, the indexing method for variables in argvars is done using Indexed and specifying "IndexingMethod""UsePart" uses Part as the indexing method.

## Examples

### Basic Examples (3)

Define a function that takes a matrix of variables as input and returns a vector:

 In[1]:=
 Out[1]=

Apply the function:

 In[2]:=
 Out[2]=

Use TensorPureFunction with a tensor of rank 3:

 In[3]:=
 Out[3]=

Apply the function:

 In[4]:=
 Out[4]=

Use TensorPureFunction with a tensor of rank 4:

 In[5]:=
 Out[5]=

Apply the function:

 In[6]:=
 Out[6]=

### Scope (3)

Use TensorPureFunction in combination with Grad:

 In[7]:=
 Out[7]=

Use TensorPureFunction in combination with Curl:

 In[8]:=
 Out[8]=

Use TensorPureFunction to compute a Jacobian matrix:

 In[9]:=
 Out[9]=

Apply the Jacobian function:

 In[10]:=
 Out[10]=

Use TensorPureFunction to compute a Hessian matrix:

 In[11]:=
 Out[11]=

Apply the Hessian function:

 In[12]:=
 Out[12]=

### Options (1)

#### IndexingMethod (1)

The IndexingMethod option allows specifying the method used to indexing elements of argvars in the TensorPureFunction. By default, the method is set to "UseIndexed", which uses the Indexed function. Alternatively, can be set the option to "UsePart" to use the Part function. This option provides flexibility in choosing the preferred method of indexing elements of argvars within the TensorPureFunction:

 In[13]:=
 Out[13]=

### Applications (4)

#### Multilinear Functions (2)

Use TensorPureFunction with the following trilinear function:

 In[14]:=
 Out[14]=

Apply the trilinear function:

 In[15]:=
 Out[15]=

#### Deformation Gradient and Vorticity Tensor (2)

Define a simple function to compute the deformation gradient given a velocity field at the point :

 In[16]:=

The calculation of the deformation gradient for the -velocity is as follows:

 In[17]:=
 Out[18]=

Now, use TensorPureFunction to obtain a pure function of the above array:

 In[19]:=
 Out[19]=
 In[20]:=
 Out[20]=

Define a simple function to compute the vorticity tensor given a velocity field at the point :

 In[21]:=

The calculation of the vorticity tensor for the -velocity is as follows:

 In[22]:=
 Out[23]=

Now, use TensorPureFunction to obtain a pure function of the above array:

 In[24]:=
 Out[24]=
 In[25]:=
 Out[25]=

### Properties and Relations (3)

Use TensorPureFunction with the resource function JacobianMatrix:

 In[26]:=
 Out[26]=

This is equivalent the computing the Jacobian directly:

 In[27]:=
 Out[27]=
 In[28]:=
 Out[28]=

Use TensorPureFunction with the resource function HessianMatrix:

 In[29]:=
 Out[29]=

This is equivalent the computing the Hessian directly:

 In[30]:=
 Out[30]=
 In[31]:=
 Out[31]=

Use TensorPureFunction with the resource function DVectorField:

 In[32]:=
 In[33]:=

The previous tensors are identical:

 In[34]:=
 Out[34]=

## Publisher

Ramón Eduardo Chan López

## Requirements

Wolfram Language 13.0 (December 2021) or above

## Version History

• 2.0.1 – 20 March 2024
• 2.0.0 – 02 October 2023
• 1.0.0 – 08 November 2022