sequence
sequence
"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, ...).
In computing and computer science, finite sequences are usually called strings,
words or lists, with the specific technical term chosen depending on the type of
object the sequence enumerates and the different ways to represent the sequence in
computer memory. Infinite sequences are called streams.
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
A tiling with squares whose sides are successive Fibonacci numbers in length.
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 in which each element is 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.
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 nth 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
(
2
n
)
n
∈
N
{\textstyle (2n)_{n\in \mathbb {N} }}. The sequence of squares could be written as
(
n
2
)
n
∈
N
{\textstyle (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
∈
N
{\textstyle (a_{n})_{n\in \mathbb {N} }}, which denotes a sequence whose nth
element is given by the variable
a
n
{\displaystyle a_{n}}. For example:
a
1
=
1
st element of
(
a
n
)
n
∈
N
a
2
=
2
nd element
a
3
=
3
rd element
⋮
a
n
−
1
=
(
n
−
1
)
th element
a
n
=
n
th element
a
n
+
1
=
(
n
+
1
)
th element
⋮
{\displaystyle {\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
∈
N
{\textstyle (b_{n})_{n\in \mathbb {N} }} could be a different sequence than
(
a
n
)
n
∈
N
{\textstyle (a_{n})_{n\in \mathbb {N} }}. One can even consider a sequence of
sequences:
(
(
a
m
,
n
)
n
∈
N
)
m
∈
N
{\textstyle ((a_{m,n})_{n\in \mathbb {N} })_{m\in \mathbb {N} }} denotes a sequence
whose mth term is the sequence
(
a
m
,
n
)
n
∈
N
{\textstyle (a_{m,n})_{n\in \mathbb {N} }}.
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
)
{\textstyle (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
∞
=
(
a
0
,
a
1
,
a
2
,
…
)
.
{\displaystyle {(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
,
…
)
{\displaystyle (1,9,25,\ldots )}
(
a
1
,
a
3
,
a
5
,
…
)
,
a
k
=
k
2
{\displaystyle (a_{1},a_{3},a_{5},\ldots ),\qquad a_{k}=k^{2}}
(
a
2
k
−
1
)
k
=
1
∞
,
a
k
=
k
2
{\displaystyle {(a_{2k-1})}_{k=1}^{\infty },\qquad a_{k}=k^{2}}
(
a
k
)
k
=
1
∞
,
a
k
=
(
2
k
−
1
)
2
{\displaystyle {(a_{k})}_{k=1}^{\infty },\qquad a_{k}=(2k-1)^{2}}
(
(
2
k
−
1
)
2
)
k
=
1
∞
{\displaystyle {\bigl (}(2k-1)^{2}{\bigr )}_{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
∞
{\textstyle {(a_{k})}_{k=1}^{\infty }}, but it is not the same as the sequence
denoted by the expression.
a
n
=
a
n
−
1
+
a
n
−
2
,
{\displaystyle a_{n}=a_{n-1}+a_{n-2},}
with initial terms
a
0
=
0
{\displaystyle a_{0}=0} and
a
1
=
1
{\displaystyle 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
n
=
a
n
−
1
−
n
,
if the result is positive and not already in the previous terms,
a
n
=
a
n
−
1
+
n
,
otherwise
,
{\displaystyle {\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.
{\displaystyle a_{0}=0.}
a
n
=
c
0
+
c
1
a
n
−
1
+
⋯
+
c
k
a
n
−
k
,
{\displaystyle a_{n}=c_{0}+c_{1}a_{n-1}+\dots +c_{k}a_{n-k},}
where
c
0
,
…
,
c
k
{\displaystyle c_{0},\dots ,c_{k}} are constants. There is a general method for
expressing the general term
a
n
{\displaystyle 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
,
{\displaystyle c_{0}=0,c_{1}=c_{2}=1,} and the resulting function of n is given by
Binet's formula.
a
n
=
c
1
a
n
−
1
+
⋯
+
c
k
a
n
−
k
,
{\displaystyle a_{n}=c_{1}a_{n-1}+\dots +c_{k}a_{n-k},}
where
c
1
,
…
,
c
k
{\displaystyle c_{1},\dots ,c_{k}} are polynomials in n. For most holonomic
sequences, there is no explicit formula for expressing
a
n
{\displaystyle a_{n}} as a funct