> sage: def h(x):
> ....: return y.subs(globals())
Oops, this is probably not what you want, becaus h(3) would not give
the expected result. This may be better:
sage: var('a b x')
(a, b, x)
sage: def h(x):
....: return y.subs(locals()).subs(globals())
....:
sage: a=2
sage: b=3
sage: h(x)
2*x^2 + 3*x
sage: var('a b x')
(a, b, x)
sage: h(4)
4*b + 16*a
sage: var('z')
z
sage: x=1
sage: h(z)
a*z^2 + b*z
Explanation: x is defined in the local name space of the function h.
Hence, subs(locals()) replaces x by z (and not by 1!) in the last
example. And then, the remaining contents of y are substitutet.
Yours
Simon
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---