On Sep 24, 7:17 am, Julius <[email protected]> wrote:
> Hi list,
>
> I wonder if there is any command similar to subsop in maple
> (www.maplesoft.com/support/help/Maple/view.aspx?path=subsop).
> There is an operands(), but I don't see how substitutions can be made
> from it.
>
> Antonio

This is all completely a guess:

Given a symbolic expression (call it "a"), the two methods
"a.operands()" and "a.operator()" will provide enough information to
reconstruct "a" itself.

More specifically, "a.operands()" returns a list of sub-expression of
"a", where if the function returned by "a.operand()" were applied to
the elements of this list, it would create a symbolic expression that
is equivalent to "a" itself.

Example 1:

sage: a = x^2 + 2*x - 15

sage: a.operands()
[x^2, 2*x, -15]

sage: a.operator()
<built-in function add>

Example 2:

sage: a = x^2 / (3*(x+1)) ^ 4

sage: a.operands()
[(x + 1)^(-4), x^2, 1/81]

sage: a.operator()
<built-in function mul>

Given this knowledge, operator substitution might be accomplished by
constructing a new symbolic expression from the old one. I'm not quite
sure how this would work, though.

I think there's a better way to do what you want (navigating an
expression tree?), but I don't know what it is called in Sage or even
whether it exists...

Someone needs to come by to provide a better answer.

-- Tianwei

-- 
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

Reply via email to