On Wed, 06 Dec 2006 09:54:47 -0800, David Harvey  
<[EMAIL PROTECTED]> wrote:
> On Dec 6, 2006, at 12:39 PM, Robert Bradshaw wrote:
>
>> The main difficulty with def/lamdba is how would one do calculus with
>> one of these functions?
>
> Yeah, like if def f(x): ... and def g(x): ... then how do I write f + g?

ANSWER 1:

def h(x):
     return f(x) + g(x)

ANSWER 2: You don't.  And there is no compelling reason that you should.

My impression is that even in Mathematica/Maple if you define an  
evaluatable
function (a "substitution rule), then you can't really do arithmetic and
calculus with it either:

In[13]:= f[x_] := x^2 + 3;
In[14]:= f[2]
Out[14]= 7
In[15]:= (f+f)[2]
Out[15]= (2 f)[2]

If you want to do arithmetic and calculus with functions, you define them
as formal symbolic objects, and you're good to go.  If you need to evaluate
them you use "subs" in maple (for subtitution), "ev" in Maxima (for  
basically
the same thing), "subst" in pari (for the same thing), and I *still* don't
know what in Mathematica, but I'm sure there's some standard funny syntax.

It is very clarifying to distinguish between functions that one calls(in  
the
sense of computer programs) and symbolic functions that are elements of  
some
formal algebra.   This is what is done in Maple/Mathematica/Maxima and  
PARI,
and I don't see why SAGE should do things differently, given that this  
approach
has been very successful.  Average beginning students can
quickly do problems in calculus books using Maple/Mathematica... so their
approach is very likely practicle.  Also, my impression is that among
us Alex C. is one of the only people who has actual signficant experience  
with
this sort of computer algebra/calculus, and he is all for just using  
Python's
def and lambda for defining functions.

  -- 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/
-~----------~----~----~----~------~----~------~--~---

Reply via email to