08-26-2020, 07:48 PM
Quote:Discrete sum (with 2 or 4 arguments return then sum from a to b if a<=bAbove quote is from XCas help screen for sum()
or of the opposite of the sum from b+1 to a-1 if a>b+1 or 0 if a=b+1)
or the discrete primitive or sum of the elements of a list or a sequence.
sum(Expr,Var,VarMin(a),VarMax(b),[VarStep(p)])
Why the convoluted swapping of limit with aboved logic ?
And, why swapped limit changed to b+1 to a-1, and not b to a ?
Some confusing examples:
XCas> sum(k, k, 1, 5) // = 1+2+3+4+5 = 15
XCas> sum(k, k, 5, 1) // = -sum(k, k, 2, 4) = -(2+3+4) = -9. OK, but don't know why
XCas> sum(k, k, 5, 1, 1) // got 15 ? somehow, step flipped to -1, instead of swapping limits.
XCas> sum(k, k, 5.1, 1) // got -14.0 ? expected -sum(k, k, 2, 4.1) = -(2+3+4) = -9
Missing step is not equivalent to default step=1
XCas> factor(sum(k, k, a, b)) // (b+a)*(b-a+1)/2
XCas> sum(k, k, a, b, 1) // "Unable to sort boundaries a,b Error: Bad Argument Value"