Hubbry Logo
Index notationIndex notationMain
Open search
Index notation
Community hub
Index notation
logo
7 pages, 0 posts
0 subscribers
Be the first to start a discussion here.
Be the first to start a discussion here.
Index notation
Index notation
from Wikipedia

In mathematics and computer programming, index notation is used to specify the elements of an array of numbers. The formalism of how indices are used varies according to the subject. In particular, there are different methods for referring to the elements of a list, a vector, or a matrix, depending on whether one is writing a formal mathematical paper for publication, or when one is writing a computer program.

In mathematics

[edit]

It is frequently helpful in mathematics to refer to the elements of an array using subscripts. The subscripts can be integers or variables. The array takes the form of tensors in general, since these can be treated as multi-dimensional arrays. Special (and more familiar) cases are vectors (1d arrays) and matrices (2d arrays).

The following is only an introduction to the concept: index notation is used in more detail in mathematics (particularly in the representation and manipulation of tensor operations). See the main article for further details.

One-dimensional arrays (vectors)

[edit]

A vector treated as an array of numbers by writing as a row vector or column vector (whichever is used depends on convenience or context):

Index notation allows indication of the elements of the array by simply writing ai, where the index i is known to run from 1 to n, because of n-dimensions.[1] For example, given the vector:

then some entries are

.

The notation can be applied to vectors in mathematics and physics. The following vector equation

can also be written in terms of the elements of the vector (aka components), that is

where the indices take a given range of values. This expression represents a set of equations, one for each index. If the vectors each have n elements, meaning i = 1,2,…n, then the equations are explicitly

Hence, index notation serves as an efficient shorthand for

  1. representing the general structure to an equation,
  2. while applicable to individual components.

Two-dimensional arrays

[edit]
Elements of matrix A are described with two subscripts or indices.

More than one index is used to describe arrays of numbers, in two or more dimensions, such as the elements of a matrix, (see also image to right);

The entry of a matrix A is written using two indices, say i and j, with or without commas to separate the indices: aij or ai,j, where the first subscript is the row number and the second is the column number. Juxtaposition is also used as notation for multiplication; this may be a source of confusion. For example, if

then some entries are

.

For indices larger than 9, the comma-based notation may be preferable (e.g., a3,12 instead of a312).

Matrix equations are written similarly to vector equations, such as

in terms of the elements of the matrices (aka components)

for all values of i and j. Again this expression represents a set of equations, one for each index. If the matrices each have m rows and n columns, meaning i = 1, 2, …, m and j = 1, 2, …, n, then there are mn equations.

Multi-dimensional arrays

[edit]

The notation allows a clear generalization to multi-dimensional arrays of elements: tensors. For example,

representing a set of many equations.

In tensor analysis, superscripts are used instead of subscripts to distinguish covariant from contravariant entities, see covariance and contravariance of vectors and raising and lowering indices.

In computing

[edit]

In several programming languages, index notation is a way of addressing elements of an array. This method is used since it is closest to how it is implemented in assembly language whereby the address of the first element is used as a base, and a multiple (the index) of the element size is used to address inside the array.

For example, if an array of integers is stored in a region of the computer's memory starting at the memory cell with address 3000 (the base address), and each integer occupies four cells (bytes), then the elements of this array are at memory locations 0x3000, 0x3004, 0x3008, …, 0x3000 + 4(n − 1) (note the zero-based numbering). In general, the address of the ith element of an array with base address b and element size s is b + is.

Implementation details

[edit]

In the C programming language, we can write the above as *(base + i) (pointer form) or base[i] (array indexing form), which is exactly equivalent because the C standard defines the array indexing form as a transformation to pointer form. Coincidentally, since pointer addition is commutative, this allows for obscure expressions such as 3[base] which is equivalent to base[3].[2]

Multidimensional arrays

[edit]

Things become more interesting when we consider arrays with more than one index, for example, a two-dimensional table. We have three possibilities:

  • make the two-dimensional array one-dimensional by computing a single index from the two
  • consider a one-dimensional array where each element is another one-dimensional array, i.e. an array of arrays
  • use additional storage to hold the array of addresses of each row of the original array, and store the rows of the original array as separate one-dimensional arrays

In C, all three methods can be used. When the first method is used, the programmer decides how the elements of the array are laid out in the computer's memory, and provides the formulas to compute the location of each element. The second method is used when the number of elements in each row is the same and known at the time the program is written. The programmer declares the array to have, say, three columns by writing e.g. elementtype tablename[][3];. One then refers to a particular element of the array by writing tablename[first index][second index]. The compiler computes the total number of memory cells occupied by each row, uses the first index to find the address of the desired row, and then uses the second index to find the address of the desired element in the row. When the third method is used, the programmer declares the table to be an array of pointers, like in elementtype *tablename[];. When the programmer subsequently specifies a particular element tablename[first index][second index], the compiler generates instructions to look up the address of the row specified by the first index, and use this address as the base when computing the address of the element specified by the second index.

void mult3x3f(float result[][3], const float A[][3], const float B[][3])
{
  int i, j, k;
  for (i = 0; i < 3; ++i) {
    for (j = 0; j < 3; ++j) {
      result[i][j] = 0;
      for (k = 0; k < 3; ++k)
        result[i][j] += A[i][k] * B[k][j];
    }
  }
}

In other languages

[edit]

In other programming languages such as Pascal, indices may start at 1, so indexing in a block of memory can be changed to fit a start-at-1 addressing scheme by a simple linear transformation – in this scheme, the memory location of the ith element with base address b and element size s is b + (i − 1)s.

References

[edit]
Revisions and contributorsEdit on WikipediaRead on Wikipedia
from Grokipedia
Index notation, also known as tensor index notation or , is a mathematical formalism that represents vectors, matrices, and higher-order tensors using indices to denote components, enabling compact expression of algebraic operations and differential equations in physics and engineering. Building on earlier work in tensor calculus by , it relies on the Einstein summation convention, where a repeated index in a product implies an implicit over its range (typically 1 to 3 in Cartesian coordinates), eliminating the need for explicit summation symbols and simplifying multi-dimensional calculations. The Einstein summation convention, a key aspect of index notation, was introduced by in 1916 during his development of to handle tensor equations efficiently, providing a coordinate-independent framework that extends naturally to and facilitates operations like dot products (AB=AiBi\vec{A} \cdot \vec{B} = A_i B_i

=AiBi), cross products ((A×B)k=ϵijkAiBj(\vec{A} \times \vec{B})_k = \epsilon_{ijk} A_i B_j

×B

)k=ϵijkAiBj using the ), and or computations. Key rules include distinguishing free indices (which vary and define the tensor rank) from dummy indices (repeated and summed over), ensuring no index appears more than twice in a term unless specified, and using comma notation (ui,ju_{i,j}) for partial derivatives. This notation is foundational in fields such as , where it describes stress tensors (σij\sigma_{ij}) and equilibrium equations (σij,j=0\sigma_{ij,j} = 0), for , and relativity for metrics.

In Mathematics

Vectors and One-Dimensional Arrays

In index notation, one-dimensional arrays, commonly referred to as vectors in , are represented as ordered sequences of scalar components denoted by a lowercase letter with a single subscript, such as aia_i, where the index ii specifies the position and ranges from 1 to nn, the of the vector. This notation treats the vector as a list of numbers, allowing precise reference to individual elements without explicit coordinate systems beyond the indexing. For instance, consider the vector a=(10,8,9,6,3,5)\mathbf{a} = (10, 8, 9, 6, 3, 5), which has n=6n = 6; its components are then a1=10a_1 = 10, a2=8a_2 = 8, a3=9a_3 = 9, a4=6a_4 = 6, a5=3a_5 = 3, and a6=5a_6 = 5. Such representation facilitates the handling of vectors as arrays in algebraic manipulations. Basic operations on vectors using index notation emphasize component-wise actions. Element-wise of two vectors a\mathbf{a} and b\mathbf{b} to form c\mathbf{c} is expressed as ci=ai+bic_i = a_i + b_i for each i=1i = 1 to nn, yielding nn independent scalar equations that collectively define the resulting vector. Similarly, follows (ka)i=kai(k \mathbf{a})_i = k a_i. In mathematical contexts, the index range conventionally begins at 1, aligning with the natural numbering of positions in sequences, though adjustments may occur in specific applications. Summation over indices is not implied in this basic form and requires explicit indication, distinguishing it from more advanced conventions. The subscript notation for vectors emerged in 19th-century linear algebra texts to denote coordinate representations, with early systematic use appearing in Hermann Grassmann's Die lineale Ausdehnungslehre (1844), which employed indices for vector components in higher-dimensional extensions. This approach was further developed by J. Willard Gibbs in his vector analysis notes around 1881–1884, solidifying its role in coordinate-based algebra.

Matrices and Two-Dimensional Arrays

In , matrices are defined as rectangular arrays of numbers arranged in rows and columns, represented using double-index notation with two subscripts aija_{ij}, where ii denotes the row index ranging from 1 to mm (the number of rows) and jj denotes the column index ranging from 1 to nn (the number of columns). This structure allows precise access to individual elements, such as the entry in the ii-th row and jj-th column. Matrices are typically denoted by uppercase letters in boldface, such as A\mathbf{A}, to distinguish them from scalars and vectors, which use italicized lowercase letters or bold lowercase for vectors with a single index. Building on , a matrix can be viewed as an of row vectors, where the ii-th row is itself a vector ai=(ai1,ai2,,ain)\mathbf{a}_i = (a_{i1}, a_{i2}, \dots, a_{in}). For example, consider the 4×34 \times 3 matrix A=(986127492605),\mathbf{A} = \begin{pmatrix} 9 & 8 & 6 \\ 1 & 2 & 7 \\ 4 & 9 & 2 \\ 6 & 0 & 5 \end{pmatrix},
Add your contribution
Related Hubs
User Avatar
No comments yet.