On Jul 29, 12:06 am, wflynny <wfly...@gmail.com> 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).
/c
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---