# index -- numeric index of a ring variable

## Synopsis

• Usage:
index v
• Inputs:
• v,
• Outputs:
• an integer, the integer index, starting at 0, of v, if it is a variable. If v is not a variable, then null is returned

## Description

Variables are indexed in the following way: the first variable has index 0, the second index 1, and so on, until n-1, where n is the number of generators of R, the ring of v. Then, if the coefficient ring is a polynomial ring, those variables are numbered starting at n, and so on.
 i1 : R = ZZ/101[a..d,t] o1 = R o1 : PolynomialRing i2 : index a o2 = 0 i3 : index t o3 = 4
 i4 : A = ZZ[a..d]; B = A[r,s,t]; C = B[x,y,z] o6 = C o6 : PolynomialRing i7 : index x o7 = 0 i8 : index z o8 = 2 i9 : index r o9 = 0
Notice that r is an element of B, and so indices are taken from that ring. If we consider r as an element of C, we get a different answer. Variables of coefficient rings of coefficient rings have an index too.
 i10 : index(r*1_C) o10 = 3 i11 : index(b*1_C) o11 = 7

The symbol index is also as a key used in GeneralOrderedMonoids to store a table that is used to map generator names to the position of the generator in the list of generators.