OK, I've given this a lot of thought and I agree that making f=sin(x)
illegal is bad, especially with regard to plotting, etc.. Also, I
understand (at least to some degree) your aversion to using the
preprocessor.
I think it is worth noting that there is a difference in both Maple
and Mathematica between "functions" and "expressions." Functions can
be evaluated at values, expressions are evaluated in a context. I
have been thinking about things in terms of functions, but I guess
everyone else has been thinking in terms of expressions. Here is what
I see of the difference:
|\^/| Maple 10 (IBM INTEL LINUX)
._|\| |/|_. Copyright (c) Maplesoft, a division of Waterloo Maple
Inc. 2005
\ MAPLE / All rights reserved. Maple is a trademark of
<____ ____> Waterloo Maple Inc.
| Type ? for help.
> f := sin(x)+y: # as an
expression
> f(3,4);
sin(x)(3, 4) + y(3, 4) #
this seems so counter-intuitive
> x:=3:
> f;
sin(3) + y #
now has 3 plugged in
> f := (x,y) -> sin(x)+y: # as a function, I
think the syntax isn't the easiest to learn/guess but makes sense.
Can even be used as an argument to plot.
> f(3,4);
sin(3) + 4
> x := 3: #
f is not changed here
> f(1,2);
sin(1) + 2
The same thing happens in Mathematica
Mathematica 5.2 for Linux x86 (64 bit)
Copyright 1988-2005 Wolfram Research, Inc.
-- Motif graphics initialized --
In[1]:= f := Sin[x] + y; # this is an
expression
In[2]:= f[3,4]
Out[2]= (y + Sin[x])[3, 4] # what does this mean?
In[3]:= x := 1
In[4]:= f
Out[4]= y + Sin[1] # 1 is now plugged
in for x
In[5]:= f[x_, y_] := Sin[x] + y;
SetDelayed::write: Tag Plus in (y + Sin[1])[x_, y_] is
Protected. # clearly, I'm not just re_assigning f
In[6]:= g[x_,y_] := Sin[x] + y # this is essentially the
same as my original proposal, except for the _'s
In[7]:= g[3,4]
Out[7]= 4 + Sin[3]
I guess I'm fine with the expression paradigm (where would they live/
what would their parent be?), but I think it would be very nice to
make them callable (which I guess would be abuse of notation).
Argument naming/order (and, in some cases perhaps number) is the big
difficulty here (and I think just forcing alphabetical is not a good
solution (with polynomials the order is defined at ring creation
time)). Either that or make substations very easy and natural.
I also have to say that defining all 52 1-letter variables on startup
seems less than ideal (they can get easily overwritten, use variables
like "theta" too, and it just seems like a hack to say "we'll define
all of them in case any get used") but it seems it's better than
requiring the preparser.
- Robert
On Dec 5, 2006, at 9:29 AM, William Stein wrote:
> You know, honestly, the problem of how to express do Calculus with
> a computer algebra system is not exactly a new one. It's been
> to some degree completely and totally solved by Mathematica.
> Maybe the real discussion we should be having is how can we
> make a basic interface to SAGE for doing calculus that is very similar
> to mathematica's? Only if there is a strong technical reason why
> something is not possible in Python, should we even be having these
> discussions. Basically, before we continue going along the route
> suggested by you and Robert, I would like a very good justification
> for why Mathematica/Maple got it wrong (despite millions of users
> and two decades of polishing and work). Otherwise, I don't understand
> why we don't just do something similar to Mathematica. This reduces
> the learning curve for some people a lot, and means we spend time
> solving problems instead of coming up with a new design that is
> probably
> wrong anyways, then spending a lot of time testing it, only to find
> that it really doesn't work for various reasons.
>
> What do you think Bobby?
>
> We are building the car, not reinventing the wheel.
>
> -- William
>
> >
--~--~---------~--~----~------------~-------~--~----~
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/sage-devel
URLs: http://sage.scipy.org/sage/ and http://modular.math.washington.edu/sage/
-~----------~----~----~----~------~----~------~--~---