Safekipedia

Index notation

Adapted from Wikipedia · Adventurer experience

In mathematics and computer programming, index notation helps us point to specific numbers in a group or list.

This is useful when we have many numbers in a row, like in a list, a vector, or a matrix.

The way we use these positions can change depending on what we are doing. If we are writing a math paper, we might use one style. But when we write a computer program, we use another style.

This helps everyone understand exactly which number we are talking about. It makes it easier to work with big groups of numbers.

Index notation is important because it makes it simpler to work with complex ideas in both math and computer science. Whether you’re solving equations or writing code, knowing how to use index notation helps you organize and find the exact number you need.

In mathematics

Main articles: Ricci calculus and Tensor

In math, we sometimes write small numbers or letters below other numbers or letters. These small marks are called "indices." They help us name parts of a group of numbers. These groups are called arrays. Arrays can be like a list with one row, a grid with rows and columns, or even more complex.

A simple group of numbers in a row is called a vector. For example, a vector might look like this: (10, 8, 9, 6, 3, 5). We can name each number in the vector using an index. The first number is a₁ (which is 10), the second is a₂ (which is 8), and so on.

We can also use indices for grids of numbers, called matrices. For example, a small grid might look like this:

Each number in this grid can be named using two indices. The number 9 is in the first row and first column, so we call it a₁₁. The number 8 is in the first row and second column, so we call it a₁₂, and so on.

Indices make it easier to work with these groups of numbers in equations. For example, if we have two vectors, a and b, and we want to add them to get a new vector c, we can write this as a simple equation using indices: aᵢ + bᵢ = cᵢ. This means that to get each number in c, we add the numbers in the same position from a and b.

Main article: Matrix (mathematics)

See also: Dyadics

Indices can also be used for more complex groups of numbers called tensors, which can have many rows and columns. In these cases, we might use more than two indices to name each number.

In computing

In many programming languages, index notation is a way to point to parts of an array. This method works like how computers handle memory in assembly language.

The address of the first element is used as a starting point. A number (the index) multiplied by the size of each element helps find other elements in the array.

For example, if an array of whole numbers starts at memory address 3000, and each whole number takes up four bytes, the elements are found at addresses 3000, 3004, 3008, and so on. The address of the _i_th element in an array can be found using the base address and the size of each element.

Implementation details

In the C programming language, there are two ways to write the same thing: *(base + i) and base[i]. They mean the same thing because C lets you write commands in different ways.

When we have tables with more than one row and column, there are three ways to handle them:

  • We can turn the table into a single line by finding a position from the two positions.
  • We can see the table as a line of smaller lines, where each smaller line is a row.
  • We can keep extra information to remember where each row starts and treat each row as its own line.

In C, all three methods can be used. The first method lets the programmer decide how the table is stored in memory and gives formulas to find each element. The second method is used when every row has the same number of elements, known when the program is written. The programmer declares the table, for example, with three columns, and refers to an element using two positions: tablename[first position][second position]. The computer figures out where each element is stored. The third method declares the table as a line of pointers and then uses these pointers to find the rows.

In other languages like Pascal, indices might start at 1 instead of 0. This can be handled by changing the memory location calculation to fit this starting point.

Related articles

This article is a child-friendly adaptation of the Wikipedia article on Index notation, available under CC BY-SA 4.0.