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