On Jul 29, 2009, at 4:10 PM, smichr wrote:
> > > > On Jul 29, 12:06 am, wflynny <[email protected]> wrote: >> While finding eigenvalues for a matrix of mine, I ran into a >> polynomial decompose error. It seems that when a polynomial has >> both a >> cubic and quartic term and coefficients that consist of symbols, >> factortools.py runs into trouble. To simplify the error, here is some >> test code that throws the same error: >> >> -------------------------- >> import sympy as sp >> >> x = sp.Symbol('x') >> z = sp.Symbol('z') >> g = cos(z)*x**4 + x**3 + 1 >> res = sp.solve(g, x) >> print res >> -------------------------- >> > There's no simple solution to your equation other than as a polynomial > and as you found out, the factoring routine doesn't like terms with > functions (or numbersymbols or exponents with rational exponents) > >> >> It seems to only fail when there is a quartic term, cubic term and >> constant term. For example: >> >> g=cos(z)*x**4+x**3 >> res=sp.solve(g,x) >> print res >> > > Here, there is a solution without resorting to a polynomial, per se: > x**3(cos(z)*x+1) the x**3 has 0 as a solution and the linear term > doesn't need factoring so there is no problem. > > >> g=cos(z)*x**4+1 > > Same thing here...we just have x**4 = -1/cos(z) so again there is no > call to factor. > > At present, you just have to work around this. cse doesn't help in > your case because the cos(z) doesn't appear multiple times so it > doesn't flag it for replacement. For my own work I've made a routine > that substitutes offending terms with temporary variables. Except for > the exp() function, most offending terms won't factor anyway. Ideally, > factor would handle this. (See also issue 1469 > http://code.google.com/p/sympy/issues/detail?id=1469&q=decompose). Would your routine help any for the expression in issue 1562? simplify() doesn't do anything to it because Poly.cancel() doesn't cancel the sin and cos terms. The same for factor. Aaron Meurer > > /c > > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "sympy" group. 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/sympy?hl=en -~----------~----~----~----~------~----~------~--~---
