Hi,

I tried:

In [18]: import sympy as sm

In [19]: a, b, c = sm.symbols('a, b, c')

In [20]: f = sm.Function('f')(a)

In [21]: expr = f + f.diff() - f.diff()/(f + f.diff()) - a*b + (a*b)**2

In [22]: sm.cse(expr)
Out[22]:
([(x0, f(a)), (x1, Derivative(x0, a)), (x2, x0 + x1)],
 [a**2*b**2 - a*b - x1/x2 + x2])

In [23]: sm.cse(expr, ignore=[f.diff()])
Out[23]:
([(x0, f(a)), (x1, Derivative(x0, a)), (x2, x0 + x1)],
 [a**2*b**2 - a*b - x1/x2 + x2])

The outcome I desire is:

([(x0, f(a)), (x1, Derivative(f(a), a)), (x2, x0 + x1)],
 [a**2*b**2 - a*b - x1/x2 + x2])

or:

([(x1, Derivative(f(a), a)), (x2, f(a) + x1)],
 [a**2*b**2 - a*b - x1/x2 + x2])

that is, that the functions or derivatives are treated like symbols.

The ignore flag is cse does not seem to do that.

Is there a way to use the pre/post processors in cse to do this?

Jason
moorepants.info
+01 530-601-9791

-- 
You received this message because you are subscribed to the Google Groups 
"sympy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sympy+unsubscr...@googlegroups.com.
To view this discussion visit 
https://groups.google.com/d/msgid/sympy/CAP7f1AjbULou2oaD3Ras8zUb78%3DM3vtorc%3DshSaG-EzMeOogFQ%40mail.gmail.com.

Reply via email to