Aaron S. Meurer a écrit : > Use cse() (common subexpression elimination). It will replace the > logs with dummy variables, which you can then see is a polynomial. > In [8]: cse((log(x) + 1)-((log(x)**3+7))) > Out[8]: ([(x0, log(x))], [-6 + x0 - x0**3]) > Why the ioutput is like this ? I've tried the folloowing : ========================================= import sympy
x = sympy.Symbol('x') x0 = sympy.Symbol('x0') y = sympy.Symbol('y') f = [ sympy.sympify('log(x)**2 + cos(y)*log(x)*(1+log(x))'), sympy.sympify('log(x)**2 + 2*x') ] for i in range(len(f)): test = sympy.cse(f[i]) print test ========================================= This gives : ----------------------------------------------- ([(x0, log(x))], [x0*(1 + x0)*cos(y) + x0**2]) ([], [2*x + log(x)**2]) ----------------------------------------------- FIRST QUESTION So why [(x0, log(x))] is not simply (x0, log(x)) ? Same question for [x0*(1 + x0)*cos(y) + x0**2] ? SECUND QUESTION Is there a way to know if expression is a polybom regarding to two or more functions like for example log(x)**2 + cos(y)*log(x)*(1+log(x)) ? Best regards. Christophe --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "sympy" group. To post to this group, send email to sympy@googlegroups.com To unsubscribe from this group, send email to sympy+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sympy?hl=en -~----------~----~----~----~------~----~------~--~---