What is this?
Why does Maple not substitute the value for y[1] in the result?
I assume that the values were substituted in sum() but subs() does not execute sum(). Accordingly there is at the timepoint of substitution no y[1] in sum()?
Thanks Dirk
This is a way that works, though I do not like much:
eval(sum(r[i]*y[i],i=1..m),[m=3,sum=add,y[1]=2]);
The short answer to "why" is that sum(r[i]*y[i], i=1..m) does not actually contain y[1]. See for yourself:
> sum(r[i]*y[i], i=1..m);
No y[1] there! One thing you could do is this:
> eval(eval(sum(r[i]*y[i],i=1..m),m=3),y[1]=2);
Note: I use eval rather than subs, to have the result evaluated after substitution.
Please, disregard this post. The previous content was misconceived.
Yes, but you have insert i=1..3 instead of i=1..m in your equation above. In this case you would not need the m=3 in subs().
You are quite right, which is why I withdraw my post. I apologize.
I did not see your response, as I sent my answer. Sorry for that.
I reckoned that. I hope that you have received a useful answer from the others, because these postings of mine surely are of no help :-).
Here are two ways of trying to do this. The first does not work, the sum is not evaluated.
subs(y[1]=2,subs(m=3,sum(r[i]*y[i],i=1..m)));
The next works, with a forced evaluation.
subs(y[1]=2,eval(subs(m=3,sum(r[i]*y[i],i=1..m))));
If you look at the help on sum in Maple 11 you will find the following statement.
"Maple returns the call unevaluated if it cannot find a closed form."
Since you do not have a closed form, Maple does not evaluate the sum and there is no "y[1]."
One way
This is a way that works, though I do not like much:
eval(sum(r[i]*y[i],i=1..m),[m=3,sum=add,y[1]=2]);sum and subs
The short answer to "why" is that sum(r[i]*y[i], i=1..m) does not actually contain y[1]. See for yourself:
No y[1] there! One thing you could do is this:
Note: I use eval rather than subs, to have the result evaluated after substitution.
Disregard this post
Please, disregard this post. The previous content was misconceived.
Yes, but you have insert
Yes, but you have insert i=1..3 instead of i=1..m in your equation above. In this case you would not need the m=3 in subs().
Quite correct
You are quite right, which is why I withdraw my post. I apologize.
I did not see your response,
I did not see your response, as I sent my answer. Sorry for that.
I reckoned that
I reckoned that. I hope that you have received a useful answer from the others, because these postings of mine surely are of no help :-).
It does appear to be the evaluation order.
Here are two ways of trying to do this. The first does not work,
the sum is not evaluated.
subs(y[1]=2,subs(m=3,sum(r[i]*y[i],i=1..m)));
The next works, with a forced evaluation.
subs(y[1]=2,eval(subs(m=3,sum(r[i]*y[i],i=1..m))));
If you look at the help on sum in Maple 11 you will find
the following statement.
"Maple returns the call unevaluated if it cannot find a closed form."
Since you do not have a closed form, Maple does not evaluate the sum
and there is no "y[1]."