How to define a mathematical sequence
Description
In mathematics, a sequence is an infinite list of values, typically
real numbers, often written
(Let’s assume that sequences are indexed starting with index 0, at
How can we express sequences in mathematical software?
Related tasks:
Using SymPy, in Python
This answer assumes you have imported SymPy as follows.
1
2
from sympy import * # load all math functions
init_printing( use_latex='mathjax' ) # use pretty math output
Sequences are typically written in terms of an independent variable
We define a term of an example sequence as (n,0,oo)
means that oo
being the SymPy
notation for
1
2
3
4
var( 'n' ) # use n as a symbol
a_n = 1 / ( n + 1 ) # formula for a term
seq = sequence( a_n, (n,0,oo) ) # build the sequence
seq
You can ask for specific terms in the sequence, or many terms in a row, as follows.
1
seq[20]
1
seq[:10]
You can compute the limit of a sequence,
1
limit( a_n, n, oo )
Content last modified on 24 July 2023.
See a problem? Tell us or edit the source.
Topics that include this task
Opportunities
This website does not yet contain a solution for this task in any of the following software packages.
- R
- Excel
- Julia
If you can contribute a solution using any of these pieces of software, see our Contributing page for how to help extend this website.