Newbie question about quotation



This (much revisited) topic includes what to do with the first argument to
solve, plot, product, sum, and presumably integrate and limit, though for
some reason it doesn't come up so much in these last two.

The notation of quote is probably not quite right, and I think lambda
notation is a better vehicle, since it explicitly exhibits the bound/unbound
nature of variables.

That is,  if we write sum(lambda([i],1/i^2), 1, 10)  it is perfectly clear
what the index variable is, and its relationship to the summand, 1/i^2.
Other bindings of i are irrelevant.

If you do this:  f:lambda([i],1/i^2)
then sum(f,i,10) makes sense.


You could say that sum(expression, i, 1, 10)  means exactly the same as my
notation with

sum(lambda([i],expression),1,10).  But how many times is "expression"
evaluated?

I don't expect this change to be made to maxima, but people who have been
writing programs in a cleaner version of functional programming (e.g.
Scheme) may see this as a winner.  

NOt that it would remove the need for explanations entirely, just that the
explanations would be simpler.
RJF


> -----Original Message-----
> From: maxima-bounces at math.utexas.edu 
> [mailto:maxima-bounces at math.utexas.edu] On Behalf Of Stavros Macrakis
> Sent: Wednesday, December 27, 2006 10:08 AM
> To: Michel Van den Bergh
> Cc: maxima at math.utexas.edu
> Subject: Re: [Maxima] Newbie question about quotation
> 
> On 12/27/06, Michel Van den Bergh 
> <michel.vandenbergh at uhasselt.be> wrote:
> > Since levin_u_sum should behave like sum I think it is best 
> to define it as a macro....
> > For the arguments that should be evaluated I perform immediately
> > arg:ev(arg,nouns). Is
> > that the correct strategy?
> 
> If you look at the code for sum (asum.lisp, function dosum), you will
> see that it is messier than that, and it will be hard to reproduce the
> behavior in user code.  Moreover, it will likely lead to all sorts of
> bizarre behavior and bugs.  This is an area we've debated before among
> the Maxima developers and frankly I don't think the current behavior
> (though it is an improvement on previous behavior) is the last word.
> 
> Here are some fun cases which show the current behavior and how it
> interacts with Maxima's handling of conditionals, mathematical vs.
> programming functions, quoted expressions, and noun forms:
> 
> sum(print(i),i,1,n);  (interesting -- shows you the internal workings)
> 
> sum(i,i,1,3) => 6  (OK)
> j: 'i$
> sum(j,i,1,3) => 6 (OK, I guess) *
> 
> sum(max(i,2),i,1,3) => 7 (OK)
> sum(max(i,2),i,1,n) =>  'sum(max(i,2),i,1,n)  (OK)
> 
> sum(gcd(i,i+3),i,1,10) => 16 (OK)
> sum(gcd(i,i+3),i,1,n) => n  (oops, gcd is a programming function, not
> a math function like max)
> 
> sum( if oddp(i) then i else 0, i, 1, 5)     => 9   
> (consistent with (*) )
> sum( if oddp(j) then j else 0, i, 1, 5)     => 0   (not 
> consistent with (*) )
> sum( '(if oddp(j) then j else 0), i, 1, 5)  => 5 * (if oddp(j) then j
> else 0)  (!!)
> 
> ff(i):=if oddp(i) then i else 0$
> sum(ff(i),i,1,5) => 9 (consistent)
> sum(ff(j),i,1,5) => 0 (not consistent with (*) )
> 
> sum(diff(log(x),x,i),i,1,3) =>  1/x-1/x^2+2/x^3 (OK)
> sum(diff(log(x),x,j),i,1,3) =>
> 'diff(log(x),x,3)+'diff(log(x),x,2)+'diff(log(x),x,1) (??!!)
> 
> form: diff(log(x),x,i)$
> sum(foo,i,1,3) =>
> 'diff(log(x),x,3)+'diff(log(x),x,2)+'diff(log(x),x,1)  (so much for
> the auto substitution)
> 
> /* OK, let's try to avoid the noun-form problem */
> foo: '(diff(log(x),x,i));
> sum(foo,i,1,3) => 
> diff(log(x),x,3)+diff(log(x),x,2)+diff(log(x),x,1)  (hmm)
> 
> Hope you find this interesting,
> 
>               -s
> _______________________________________________
> Maxima mailing list
> Maxima at math.utexas.edu
> http://www.math.utexas.edu/mailman/listinfo/maxima
>