Sequences and series 

Sequences 

 

Maple's terminology differs a little from ours. To us, a sequence is always an infinite list of numbers, but Maple understands them as finite, though aribtrarily long. You can type in the entries of a sequence one by one, or use seq to generate them from a rule. 

> s:= 1, 1/2, 1/3, 1/4, 1/5;
 

1, 1/2, 1/3, 1/4, 1/5 

> s:= seq( 1/n, n=1..10 );
 

1, 1/2, 1/3, 1/4, 1/5, 1/6, 1/7, 1/8, 1/9, 1/10 

> s[4];
 

1/4 

Some sequences are defined by a recursion relation in which each new term is defined in terms of earlier values. The most famous of these is the Fibonacci sequence. We can use an arrow function to implement such a recurrence. 

> fib:= n-> fib(n-1) + fib(n-2);
 

proc (n) options operator, arrow; fib(n-1)+fib(n-2) end proc 

In order to close up the definition, we need two initial values of the sequence. 

> fib(1):= 1:
 

> fib(2):= 1:
 

Now we can ask for any term in the sequence, or construct a part of it. 

> fib(3);
 

2 

> fib(6);
 

8 

> seq( fib(n), n=1..12 );
 

1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144 

Limits of sequences 

To Maple, a 'sequence' is finite and cannot have a limit. However, we can take the expression for the nth term and then take a limit in the usual way. 

> a[n] := (n^2-n)/(2*n^2+sqrt(n));
 

(n^2-n)/(2*n^2+n^(1/2)) 

> limit( a[n], n=infinity );
 

1/2 

> b[n]:= cos(n)^2 / exp(n);
 

cos(n)^2/exp(n) 

> limit( b[n], n=infinity );
 

0 

 

Series 

We can use the Sum command to represent either a finite sum or an infinite series. For example, the partial sums of the geometric series are given by 

> s[n]:= Sum( r^i, i=0..n );
 

Sum(r^i, i = 0 .. n) 

The full geometric series lets n go to infinity. 

> S:= Sum( r^i, i=0..infinity );
 

Sum(r^i, i = 0 .. infinity) 

In these cases Maple can actually tell you what the sum is, but that's pretty rare. Geometric and telescoping series are the elementary examples. 

> value(s[n]);
 

r^(n+1)/(r-1)-1/(r-1) 

> value(S);
 

-1/(r-1) 

> Sum( 1/(n*(n+2)), n=1..infinity );
 

Sum(1/(n*(n+2)), n = 1 .. infinity) 

> value(%);
 

3/4 

It's more likely that Maple will give a reference to some mathematical object that you have never encountered before, as in the harmonic series. 

> h[n]:= Sum( 1/i, i=1..n );
 

Sum(1/i, i = 1 .. n) 

> value(h[n]);
 

Psi(n+1)+gamma 

> limit( %, n=infinity );
 

infinity 

Finally, it's worth knowing that if you just wish to add up a finite list of numbers, the add command may be what you really want. 

> value( Sum( 1/i, i=1..1000) );
 

Psi(1001)+gamma 

> add( 1/i, i=1..1000 );
 

53362913282294785045591045624042980409652472280384260097101349248456268889497101757506097901985035691409088731550468098378442172117885009464302344326566022502100278425632852081405544941210442510142672...
53362913282294785045591045624042980409652472280384260097101349248456268889497101757506097901985035691409088731550468098378442172117885009464302344326566022502100278425632852081405544941210442510142672...
53362913282294785045591045624042980409652472280384260097101349248456268889497101757506097901985035691409088731550468098378442172117885009464302344326566022502100278425632852081405544941210442510142672...
53362913282294785045591045624042980409652472280384260097101349248456268889497101757506097901985035691409088731550468098378442172117885009464302344326566022502100278425632852081405544941210442510142672...
53362913282294785045591045624042980409652472280384260097101349248456268889497101757506097901985035691409088731550468098378442172117885009464302344326566022502100278425632852081405544941210442510142672...
53362913282294785045591045624042980409652472280384260097101349248456268889497101757506097901985035691409088731550468098378442172117885009464302344326566022502100278425632852081405544941210442510142672...
53362913282294785045591045624042980409652472280384260097101349248456268889497101757506097901985035691409088731550468098378442172117885009464302344326566022502100278425632852081405544941210442510142672...
53362913282294785045591045624042980409652472280384260097101349248456268889497101757506097901985035691409088731550468098378442172117885009464302344326566022502100278425632852081405544941210442510142672...
53362913282294785045591045624042980409652472280384260097101349248456268889497101757506097901985035691409088731550468098378442172117885009464302344326566022502100278425632852081405544941210442510142672...
53362913282294785045591045624042980409652472280384260097101349248456268889497101757506097901985035691409088731550468098378442172117885009464302344326566022502100278425632852081405544941210442510142672...
53362913282294785045591045624042980409652472280384260097101349248456268889497101757506097901985035691409088731550468098378442172117885009464302344326566022502100278425632852081405544941210442510142672...
53362913282294785045591045624042980409652472280384260097101349248456268889497101757506097901985035691409088731550468098378442172117885009464302344326566022502100278425632852081405544941210442510142672...
53362913282294785045591045624042980409652472280384260097101349248456268889497101757506097901985035691409088731550468098378442172117885009464302344326566022502100278425632852081405544941210442510142672...
53362913282294785045591045624042980409652472280384260097101349248456268889497101757506097901985035691409088731550468098378442172117885009464302344326566022502100278425632852081405544941210442510142672...
53362913282294785045591045624042980409652472280384260097101349248456268889497101757506097901985035691409088731550468098378442172117885009464302344326566022502100278425632852081405544941210442510142672...
53362913282294785045591045624042980409652472280384260097101349248456268889497101757506097901985035691409088731550468098378442172117885009464302344326566022502100278425632852081405544941210442510142672...
53362913282294785045591045624042980409652472280384260097101349248456268889497101757506097901985035691409088731550468098378442172117885009464302344326566022502100278425632852081405544941210442510142672...
53362913282294785045591045624042980409652472280384260097101349248456268889497101757506097901985035691409088731550468098378442172117885009464302344326566022502100278425632852081405544941210442510142672...