William Stein wrote:
> On Wednesday, August 10, 2016, Todd Zimmerman
> <[email protected] <mailto:[email protected]>> wrote:
> 
>     I assumed that SageMath converts the functions into symbolic
>     expressions.
>     If I enter the following it will work:
> 
> 
>     f=lambda x: x*sin(x)
>     diff(f(x),x)
> 
> 
> f is a python function 
> 
> f(x) is a symbolic expression - the result of calling f with input x.

And that only works "out of the box" because x (in the global
environment) is already (pre-)defined to be a symbolic variable, hence
from Python's point of view has a value assigned such that f(x) can be
evaluated before calling diff().

I.e.,

diff(g(y),y)

won't work unless you also define y to be a symbolic variable (no matter
what formal parameter name you use in the Python function g).


-leif


>     def g(x):
>         return x*sin(x)
>         
>     diff(g(x),x)
> 
>     On Wednesday, August 10, 2016 at 4:01:09 PM UTC-5, Harald Schilly wrote:
> 
>         On Wed, Aug 10, 2016 at 10:46 PM, Todd Zimmerman
>         <[email protected]> wrote:
>         >  You can integrate and differentiate both types of functions
>         in SageMath as
>         > well as use them for solving differential equations.
> 
>         So, can you copy/paste us an example? It does work, if that small
>         python-function is evaluated and returns a symbolic expression.
>         That
>         will work, I don't doubt that, but the python-function in itself is
>         then no longer part of this. Key for understanding this is, that
>         nested functions are evaluated from the inside out and there is no
>         direct concept of lazyness in Python. In some situations, it might
>         look like that, so I fully understand that this is confusing.
> 
>         -- h


-- 
You received this message because you are subscribed to the Google Groups 
"sage-support" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/sage-support.
For more options, visit https://groups.google.com/d/optout.

Reply via email to