On Fri, 25 Jun 2010 07:53:00 -0700 Mike Witt <[email protected]> wrote:
> On 06/25/2010 06:07:02 AM, kcrisman wrote: > > Dear Mike, > > > > Just to follow up: > > > > There is further discussion at > > http://trac.sagemath.org/sage_trac/ticket/9329 > > if you are interested in saying exactly what sort of data structure > > would enable you to perform the simplifications you would like to > > without having to create a custom Maxima simplification routine. > > > > - kcrisman > > Well ... I can see how one might work one's way > through the expression, using the operator() and operands() > functions. And, I suppose, I can see how one could then build > up the equivalent expression, having modified one of the > operands in a certain way. So, I don't suppose that there is > actually any need for a custom data structure to do this. As far as I understand from your previous comments, a way to extract the exponential functions from the expression is all you need. You don't really need to walk through the tree. Here is one way to do this: sage: t = exp(x+y)*(x-y)*(exp(y)+exp(z-y)) sage: t (e^(-y + z) + e^y)*(x - y)*e^(x + y) sage: w = SR.wild() sage: t.find(exp(w)) [e^(-y + z), e^(x + y), e^y] You can then change the expressions in the given array and substitute new values for them: sage: t.subs({res[1]: sin(res[1].operands()[0])}) (e^(-y + z) + e^y)*(x - y)*sin(x + y) The .operands()[0] syntax is really cumbersome. We need a shortcut for this. I thought .op(0) worked for pynac expressions before we switched from the maxima backend. > Although ... I guess I'm still a bit confused as to why > this happens, even given the form of the exponential. > > sage: f = e^(2*I*pi*n*x - 2*I*pi*n) > sage: latex(f) > e^{\left(\left(2 I\right) \, \pi n x + \left(-2 I\right) \, \pi > n\right)} > > Still, I shouldn't really get +(-2i) right? This is a bug: http://trac.sagemath.org/sage_trac/ticket/9394 I'll fix this when I have time to work on pynac again. Cheers, Burcin -- 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
