mapleki
mapleki

Reputation: 1

invalid subscript selector problem in function list for loop

This eval(subs(x=0,test[i])^2) output error, invalid subscript selector in maple problem is test[i] in for loop, how to avoid this error?

evolf := proc(z, f)
h1 := z + f;
h2 := z - f;
h3 := z*f;
h4 := z+diff(f,x);
h5 := z-diff(f,x);
h6 := z*diff(f,x);
h7 := subs(x=z, f);
test := [h1, h2, h3, h4, h5, h6, h7];
temp := 0;
for i from 1 to 9 do
    eval(subs(x=0,test[i])^2);
end do;
evalf(temp)
end proc;

Upvotes: 0

Views: 538

Answers (1)

Mat
Mat

Reputation: 206679

You're looping from 1 to 9, but your array only has seven elements in it. You're trying to access elements beyond the array's end.

Upvotes: 1

Related Questions