Hi, On Sat, Aug 07, 2010 at 04:57:18AM -0700, smichr wrote: > I've asked about factoring before but am just jotting down some > observations that I've made in the last few days. I was talking with > Aaron the other day about a routine and suggested he should use > factoring. He says, "that's gong to be expensive." I got to thinking. > > There are really 3 (at least) types of factoring: > > 1) factoring that can be done by inspection of factors. I call this > separation. Pursued recursively, it leads to a possible separation of > variables: > > x + x*y + a + a*y > x*(1 + y) + a*(1 + y) > (x+a)*(1+y) > > This should be very fast factoring since you are looking for existing > factors, not extractable factors. separatevars should be re-written to > not use factor since that expensive operation is not needed for this. > > 2) factoring that can be done be extraction of common bases: > > x + x**2 > x*(1 + x) > > This should be pretty fast since you have the factor candidates > already visible but you need to see if they can be extracted from > other bases. This sort of factoring is available through terms_gcd > > 3) factoring that can be done only by identifying potential factors > and doing trial division. > > x**2 - 1 > (x+1)*(x-1) > > This is available through factor, but perhaps factor should try the > other simpler methods before resorting to level 3 factoring. >
I implemented a simple symbolic factor() function on polys11, e.g.: In [1]: factor((x**2 + 4*x + 4)**10000000/(x**2 + 1), extension=I) Out[1]: 20000000 (2 + x) ─────────────── (x + ⅈ)⋅(x - ⅈ) Previously one had to use frac=True flag and it hanged anyway due to the huge exponent (really due to expand()). However, this case: factor((x + y)**100*z**2 + 2*(x + y)**100*z + (x + y)**100) is still not handled properly (hangs). > -- > You received this message because you are subscribed to the Google Groups > "sympy-patches" group. > To post to this group, send email to sympy-patc...@googlegroups.com. > To unsubscribe from this group, send email to > sympy-patches+unsubscr...@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/sympy-patches?hl=en. > -- Mateusz
signature.asc
Description: This is a digitally signed message part