Hi,
I am trying to extract part of a symbolic expression.
The expression -- an eigenvalue of a matrix -- has the form
A + B*sqrt(C)
where A, B and C are themselves complicated symbolic expressions.
I wish to extract the subexpression C from this to test where the
eigenvalues change type (where C==0).
By using introspection and the help (both excellent features!), I
stumbled across one possible solution, using iterator. But it's very
fussy: I have to do something like:
var('A B C')
eigval = A + B*sqrt(C)
terms = list( eigval.iterator() )
first = terms[0]
terms2 = list(first.iterator())
desired = list(terms2[1].iterator())[0]
to extract the part I want into the variable "desired"
To me it would seem more intuitive to use indexing directly on the
expression, to be able to do something like
eigval[0][1][0]
which is similar to what is available in Mathematica, for example, but
this doesn't work, since apparently indexing is not defined for
symbolic expressions. (Couldn't it be defined to have exactly this
functionality?)
So the question finally is: am I reinventing the wheel here? Is there
a simple way to do this?
Thanks and best wishes,
David.
--
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
URL: http://www.sagemath.org