Function Repository Resource:

# SymbolToSubscript

Convert symbols into subscript forms

Contributed by: E. Chan-López & Jaime Manuel Cabrera
 ResourceFunction["SymbolToSubscript"][expr] converts any multi-character symbol within expr so that all but the first character become a subscript. ResourceFunction["SymbolToSubscript"][expr,"NestedIndices"] nests multi-character subscripts. ResourceFunction["SymbolToSubscript"][expr,"MultipleIndices"] separates multi-character subscripts with commas.

## Details and Options

ResourceFunction["SymbolToSubscript"] only acts on unprotected subscriptable symbols.
ResourceFunction["SymbolToSubscript"] converts subscriptable symbols involving C into C[i].
SymbolToSubscripts[expr,"NestedIndices"] can be used on subscriptable symbols with multiple indices.
SymbolToSubscripts[expr,"MultipleIndices"] can be used on symbolic matrices, where it separates numbers with commas.
SymbolToSubscripts[expr,"FormatStyle""ToStringFormat"] changes the format of the indices from symbol expressions to strings. It can be used to get the outputs of expressions in string format.

## Examples

### Basic Examples (2)

Convert a symbol to a subscripted symbol:

 In[1]:=
 Out[1]=

Convert multiple symbols:

 In[2]:=
 Out[2]=
 In[3]:=
 Out[3]=
 In[4]:=
 Out[4]=

### Scope (9)

Use with a list of expressions:

 In[5]:=
 Out[5]=

Use with a symbolic matrix:

 In[6]:=
 Out[7]=

Use with a tensor of rank 3:

 In[8]:=
 Out[8]=

Use with a tensor of rank 4:

 In[9]:=
 Out[9]=

Use with a nonlinear system of ordinary differential equations:

 In[10]:=
 Out[10]=

Use with a system of partial differential equations:

 In[11]:=
 Out[11]=

SymbolToSubscript optionally uses "NestedIndices" to represent subscriptable symbols with multiple indices in a nested format:

 In[12]:=
 Out[12]=

SymbolToSubscript optionally uses "MultipleIndices" to represent subscriptable symbols with multiple indices, separating them by commas:

 In[13]:=
 Out[14]=

Both the base and subscript in the output are symbols and inherit any existing definitions:

 In[15]:=
 In[16]:=
 Out[16]=

### Options (1)

#### FormatStyle (1)

SymbolToSubscript includes an option that enables its outputs to be represented in a string format:

 In[17]:=
 Out[18]=

### Applications (3)

Format a symbolic polynomial:

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

Format a symbolic matrix:

 In[21]:=
 In[22]:=
 Out[22]=
 In[23]:=
 Out[23]=

Use SymbolToSubscript and TeXForm:

 In[24]:=
 Out[24]=

Define a function for making a Vandermonde matrix:

 In[25]:=

Format a Vandermonde matrix:

 In[26]:=
 Out[26]=

The SymbolToSubscript command allows TeXForm to be used correctly when we have expressions with subscripts that are written as symbols:

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

### Applications (2)

Use SymbolToSubscript with the resource function HurwitzMatrix:

 In[31]:=
 In[32]:=
 Out[33]=
 In[34]:=
 Out[34]=

Use SymbolToSubscript with the resource function SolutionRulesToFunctions:

 In[35]:=
 Out[35]=

### Possible Issues (2)

The function SymbolToSubscript, when transforming an expression into subscript format, may encounter a potential issue. As the function dissects the expression and processes each component via ToExpression, numerical expressions are simplified by default. For instance, if the only numeric indices we have are zero followed by one, we are left with just the number one. This interpretation leads to the conversion of this pair of numbers into a single subscript, which may not be the intended outcome. To circumvent this problem and provide more granular control over the output, the function is equipped with options that allow for improved handling of how expression components are processed and displayed. Let's illustrate this with an example:

 In[36]:=
 Out[36]=

To handle the above problem, SymbolToSubscript has the "ToStringFormat" option:

 In[37]:=
 Out[37]=
 In[38]:=
 Out[38]=

We can also address this issue using the options for nested indices and multiple indices separated by commas, as demonstrated below:

 In[39]:=
 Out[40]=

The SymbolToSubscript function provides a simple way to handle subscriptable symbols. However, it's essential to be mindful of protected symbols such as E (exponential constant), π (Pi), I (Imaginary unit), among others when using this function. Let's illustrate this with an example:

 In[41]:=
 Out[41]=

To avoid the above misunderstandings, users are highly advised not to use protected symbols.

## Publisher

Ramón Eduardo Chan López

## Requirements

Wolfram Language 13.0 (December 2021) or above

## Version History

• 3.0.0 – 09 August 2023
• 2.0.0 – 26 June 2023
• 1.1.0 – 22 August 2022
• 1.0.0 – 19 July 2022