Thanks.

I think I got it.

On Sun, Nov 29, 2009 at 12:48 PM, Harald Schilly
<harald.schi...@gmail.com>wrote:

> On Nov 29, 10:50 am, Yotam Avital <yota...@gmail.com> wrote:
> >
> > 1. def f(x): return x^2
>
> That's a pure Python function, it's in some way "universal" but you
> cannot derivate it.
>
> sage: type(f)
> <type 'function'>
>
> >
> > 2. f(x) = x^2
>
> That's preparsed and actually this:
> sage: preparse('f(x) = x^2')
> '__tmp__=var("x"); f = symbolic_expression(x**Integer(2)).function(x)'
>
> That's why it is the same as
>
> >
> > 3. x = var('x')
> > f(x) = x^2
> >
> sage: type(f)
> <type 'sage.symbolic.expression.Expression'>
>
> That's an expression and you can evaluate it, that's how a
> mathematical function works.
>
> You can also do things like
> sage: f.derivative()
> x |--> 2*x
>
> Note: There is even more, read the help of fast_callable?
>
> i.e.
> sage: timeit('f(2.2)')
> 625 loops, best of 3: 134 µs per loop
>
> sage: ffast = fast_callable(f,vars=[x], domain=float)
> sage: timeit('ffast(2.2)')
> 625 loops, best of 3: 15.2 µs per loop
>
>
> H
>
> --
> To post to this group, send email to sage-support@googlegroups.com
> To unsubscribe from this group, send email to
> sage-support-unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/sage-support
> URL: http://www.sagemath.org

-- 
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to 
sage-support-unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org

Reply via email to