On 04/22/2010 04:13 PM, pallab wrote:
Sorry I did not make it clear. I just defined S as
var('S')
At=S*x
S=4
Here is a session in Sage that I hope illustrates the difference between
Mathematica and Sage in this regard. In Sage and python, the things
that you type are names, and they point to objects. In the example
above, it's confusing because there is a name "S" and a variable object
which prints out "S".
sage: S=var('my_variable')
sage: S
my_variable
Above, I've created a variable object that prints itself out as
"my_variable" and I've given it the name "S". That means when I type
"S" in Sage, I'm referring to the variable object.
sage: At=S*x
sage: At
my_variable*x
Now I've assigned At to be the variable object that the name "S" points
to, multiplied by the variable object that the name "x" points to.
sage: S=4
sage: S
4
Now I've made the name "S" point to something different, like the number 4.
sage: At
my_variable*x
But notice that since At was a variable object multiplied by another
variable object, it doesn't care that I've switched the name "S" to
point to something different.
However, I can substitute in a value for the variable object "my_variable":
sage: At(my_variable=3)
3*x
That's why you need to do something like A(S=3) in your original code to
get 3*x.
Thanks,
Jason
--
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