ynakamura

80 Reputation

8 Badges

18 years, 116 days

MaplePrimes Activity


These are replies submitted by ynakamura

Thanks, I think this is a perfect answer.
Thanks, I think this is a perfect answer.
Thank you for your comment. I think one of the good examples of difference between sum and add is as follows.
sum(i^2, i=1..n);
                          3          2
                   (n + 1)    (n + 1)
                   -------- - -------- + n/6 + 1/6
                      3          2
add(i^2, i=1..n);
Error, unable to execute add
However, I am still confusing about your example. I tried the followin two examples. Why does sum return 14 ? Example 1: I carried out in order, not in procedure.
restart;
y:=i^2;
                                     2
                               y := i
[add,sum](y, i = 1..3);
                               [14, 14]

Example 2. I replace y:=i^2 to y:=i->i^2
proc()
   local y,i;
   y := i -> i^2;
   return [add, sum](y(i), i = 1..3);
 end proc();
                               [14, 14]
Yasuyuki NAKAMURA
Thank you for your comment. I think one of the good examples of difference between sum and add is as follows.
sum(i^2, i=1..n);
                          3          2
                   (n + 1)    (n + 1)
                   -------- - -------- + n/6 + 1/6
                      3          2
add(i^2, i=1..n);
Error, unable to execute add
However, I am still confusing about your example. I tried the followin two examples. Why does sum return 14 ? Example 1: I carried out in order, not in procedure.
restart;
y:=i^2;
                                     2
                               y := i
[add,sum](y, i = 1..3);
                               [14, 14]

Example 2. I replace y:=i^2 to y:=i->i^2
proc()
   local y,i;
   y := i -> i^2;
   return [add, sum](y(i), i = 1..3);
 end proc();
                               [14, 14]
Yasuyuki NAKAMURA
Yes, I completely agree with you. That's easiest way.
If you uncomment, the solution y(x) is substituded in deq2, because deq2 is defined using y(x). You can just replace y(x) with z(x), then you will get correct answer. Y. Nakamura
1 2 Page 2 of 2