# Sequence

## Finite or infinite ordered list of elements / From Wikipedia, the free encyclopedia

#### Dear Wikiwand AI, let's keep it short by simply answering these key questions:

Can you list the top facts and stats about Sequence?

Summarize this article for a 10 year old

In mathematics, a **sequence** is an enumerated collection of objects in which repetitions are allowed and order matters. Like a set, it contains members (also called *elements*, or *terms*). The number of elements (possibly infinite) is called the *length* of the sequence. Unlike a set, the same elements can appear multiple times at different positions in a sequence, and unlike a set, the order does matter. Formally, a sequence can be defined as a function from natural numbers (the positions of elements in the sequence) to the elements at each position. The notion of a sequence can be generalized to an indexed family, defined as a function from an *arbitrary* index set.

For example, (M, A, R, Y) is a sequence of letters with the letter 'M' first and 'Y' last. This sequence differs from (A, R, M, Y). Also, the sequence (1, 1, 2, 3, 5, 8), which contains the number 1 at two different positions, is a valid sequence. Sequences can be *finite*, as in these examples, or *infinite*, such as the sequence of all even positive integers (2, 4, 6, ...).

The position of an element in a sequence is its *rank* or *index*; it is the natural number for which the element is the image. The first element has index 0 or 1, depending on the context or a specific convention. In mathematical analysis, a sequence is often denoted by letters in the form of $a_{n}$, $b_{n}$ and $c_{n}$, where the subscript *n* refers to the *n*th element of the sequence; for example, the *n*th element of the Fibonacci sequence *$F$* is generally denoted as *$F_{n}$*.

In computing and computer science, finite sequences are sometimes called strings, words or lists, the different names commonly corresponding to different ways to represent them in computer memory; infinite sequences are called streams. The empty sequence ( ) is included in most notions of sequence, but may be excluded depending on the context.

A sequence can be thought of as a list of elements with a particular order.^{[1]}^{[2]} Sequences are useful in a number of mathematical disciplines for studying functions, spaces, and other mathematical structures using the convergence properties of sequences. In particular, sequences are the basis for series, which are important in differential equations and analysis. Sequences are also of interest in their own right, and can be studied as patterns or puzzles, such as in the study of prime numbers.

There are a number of ways to denote a sequence, some of which are more useful for specific types of sequences. One way to specify a sequence is to list all its elements. For example, the first four odd numbers form the sequence (1, 3, 5, 7). This notation is used for infinite sequences as well. For instance, the infinite sequence of positive odd integers is written as (1, 3, 5, 7, ...). Because notating sequences with ellipsis leads to ambiguity, listing is most useful for customary infinite sequences which can be easily recognized from their first few elements. Other ways of denoting a sequence are discussed after the examples.

### Examples

The prime numbers are the natural numbers greater than 1 that have no divisors but 1 and themselves. Taking these in their natural order gives the sequence (2, 3, 5, 7, 11, 13, 17, ...). The prime numbers are widely used in mathematics, particularly in number theory where many results related to them exist.

The Fibonacci numbers comprise the integer sequence whose elements are the sum of the previous two elements. The first two elements are either 0 and 1 or 1 and 1 so that the sequence is (0, 1, 1, 2, 3, 5, 8, 13, 21, 34, ...).^{[1]}

Other examples of sequences include those made up of rational numbers, real numbers and complex numbers. The sequence (.9, .99, .999, .9999, ...), for instance, approaches the number 1. In fact, every real number can be written as the limit of a sequence of rational numbers (e.g. via its decimal expansion, also see *completeness of the real numbers*). As another example, π is the limit of the sequence (3, 3.1, 3.14, 3.141, 3.1415, ...), which is increasing. A related sequence is the sequence of decimal digits of π, that is, (3, 1, 4, 1, 5, 9, ...). Unlike the preceding sequence, this sequence does not have any pattern that is easily discernible by inspection.

Other examples are sequences of functions, whose elements are functions instead of numbers.

The On-Line Encyclopedia of Integer Sequences comprises a large list of examples of integer sequences.^{[3]}

### Indexing

Other notations can be useful for sequences whose pattern cannot be easily guessed or for sequences that do not have a pattern such as the digits of π. One such notation is to write down a general formula for computing the *n*th term as a function of *n*, enclose it in parentheses, and include a subscript indicating the set of values that *n* can take. For example, in this notation the sequence of even numbers could be written as $(2n)_{n\in \mathbb {N} }$. The sequence of squares could be written as $(n^{2})_{n\in \mathbb {N} }$. The variable *n* is called an index, and the set of values that it can take is called the index set.

It is often useful to combine this notation with the technique of treating the elements of a sequence as individual variables. This yields expressions like $(a_{n})_{n\in \mathbb {N} }$, which denotes a sequence whose *n*th element is given by the variable $a_{n}$. For example:

- ${\begin{aligned}a_{1}&=1{\text{st element of }}(a_{n})_{n\in \mathbb {N} }\\a_{2}&=2{\text{nd element }}\\a_{3}&=3{\text{rd element }}\\&\;\;\vdots \\a_{n-1}&=(n-1){\text{th element}}\\a_{n}&=n{\text{th element}}\\a_{n+1}&=(n+1){\text{th element}}\\&\;\;\vdots \end{aligned}}$

One can consider multiple sequences at the same time by using different variables; e.g. $(b_{n})_{n\in \mathbb {N} }$ could be a different sequence than $(a_{n})_{n\in \mathbb {N} }$. One can even consider a sequence of sequences: $((a_{m,n})_{n\in \mathbb {N} })_{m\in \mathbb {N} }$ denotes a sequence whose *m*th term is the sequence $(a_{m,n})_{n\in \mathbb {N} }$.

An alternative to writing the domain of a sequence in the subscript is to indicate the range of values that the index can take by listing its highest and lowest legal values. For example, the notation $(k^{2})_{k=1}^{10}$ denotes the ten-term sequence of squares $(1,4,9,\ldots ,100)$. The limits $\infty$ and $-\infty$ are allowed, but they do not represent valid values for the index, only the supremum or infimum of such values, respectively. For example, the sequence $(a_{n})_{n=1}^{\infty }$ is the same as the sequence $(a_{n})_{n\in \mathbb {N} }$, and does not contain an additional term "at infinity". The sequence $(a_{n})_{n=-\infty }^{\infty }$ is a **bi-infinite sequence**, and can also be written as $(\ldots ,a_{-1},a_{0},a_{1},a_{2},\ldots )$.

In cases where the set of indexing numbers is understood, the subscripts and superscripts are often left off. That is, one simply writes $(a_{k})$ for an arbitrary sequence. Often, the index *k* is understood to run from 1 to ∞. However, sequences are frequently indexed starting from zero, as in

- $(a_{k})_{k=0}^{\infty }=(a_{0},a_{1},a_{2},\ldots ).$

In some cases, the elements of the sequence are related naturally to a sequence of integers whose pattern can be easily inferred. In these cases, the index set may be implied by a listing of the first few abstract elements. For instance, the sequence of squares of odd numbers could be denoted in any of the following ways.

- $(1,9,25,\ldots )$
- $(a_{1},a_{3},a_{5},\ldots ),\qquad a_{k}=k^{2}$
- $(a_{2k-1})_{k=1}^{\infty },\qquad a_{k}=k^{2}$
- $(a_{k})_{k=1}^{\infty },\qquad a_{k}=(2k-1)^{2}$
- $\left((2k-1)^{2}\right)_{k=1}^{\infty }$

Moreover, the subscripts and superscripts could have been left off in the third, fourth, and fifth notations, if the indexing set was understood to be the natural numbers. In the second and third bullets, there is a well-defined sequence $(a_{k})_{k=1}^{\infty }$, but it is not the same as the sequence denoted by the expression.

### Defining a sequence by recursion

Sequences whose elements are related to the previous elements in a straightforward way are often defined using recursion. This is in contrast to the definition of sequences of elements as functions of their positions.

To define a sequence by recursion, one needs a rule, called *recurrence relation* to construct each element in terms of the ones before it. In addition, enough initial elements must be provided so that all subsequent elements of the sequence can be computed by successive applications of the recurrence relation.

The Fibonacci sequence is a simple classical example, defined by the recurrence relation

- $a_{n}=a_{n-1}+a_{n-2},$

with initial terms $a_{0}=0$ and $a_{1}=1$. From this, a simple computation shows that the first ten terms of this sequence are 0, 1, 1, 2, 3, 5, 8, 13, 21, and 34.

A complicated example of a sequence defined by a recurrence relation is Recamán's sequence,^{[4]} defined by the recurrence relation

- ${\begin{cases}a_{n}=a_{n-1}-n,\quad {\text{if the result is positive and not already in the previous terms,}}\\a_{n}=a_{n-1}+n,\quad {\text{otherwise}},\end{cases}}$

with initial term $a_{0}=0.$

A *linear recurrence with constant coefficients* is a recurrence relation of the form

- $a_{n}=c_{0}+c_{1}a_{n-1}+\dots +c_{k}a_{n-k},$

where $c_{0},\dots ,c_{k}$ are constants. There is a general method for expressing the general term $a_{n}$ of such a sequence as a function of n; see Linear recurrence. In the case of the Fibonacci sequence, one has $c_{0}=0,c_{1}=c_{2}=1,$ and the resulting function of n is given by Binet's formula.

A holonomic sequence is a sequence defined by a recurrence relation of the form

- $a_{n}=c_{1}a_{n-1}+\dots +c_{k}a_{n-k},$

where $c_{1},\dots ,c_{k}$ are polynomials in n. For most holonomic sequences, there is no explicit formula for expressing $a_{n}$ as a function of n. Nevertheless, holonomic sequences play an important role in various areas of mathematics. For example, many special functions have a Taylor series whose sequence of coefficients is holonomic. The use of the recurrence relation allows a fast computation of values of such special functions.

Not all sequences can be specified by a recurrence relation. An example is the sequence of prime numbers in their natural order (2, 3, 5, 7, 11, 13, 17, ...).

There are many different notions of sequences in mathematics, some of which (*e.g.*, exact sequence) are not covered by the definitions and notations introduced below.

### Definition

In this article, a sequence is formally defined as a function whose domain is an interval of integers. This definition covers several different uses of the word "sequence", including one-sided infinite sequences, bi-infinite sequences, and finite sequences (see below for definitions of these kinds of sequences). However, many authors use a narrower definition by requiring the domain of a sequence to be the set of natural numbers. This narrower definition has the disadvantage that it rules out finite sequences and bi-infinite sequences, both of which are usually called sequences in standard mathematical practice. Another disadvantage is that, if one removes the first terms of a sequence, one needs reindexing the remainder terms for fitting this definition. In some contexts, to shorten exposition, the codomain of the sequence is fixed by context, for example by requiring it to be the set **R** of real numbers,^{[5]} the set **C** of complex numbers,^{[6]} or a topological space.^{[7]}

Although sequences are a type of function, they are usually distinguished notationally from functions in that the input is written as a subscript rather than in parentheses, that is, *a _{n}* rather than

*a*(

*n*). There are terminological differences as well: the value of a sequence at the lowest input (often 1) is called the "first element" of the sequence, the value at the second smallest input (often 2) is called the "second element", etc. Also, while a function abstracted from its input is usually denoted by a single letter, e.g.

*f*, a sequence abstracted from its input is usually written by a notation such as $(a_{n})_{n\in A}$, or just as $(a_{n}).$ Here

*A*is the domain, or index set, of the sequence.

Sequences and their limits (see below) are important concepts for studying topological spaces. An important generalization of sequences is the concept of nets. A **net** is a function from a (possibly uncountable) directed set to a topological space. The notational conventions for sequences normally apply to nets as well.

### Finite and infinite

The **length** of a sequence is defined as the number of terms in the sequence.

A sequence of a finite length *n* is also called an *n*-tuple. Finite sequences include the **empty sequence** ( ) that has no elements.

Normally, the term *infinite sequence* refers to a sequence that is infinite in one direction, and finite in the other—the sequence has a first element, but no final element. Such a sequence is called a **singly infinite sequence** or a **one-sided infinite sequence** when disambiguation is necessary. In contrast, a sequence that is infinite in both directions—i.e. that has neither a first nor a final element—is called a **bi-infinite sequence**, **two-way infinite sequence**, or **doubly infinite sequence**. A function from the set **Z** of *all* integers into a set, such as for instance the sequence of all even integers ( ..., −4, −2, 0, 2, 4, 6, 8, ... ), is bi-infinite. This sequence could be denoted $(2n)_{n=-\infty }^{\infty }$.

### Increasing and decreasing

A sequence is said to be *monotonically increasing* if each term is greater than or equal to the one before it. For example, the sequence $(a_{n})_{n=1}^{\infty }$ is monotonically increasing if and only if *a*_{n+1} $\geq$ *a*_{n} for all *n* ∈ **N**. If each consecutive term is strictly greater than (>) the previous term then the sequence is called **strictly monotonically increasing**. A sequence is **monotonically decreasing** if each consecutive term is less than or equal to the previous one, and is **strictly monotonically decreasing** if each is strictly less than the previous. If a sequence is either increasing or decreasing it is called a **monotone** sequence. This is a special case of the more general notion of a monotonic function.

The terms **nondecreasing** and **nonincreasing** are often used in place of *increasing* and *decreasing* in order to avoid any possible confusion with *strictly increasing* and *strictly decreasing*, respectively.

### Bounded

If the sequence of real numbers (*a _{n}*) is such that all the terms are less than some real number

*M*, then the sequence is said to be

**bounded from above**. In other words, this means that there exists

*M*such that for all

*n*,

*a*≤

_{n}*M*. Any such

*M*is called an

*upper bound*. Likewise, if, for some real

*m*,

*a*≥

_{n}*m*for all

*n*greater than some

*N*, then the sequence is

**bounded from below**and any such

*m*is called a

*lower bound*. If a sequence is both bounded from above and bounded from below, then the sequence is said to be

**bounded**.

### Subsequences

A **subsequence** of a given sequence is a sequence formed from the given sequence by deleting some of the elements without disturbing the relative positions of the remaining elements. For instance, the sequence of positive even integers (2, 4, 6, ...) is a subsequence of the positive integers (1, 2, 3, ...). The positions of some elements change when other elements are deleted. However, the relative positions are preserved.

Formally, a subsequence of the sequence $(a_{n})_{n\in \mathbb {N} }$ is any sequence of the form $(a_{n_{k}})_{k\in \mathbb {N} }$, where $(n_{k})_{k\in \mathbb {N} }$ is a strictly increasing sequence of positive integers.

### Other types of sequences

Some other types of sequences that are easy to define include:

- An
**integer sequence**is a sequence whose terms are integers. - A
**polynomial sequence**is a sequence whose terms are polynomials. - A positive integer sequence is sometimes called
**multiplicative**, if*a*_{nm}=*a*_{n}*a*_{m}for all pairs*n*,*m*such that*n*and*m*are coprime.^{[8]}In other instances, sequences are often called*multiplicative*, if*a*_{n}=*na*_{1}for all*n*. Moreover, a*multiplicative*Fibonacci sequence^{[9]}satisfies the recursion relation*a*_{n}=*a*_{n−1}*a*_{n−2}. - A binary sequence is a sequence whose terms have one of two discrete values, e.g. base 2 values (0,1,1,0, ...), a series of coin tosses (Heads/Tails) H,T,H,H,T, ..., the answers to a set of True or False questions (T, F, T, T, ...), and so on.