AngouriMath
Sum
Method with 2 overloads
Sum(AngouriMath.Entity,AngouriMath.Entity,AngouriMath.Entity,AngouriMath.Entity)
Summary
A summation ofexpr asvar runs from
from toto inclusive.
Parameter "expr"
The summand. It may mentionvar .Parameter "var"
The index, which this binds — it is not a free variable of the result. Naming
i works: it is the imaginary unit everywhere else, but declaring it as the index
is taken as meaning it, throughout this operator and nowhere outside it — and the
same holds of every other binder in the language. See Binding.
Parameter "from"
The first value of the index.Parameter "to"
The last value of the index, inclusive.Returns
The sum written out where the bounds are concrete integers and there are not too many
terms; a closed form where the body is a polynomial in the index, whatever the bounds;
and an unevaluated Summationf otherwise — so a body this cannot
read is carried rather than refused.
Remarks
An empty range sums to 0 , which is stated rather than left to fall out of the
loop. #248That convention is why a closed form carries a condition: sum(k, k, 1, n) is
(n + n^2)/2 only wheren >= 0 , the range being empty and the sum
0 below that while the polynomial is not.
Example
using System; using AngouriMath; using static AngouriMath.MathS; Console.WriteLine(Sum("k", "k", 1, 10).Simplify()); Console.WriteLine(Sum("k", "k", 1, "n"));
Prints
55 sum(k, k, 1, n)Sum(AngouriMath.Entity,AngouriMath.Entity,AngouriMath.Entity)
Summary
The sum ofexpr over the members ofover as
var ranges over it, each member counted once: written
sum(expr, var in over) . A sum over the roots of a polynomial is a sum over its
set of roots,sum(f(w), w in { w : p(w) = 0 }) , with no index and no order.
Parameter "expr"
The term, as a function ofvar .Parameter "var"
The name that ranges over the set, bound by the sum.Parameter "over"
The set.Returns
The terms added up where the set is finite and its members are known: a listed set of
numbers, or roots of a polynomial that are rational, roots of a quadratic or roots of a
binomial -- those of an irreducible cubic or quartic are kept as the sum, radicals
reading no more simply than it. Evaluated to a
number, the roots it cannot write are found numerically, all of them or none. Left as
written otherwise: a set with a symbol among its members, which may coincide, or a set
that is not finite.
Remarks
Example
using System; using static AngouriMath.MathS; Console.WriteLine(Sum("w^2", "w", "{ w : w^3 - 2w + 1 = 0 }").Simplify());
Prints
4
Angouri © 2019-2023 · Project's repo · Site's repo · Octicons · Transparency · 4378 pages online