The difference between f(x=3) and f(3) of callable symbolic expression 'f'
f=x.derivative()
f(3) ----> error
f(x=3) ----> ok!
Dose f(x=3) call the method __call__?
f=x.derivative()
f(3) ----> error
f(x=3) ----> ok!
Dose f(x=3) call the method __call__?
Not surprised that f(3) is giving you an error. This form of substituting values in symbolic expressions has been deprecated for quite a while (well, over four years!). You must have got the warning at some point in your calculations. You should be using either f.subs(x=3) or f(x=3), i.e., specify the variable name explicitly.
Note that there are some idiosyncrasies while working with symbolic expressions. For instance the following will not complain even though f is not defined as a function of x:
sage: f = SR(1)
sage: f.subs(x=2)
1
Inspired by your answer. I finally found that if no keywords was specified, f(3) will call variables() method to make a dict to pass to sage.symbolic.expression.Expression.subs method. It is the subs method do the actual work. So when varibles() return None, the dict cannot be made, an error was raised. The code is in Line 683 of /devel/sage/sage/symbolic/ring.pyx
Please start posting anonymously - your entry will be published after you log in or create a new account.
Asked: 2013-03-14 11:06:52 +0100
Seen: 2,135 times
Last updated: Mar 14 '13
Using sage to derive symbolic finite difference approximations to differential equations.
A combination of commands partial_fraction(x) and coefficient(x,n)
Sage cannot simplify arccos, but can simplify arcsin?
Conversion of Differential Forms to a manipulable symbolic expression
Verifying that a symbolic expression in two variables is 0.
How to check if a symbolic expression is numerically evaluable?
Comparing even powers of $i$ with 1
How should I get symbolic expression of eigenvalues and eigenvectors of a real symmetric matrix 3x3
Copyright Sage, 2010. Some rights reserved under creative commons license. Content on this site is licensed under a Creative Commons Attribution Share Alike 3.0 license.