Error, bad index into Matrix
Error, bad index into Array
Error, bad index into Vector
Description
Examples
Indexing into a Matrix, Array, or Vector must be done with integer values. Related to this, multi-element selection with a Matrix, Array, or Vector must also come down to integers at the endpoints. Trying to index a Matrix with a symbol will result in an error.
Example 1
Note that n has no value in this example.
A ≔ 1,2 ; 3, 4
An,n
Solution:
In this case, defining n corrects the error.
n≔1
n:=1
1
Example 2
This one is more subtle because the sum command is following Maple's normal evaluation rules. The index operation Vi is attempted before sum is called. At this point, the name i does not have a value.
V ≔ 1,2, 3,4
sumVi,i=1..4
Solution 1:
Evaluation of Vi needs to be delayed using right single quotes.
sum 'Vi', i=1..4
10
Solution 2:
Instead of sum, use add. The add command is recommended for adding a finite sequence of values. The add command has special evaluation rules, so no error occurs in the evaluation.
add Vi, i=1..4
Example 3 A nested call to sum with only one set of right single quotes leads to a different error. A second set of right single quotes corrects the problem.
A ≔ Matrix3,i,j→i+j
A≔234345456
sumsumAi,j,i=1..3,j=1..3;
sumsum'A'i,j,i=1..3,j=1..3;
Error, (in SumTools:-DefiniteSum:-ClosedForm) summand is singular in the interval of summation
sumsum' 'A' 'i,j,i=1..3,j=1..3;
36
See Also
add
Matrices and Vectors
uneval
Download Help Document