Standard Subscripts vs. Literal Subscripts
© Maplesoft, a division of Waterloo Maple Inc., 2013

Introduction


Subscripted names in Maple, such as , can be used and interpreted in different ways. This Tips and Techniques explores the different types of subscripts in Maple, the advantages of each, and how to choose between them. In particular, it examines the difference between standard subscripts, which are interpreted as table references, and literal subscripts, in which the subscript forms an integral part of the variable name.
Note: The following document uses Maple versions 16 and below.
For more information on subscripts in Maple 17 and above, see Improved Subscript Handling (Web)


Standard Subscripts


Standard subscripts in Maple have a dual role. They are both variable names and table references. Frequently, the "table" interpretation can either be completely ignored, or it provides a definite advantage, as it means you can benefit from many builtin Maple commands and tools which understand tables. Standard subscripts are suitable for most applications.

Creating and Using Standard Subscripted Names


In Maple's 2D mathematics input, subscripts can be created in two ways: using the Expression palette, or by using the keyboard shortcut.
To insert subscripts using the Expression palette, folow the instructions below.
Action

Result

Expand the Expression palette, and click on the
expression.


The expression will be inserted at the location of your cursor.


Insert the letter as the base variable.


Press [Tab] to move to the subscript section.


Insert the number 1 as the subscript.


Press the right arrow key to return to the baseline, and continue writing your expression.




To insert subscripts using keyboard shortcuts, place your cursor to the right of your base variable and then type an underscore, [ _ ]. Your cursor will enter the subscript area, where you can enter any characters you like to be part of your subscript, including standard letters, numbers, and greek symbols.
Example

Keystrokes


a [_] 1 rightarrow + a _ 2

Palette symbols and symbol completion work as usual.

alpha [Ctrl][Space] [_] beta [Ctrl][Space]

You can create subscripts of subscripts.

y [_] a [_] 1 rightarrow rightarrow y [_]b [_] 2



Tip: See
the 2D math shortcut keys
for the full list of all shortcut keys.

In Maple Syntax


In 1D Maple syntax, subscripts are entered using square bracket index notation. The result is displayed as a properly formatted subscripted name.
 (2.1.1.1) 
 (2.1.1.2) 
Note that this can also be used in 2D. Although the input is not in the form of a subscript, the output is.
 (2.1.1.3) 
Tip: When entering commands in 2D, you can choose the notation that best suits your application. For instance, you may wish to use square bracket notation for table indices and subscript notation for variable names. For example, if is a table of experimental results for a variety of data points, you could write:
Tip: You can also use the subscript notation to access elements in a list, set, or expression sequence. Both the underscore (2D) and square brackets (2D and Maple syntax) notation can be used.


Example 1: Variables


Subscripted names can be used simply as variable names. Subscripts let you write and display your variables the same as you would write them on paper or read them in a book.
In this example, we will perform some fundamental vector addition. Consider a flight that leaves town A and travels 650 km Northeast, makes a stop in town B, then travels 300 km North to arrive in town C. What is the magnitude of the displacement of the aircraft over the entire trip?
To solve this problem, we will compute the total distance travelled in the and directions, and then use this information to calculate the displacement magnitude .
Because the plane travelled directly Northeast for the first portion of its trip, we know that .
Find :
Find :
Because the plane travelled directly north on the second portion of its trip, is simply 300 km.
Now, solve for :

The flight from Town A to Town C.



In examples such as these, subscripts are simply used to create appropriate variable names.


Example 2: Table References


This example illustrates some of the advantages of the dual variable name/table index interpretation of subscripts.
Run the same experiment 4 times, and record the results:
You can certainly use these names strictly as subscripted variables, but because is a table and not simply a collection of unrelated variable names, you can also do things like add together all the values with a single command:
 (2.1.3.1) 
or create an expression that uses a variable for the index...
 (2.1.3.2) 
 (2.1.3.3) 
and then evaluate that expression for a particular value later.
=
=
These operations would be much more cumbersome to perform if , , , and were simply four different variables.




Literal Subscripts


Once you attach a subscript to a variable, Maple automatically treats the base name as a table. As you have seen in the earlier examples, most of the time this interpretation is convenient or irrelevant. However, there is a scenario where the table interpretation is not desirable.

The Problem


The problem occurs if you need to assign values to both a subscripted name and to the base name itself. For example:
 (3.1.1) 
 (3.1.2) 
 (3.1.3) 
Looks okay so far, but now when you try to access the values, odd things happen:
=
What's happening is that Maple first evaluates , sees that it has a value of 10, and then tries to access the elements of the table "10". Obviously this is not the intended result.


The Solution


The solution is to tell Maple not to treat as a table, by using literal subscripts instead of the regular subscript. A literal subscript is a subscript that is part of the variable name. It is not a table index, and so using it will not automatically declare the base name to be a table.
Repeating the example above using literal subscripts gives:
 (3.2.1) 
 (3.2.2) 
 (3.2.3) 
Since is no longer a table, we can access the variable values properly:
 (3.2.4) 


Creating Literal Subscripts


To create a literal subscript using Maple's 2D math input, you can either use the keyboard shortcut or the expression from the Expression palette. To enter literal subscripts from the Expression palette, click on the
expression ( subscript ).Alternatively, you can use the keyboard shortcut by pressing [Ctrl] and underscore (usually entered as [Ctrl][_]). As you can see in the examples below, literal subscripts look the same as standard subscripts, so you maintain the desired appearance of your variable names.
Example

Keystrokes


a [Ctrl][_] 1 rightarrow [+] a [Ctrl][_] 2

Palette symbols and symbol completion work as usual.

alpha [Ctrl][Space] [Ctrl][_] beta [Ctrl][Space]

You can create literal subscripts of litereral subscripts.

y [Ctrl][_] a [Ctrl][_] 1 rightarrow rightarrow y [Ctrl][_] b [Ctrl][_] 2




Example


Problem Statement:
The following example solves the classic heat transfer problem. Literal subscripts are used throughout. Consider a sealed, insulated beaker that contains 100mL of water at a temperature of C. One liter of water is then added to the beaker, and the final temperature of the liquid combination is 30 C. The problem is to find the initial temperature, , of the added water. Starting with the heat equation, we can procede to solve this problem using literal subscripts to maintain proper notation.
Solution:
The heat leaving the 100mL amount of water must be equal to the heat being added to the one liter amount of water  that is, . Using a standard heat transfer equation, we can write our formula:
 (3.3.1.1) 
Defining what we know:

the mass of 100mL of water


the mass of one liter of water


the initial temperature of the 100mL water


the final temperature of the combined liquids


the specific heat capacity of water



Now we can solve for our final temperature as Maple substitutes in these values:
 (3.3.1.2) 
Notice that literal subscripts allowed us to solve this problem while maintaining proper notation  standard subscripts would not have sufficed.


Literal Subscripts in Maple Syntax


Though rarely done, it is possible to enter literal subscripts using Maple syntax. The same palette button, , can be used when entering expressions in 1D. When you press the button, the result is converted as:
You can then tab between the placeholders to fill in the values. Of course, there is no need to use the palette. You can also type in the expression directly. The key is to surround the expresssion in single back quotes.
 (3.3.2.1) 
 (3.3.2.2) 
 (3.3.2.3) 
 (3.3.2.4) 
However, since the variables are not displayed as subscripted expressions, there is typically no advantage to using literal subscripts when working in Maple syntax notation. A more common approach is to choose different variable names, as described below.



Alternative Approach


If you need to give values to both subscripted and nonsubscripted variables with the same base name, literal subscripts are the best approach when the exact variable names matter, such as when the quantities have standard, widely used names.
If the exact variable name is less crucial, a common alternate approach is to use the standard subscripts for all the subscripted names, and a different variable for the base name variable. For example, if is your base name (so you have , etc. as variable names), then instead of assigning a value to , you can instead use , or . This approach allows you to continue to use standard subscripts and benefit from the advantages of using a table to store values.


Legal Notice: The copyright for this application is owned by Maplesoft. The application is intended to demonstrate the use of Maple to solve a particular problem. It has been made available for product evaluation purposes only and may not be used in any other context without the express permission of Maplesoft.
