Wolfram Function Repository
Instant-use add-on functions for the Wolfram Language
Function Repository Resource:
Get a pure function whose argument is a matrix for a given tensor
ResourceFunction["TensorPureFunction"][t,argvars] gives the corresponding pure function representation of a tensor t for a matrix of variables argvars. | |
ResourceFunction["TensorPureFunction"][t] represents an operator form that can be applied to arguments. |
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]= | ![]() |
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]= | ![]() |
Use TensorPureFunction with the following trilinear function:
In[13]:= | ![]() |
Out[13]= | ![]() |
Apply the trilinear function:
In[14]:= | ![]() |
Out[14]= | ![]() |
Define a simple function to compute the deformation gradient given a velocity field at the point :
In[15]:= | ![]() |
The calculation of the deformation gradient for the -velocity is as follows:
In[16]:= | ![]() |
Out[17]= | ![]() |
Now, use TensorPureFunction to obtain a pure function of the above array:
In[18]:= | ![]() |
Out[18]= | ![]() |
In[19]:= | ![]() |
Out[19]= | ![]() |
Define a simple function to compute the vorticity tensor given a velocity field at the point :
In[20]:= | ![]() |
The calculation of the vorticity tensor for the -velocity is as follows:
In[21]:= | ![]() |
Out[22]= | ![]() |
Now, use TensorPureFunction to obtain a pure function of the above array:
In[23]:= | ![]() |
Out[23]= | ![]() |
In[24]:= | ![]() |
Out[24]= | ![]() |
Use TensorPureFunction with the resource function JacobianMatrix:
In[25]:= | ![]() |
Out[25]= | ![]() |
This is equivalent the computing the Jacobian directly:
In[26]:= | ![]() |
Out[26]= | ![]() |
In[27]:= | ![]() |
Out[27]= | ![]() |
Use TensorPureFunction with the resource function HessianMatrix:
In[28]:= | ![]() |
Out[28]= | ![]() |
This is equivalent the computing the Hessian directly:
In[29]:= | ![]() |
Out[29]= | ![]() |
In[30]:= | ![]() |
Out[30]= | ![]() |
Use TensorPureFunction with the resource function DVectorField:
In[31]:= | ![]() |
In[32]:= | ![]() |
The previous tensors are identical, as seen below:
In[33]:= | ![]() |
Out[33]= | ![]() |
This work is licensed under a Creative Commons Attribution 4.0 International License