Justin,


On 5/9/07, Justin C. Walker <[EMAIL PROTECTED]> wrote:
>
>
>
> On May 9, 2007, at 3:28 PM, Bobby Moretti wrote:
> > On 5/9/07, Justin C. Walker <[EMAIL PROTECTED]> wrote:
> >> On May 9, 2007, at 10:51 AM, Timothy Clemans wrote:
> >> I'm not sure these are failures, per se.  This may be a in issue with
> >> the Principal of Least Surprise :-}
> > This is definitely the case here. In every one of your examples,
> > Timothy,
> > the module is doing what it's supposed to. Sorry, the documentation
> > is kind
> > of lacking in the tutorial. I'm working on it right now. For now
> > I'd suggest
> > looking at the reference manual and especially the docstring for
> > sage.calculus.calculus.
>
> Manual?  Read?  :-}
>
> > Now,  by default, the symbols f, g, and most other single-character
> > symbols
> > are instances of SymbolicVariable. They are not callable. What you
> > really
> > are trying to do is make a formal function f, and a formal function
> > g, and
> > differentiate those. So to do that, you need to use the commands:
> >
> > sage: f = function('f')
> > sage: g = function('g')
> > sage: foo = diff(f(x) + g(x))
> > diff(g(x), x, 1) + diff(f(x), x, 1)
> >
> > and then you can do something like
> > sage: foo(f=sin, g=x^3)
> > cos(x) + 3*x^2
>
> Thanks for this.  Now, David's reply makes even more sense :-}  I
> cobbled up my response by communing with the ether, rather than
> actually reading something...
>
> > They are, but not as formal functions. They're defined as
> > SymbolicVariables.
>
> This is the part that I didn't really get until now.
>
> The calculus package is a great addition.  It seems to 'just work'.


Thanks :). We tried to emulate the feel of language-level literals for doing
symbolics.

I have a few concerns (cf. the Principal above), since this package
> is affected by what you change during a session, but overall, I like it.
>
Here's an example of what I'm hinting at:
>
> > sage: f=c*x
> > sage: diff(f,c)
> > x
> > sage: diff(f,x)
> > c
> > sage: c=3
> > sage: type(c)
> > <type 'sage.rings.integer.Integer'>
> > sage: type(f)
> > <class 'sage.calculus.calculus.SymbolicArithmetic'>
> > sage: diff(f,c)
> > .....
> > <type 'exceptions.ValueError'>: must supply an explicit variable
> > for an expression containing more than one variable
>
> so above, the substitution 'c -> 3' takes place at the call.  Below,
>
> > sage: diff(f,x)
> > c
> > sage:
>
> no substitution happens.  On the other hand:
>
> > sage: a=1
> > sage: g=a*x
> > sage: diff(g,x)
> > 1
> > sage:
>
> Justin


This is indeed a caveat of doing what we're doing. I too had my initial
doubts about this, but I think it works pretty well in practice. Can you
think of a way around this design?

Also, this same error could come up anywhere in SAGE. The following, while a
bit contrived, is nonetheless possible for a novice user to input:

sage: Integer  = 2
... input some code ...
...
...
... and later on:
sage: 2+2
Traceback (most recent call last):
<type 'exceptions.TypeError'>: 'sage.rings.integer.Integer' object is not
callable.

Thanks for the feedback. Keep it coming.

~Bobby

--
> Justin C. Walker, Curmudgeon-At-Large
> Director
> Institute for the Enhancement of the Director's Income
> --------
> "Weaseling out of things is what separates us from the animals.
>   Well, except the weasel."
>        - Homer J Simpson
> --------
>
>
>
> >
>


-- 
Bobby Moretti
[EMAIL PROTECTED]

--~--~---------~--~----~------------~-------~--~----~
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/sage-support
URLs: http://sage.math.washington.edu/sage/ and http://sage.scipy.org/sage/
-~----------~----~----~----~------~----~------~--~---

Reply via email to