I wrote a function to do the above (subsg(variable), see below), but I
would like to use it as a method notation (e.g. variable.subsg()).
Could anyone tell me how to do this?
Thanks a lot!
Stan
Here is the function:
def subsg(variable):
"""
Substitutes all definitions in the global name space for the
variables contained in 'variable' and returns the result.
INPUT:
variable -- a symbolic variable
EXAMPLE:
sage: var ('a b c')
a b c
sage: f = a*x
sage: a = 2*b
sage: b = c^2
sage: subsg(f)
2*c^2*x
"""
expr1 = variable
expr2 = variable.subs(globals())
while expr1 <> expr2:
expr1 = expr2
expr2 = expr1.subs(globals())
return expr1
--~--~---------~--~----~------------~-------~--~----~
To post to this group, send email to [email protected]
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://www.sagemath.org
-~----------~----~----~----~------~----~------~--~---