4

The following two pieces of maxima code should be equivalent:

sum(x[i], i, 1, 2);
ev(%, x[1] = 5, x[2] = 3);

and:

sum(x[i], i, 1, n);
ev(%, n = 2, x[1] = 5, x[2] = 3);

In the first case, maxima knows to evaluate the expression to 8. In the second case, it doesn't simplify and leaves me with a symbolic summation of x[i] for i = 1 to 2.

Why is it that maxima is unable to recognize the second expression as being the same as the first?

Short of hardcoding the answer (as in the first piece of code), how do I get maxima to fully evaluate a summation with indexed variables when evaluating a summation where the upper limit is specified later?

daj
  • 6,962
  • 9
  • 45
  • 79
  • there is a community under proposal..may be you would like to [join](http://area51.stackexchange.com/proposals/66233/maxima) – Pankaj Sejwal Mar 15 '14 at 17:12
  • thanks I don't think this is a good idea though. The community is too small and traffic would be too low. # of downloads isn't a good measure of the active userbase. I wouldn't be surprised if most users use of maxima was fairly shallow (solve a toy equation and leave it untouched for a year or uninstall it). – daj Mar 18 '14 at 02:07
  • its a complete CAS and we can always explore more and more and develop it over the time. But it would be good to share and learn at one place. I have used Mathematica and Maxima does almost everything that mathematica does. – Pankaj Sejwal Mar 18 '14 at 06:21
  • I agree, I am a fan of maxima. i just don't think it has a big enough community that it would sustain a q&a independent of stackoverflow – daj Mar 19 '14 at 02:38
  • First lets give it a try, my statistics were wrong and total number of downloads is 3,019,298. Come there, post a few question and upvote a few. – Pankaj Sejwal Mar 19 '14 at 06:12

1 Answers1

2

sum is in the noun form (see a leading % in the lisp expression)

(%i76) expr: sum(x[i], i, 1, n);
                                    n
                                   ====
                                   \
(%o76)                              >    x
                                   /      i
                                   ====
                                   i = 1
(%i77) :lisp $expr

((%SUM SIMP) (($X SIMP ARRAY) $I) $I 1 $N)

You need to tell ev to evaluate nouns

(%i77) ev(expr, n = 2, x[1] = 5, x[2] = 3, nouns);
(%o77)                              x  + x
                                     2    1

and request an extra post-evaluation

(%i78) ev(expr, n = 2, x[1] = 5, x[2] = 3, nouns, eval);
(%o78)                                 8
slitvinov
  • 5,693
  • 20
  • 31
  • I found simplify_sum() or simpsum : true also works, I'm guessing this is what it's doing under the hood. – daj Mar 01 '14 at 18:40