Hi,

I have some equations that use the Greek letter lambda in them, but
I'm having problems because lambda is a keyword in python, and at some
points the two collide. For example:

sage: l = var("lambda")
sage: t = var("theta")
sage: e1 = t == l^2
sage: e2 = e1.solve(l)
sage: e1
theta == lambda^2
sage: e2
[lambda == -sqrt(theta), lambda == sqrt(theta)]

# Subs for theta (have to use "theta" and not "t")

sage: (e2[0].subs(theta = 5), e2[1].subs(theta = 5))
(lambda == -sqrt(5), lambda == sqrt(5))

# Subs for lambda (have to use "lambda", but that's a keyword)

sage: e1.subs(lambda = 3)
------------------------------------------------------------
   File "<ipython console>", line 1
     e1.subs(lambda = Integer(3))
                    ^
SyntaxError: invalid syntax

For some reason I don't understand, whilst .solve() will take the
symbolic variable as a parameter to solve for (e.g. "t"), .subs()
requires the variable name (e.g. "theta"). Often these are the same,
but not always, and in the case where I have a variable "lambda" it
causes a syntax error.

Any way to get around this? Is this the intended syntax for subs(), as
it seems a little confused?
--~--~---------~--~----~------------~-------~--~----~
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
URLs: http://www.sagemath.org
-~----------~----~----~----~------~----~------~--~---

Reply via email to