Dear all,

I suppose that the below is not possible yet, so I am forwarding this
to sage-devel. I think it would be great if one was able to access
parts of an expression in a nested way, e.g.

expr1 = (a*x^3 + b*x)/(1 - Sqrt((1 - x)/(x - c))) + c/x

expr1[0]
(a*x^3 + b*x)/(1 - Sqrt((1 - x)/(x - c)))

expr1[1]
c/x

expr1[0][0]
(a*x^3 + b*x)

expr1[0][1]
(1 - Sqrt((1 - x)/(x - c)))

expr1[0][0][1]
a*x^3

etc.

One of the potential uses would be to find out where a div/0 error
happens. Currently one gets only an error message that the whole
expression failed, but it is very hard to find out which term caused
the failure.

Cheers
Stan


---------- Forwarded message ----------
From: Stan Schymanski <[email protected]>
Date: Jan 27, 11:00 am
Subject: accessing parts of expressions
To: sage-support


Dear all,

Before the switch to Pynac, it was possible to
accesspartsofexpressionsby indexing, e.g.
f = x^3 + 2*x^2 + 3*x
f[0]
x^3

Now I get the error message
TypeError: 'sage.symbolic.expression.Expression' object does not
support
indexing

Below, I pasted an example how Burcin wanted to implement indexing in
Pynac. Has this ever happened, or is there another way
ofaccessingpartsofexpressions? I am currently trying to extract the
terms in
the exponent of an expression, but I don't know how to do it easily.

Thanks for your help!

Stan

On Mar 21 2009, 7:32 pm, Burcin Erocal <[email protected]> wrote:



> It's in pynac already:

> sage: var('x,y',ns=1)
> (x, y)
> sage: f = expand((1+x+1/y)^10)
> sage: f.nargs()
> 66

> I could hook this up to __len__ as well, since __getitem__ lets you
> accesspartsof the expression. E.g.,

> sage: f[0]
> x^10
> sage: f[1]
> 10*x^9

> Cheers,
> Burcin

-- 
To post to this group, send an email to [email protected]
To unsubscribe from this group, send an email to 
[email protected]
For more options, visit this group at http://groups.google.com/group/sage-devel
URL: http://www.sagemath.org

Reply via email to