Maxima Function
sum (expr, i, i_0, i_1)
Represents a summation of the values of expr as
the index i varies from i_0 to i_1.
The noun form 'sum
is displayed as an uppercase letter sigma.
sum
evaluates its summand expr and lower and upper limits i_0 and i_1,
sum
quotes (does not evaluate) the index i.
If the upper and lower limits differ by an integer, the summand expr is evaluated for each value of the summation index i, and the result is an explicit sum.
Otherwise, the range of the index is indefinite.
Some rules are applied to simplify the summation.
When the global variable simpsum
is true
, additional rules are applied.
In some cases, simplification yields a result which is not a summation;
otherwise, the result is a noun form 'sum
.
When the evflag
(evaluation flag) cauchysum
is true
,
a product of summations is expressed as a Cauchy product,
in which the index of the inner summation is a function of the
index of the outer one, rather than varying independently.
The global variable genindex
is the alphabetic prefix used to generate the next index of summation,
when an automatically generated index is needed.
gensumnum
is the numeric suffix used to generate the next index of summation,
when an automatically generated index is needed.
When gensumnum
is false
, an automatically-generated index is only
genindex
with no numeric suffix.
See also , ,
bashindices
, niceindices
,
nouns
, evflag
, and zeilberger
.
Examples:
(%i1) sum (i^2, i, 1, 7); (%o1) 140 (%i2) sum (a[i], i, 1, 7); (%o2) a + a + a + a + a + a + a 7 6 5 4 3 2 1 (%i3) sum (a(i), i, 1, 7); (%o3) a(7) + a(6) + a(5) + a(4) + a(3) + a(2) + a(1) (%i4) sum (a(i), i, 1, n); n ==== \ (%o4) > a(i) / ==== i = 1 (%i5) sum (2^i + i^2, i, 0, n); n ==== \ i 2 (%o5) > (2 + i ) / ==== i = 0 (%i6) sum (2^i + i^2, i, 0, n), simpsum; 3 2 n + 1 2 n + 3 n + n (%o6) 2 + --------------- - 1 6 (%i7) sum (1/3^i, i, 1, inf); inf ==== \ 1 (%o7) > -- / i ==== 3 i = 1 (%i8) sum (1/3^i, i, 1, inf), simpsum; 1 (%o8) - 2 (%i9) sum (i^2, i, 1, 4) * sum (1/i^2, i, 1, inf); inf ==== \ 1 (%o9) 30 > -- / 2 ==== i i = 1 (%i10) sum (i^2, i, 1, 4) * sum (1/i^2, i, 1, inf), simpsum; 2 (%o10) 5 %pi (%i11) sum (integrate (x^k, x, 0, 1), k, 1, n); n ==== \ 1 (%o11) > ----- / k + 1 ==== k = 1 (%i12) sum (if k <= 5 then a^k else b^k, k, 1, 10)); Incorrect syntax: Too many )'s else b^k, k, 1, 10)) ^ (%i12) linenum:11; (%o11) 11 (%i12) sum (integrate (x^k, x, 0, 1), k, 1, n); n ==== \ 1 (%o12) > ----- / k + 1 ==== k = 1 (%i13) sum (if k <= 5 then a^k else b^k, k, 1, 10); 10 9 8 7 6 5 4 3 2 (%o13) b + b + b + b + b + a + a + a + a + a