[Maxima] sum macro
robert.dodier at gmail.com
Fri Nov 7 11:36:27 CST 2008
On Fri, Nov 7, 2008 at 8:04 AM, Hal Finkel <hal.finkel at yale.edu> wrote:
> I am trying to figure out how to define a macro or function which will
> sum a given expression of a given variable from 1 to 4.
> This does not work:
> sum1to4(exp, var) ::= sum(exp, var, 1, 4);
Here's a different version that seems to work.
sum1to4 (exp, var) ::= buildq ([exp, var], sum (exp, var, 1, 4));
sum1to4 (x, x);
macroexpand (sum1to4 (x, x));
=> sum(x, x, 1, 4)
Unfortunately sum evaluates its arguments in an
idiosyncratic manner (in an effort to make sum work the way
people would expect it). I'll take most of the blame for that, since
I wrote the code for the current version of sum. Questions about
sum come up often enough that I'm regretting some of the
stuff I did; maybe it's time to reconsider.
More information about the Maxima