Re: beginner’s question with Maxi ma
Richard Fateman <[email protected]>
| Newsgroups | gmane.comp.mathematics.maxima.general |
|---|---|
| Message-ID | <CADB8Zm4jQpNd8Q_hK069c8GbfPf2VZY-G-eyeAkZ4xL+Fpxc3Q@mail.gmail.com> |
The definition of $sum, in source file asum.lisp is set up so that it does not evaluate its arguments universally. This makes sense since sum(f(i),i,a,b) should conventionally not evaluate i, or f(i) -- until it is examined somewhat, but should evaluate a and b. Here's the definition in Maxima. It calls dosum to do the real work. Dosum and its subroutines are responsible for a lot of effort. (defmspec $sum (l) (arg-count-check 4 l) (setq l (cdr l)) (dosum (car l) (cadr l) (meval (caddr l)) (meval (cadddr l)) t :evaluate-summand t)) If you want to put the first argument of a sum-like function at the end, so you say rsum(i,1,n,f(i)), then here's a definition for a reversed sum, rsum. [this ancient code is using original lisp names: (car '(a b c d)) is a. (cadddr '(a b c d)) is d.] (defmspec $rsum (l) (arg-count-check 4 l) (setq l (cdr l)) (dosum (cadddr l) (car l) (meval (cadr l)) (meval (caddr l)) t :evaluate-summand t)) Of course humans are very flexible and in most circumstances I would think that learning to use sum() should not be much of a burden. RJF On Sat, Aug 22, 2026 at 4:56 PM Stavros Macrakis <[email protected]> wrote: > I suspect that your macro problem is because of the peculiar behavior of > *sum*, but I haven't been able to track it down yet. Stay tuned. > > > On Sat, Aug 22, 2026, 17:39 <[email protected]> wrote: > >> > There are two separable parts to your computation. >> > 1. The syntax hacking >> > 2. The computation >> >> True enough. At the moment, my interpretation of how the ::= operator >> would work seems to have been faulty. >> >> > Good luck. >> >> Thank you for your advice and your well wishes. >> >> >> _______________________________________________ >> Maxima-discuss mailing list >> [email protected] >> https://lists.sourceforge.net/lists/listinfo/maxima-discuss >> > _______________________________________________ > Maxima-discuss mailing list > [email protected] > https://lists.sourceforge.net/lists/listinfo/maxima-discuss > _______________________________________________ Maxima-discuss mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/maxima-discuss