[Date Index]
[Thread Index]
[Author Index]
Re: PolynomialQuotient slow
*To*: mathgroup at smc.vnet.net
*Subject*: [mg129322] Re: PolynomialQuotient slow
*From*: danl at wolfram.com
*Date*: Wed, 2 Jan 2013 21:16:07 -0500 (EST)
*Delivered-to*: l-mathgroup@mail-archive0.wolfram.com
*Delivered-to*: l-mathgroup@wolfram.com
*Delivered-to*: mathgroup-newout@smc.vnet.net
*Delivered-to*: mathgroup-newsend@smc.vnet.net
*References*: <kbtbip$cph$1@smc.vnet.net>
On Monday, December 31, 2012 6:45:13 PM UTC-6, Roman Pearce wrote:
> Something seems wrong here with the performance of PolynomialQuotient. Is there blowup because the leading coefficient in x is a polynomial? Also it seems slower in Mathematica 9 versus v8.
>
>
>
> d = 5
>
> f = Expand[ ((1+x)*(1+y)*(1+z))^d + 1 ];
>
> g = Expand[ ((1-x)*(1-y)*(1-z))^d + 1 ];
>
> AbsoluteTiming[ p = Expand[ f g ]; ]
>
> AbsoluteTiming[ q = PolynomialQuotient[p, f, x]; ]
>
> AbsoluteTiming[ P = Factor[ p ]; ]
>
>
>
> What is the preferred method for (exact) division of polynomials? On this example I tried Cancel[ p/f ] and it works fine, but on other problems it is faster to use PolynomialQuotient. Suggestions?
Hi Roman,
Yes, PolynomialQuotient is slow. It is, as you suspected, intrinsically "univariate" and thus does not work in a fraction-free manner when coefficients are themselves polynomials.
Here are some possibilities for improved speed.
(1) Use PolynomialReduce (in the sense of computing Groebner bases).
(2) Use PolynomialMod, as that seems better able to find a remainder quickly. Then subtract that from the dividend and Together the result over the divisor. If you know the division is exact to begin (as in this example) with you can skip the PolynomialMod step.
(3) Use a certain (undocumented) internal function.
Here are the three approaches.
In[51]:= AbsoluteTiming[{q2, r} =
PolynomialReduce[p, f, Variables[{p, f}]]; q2 = First[q2];]
Out[51]= {0.052611, Null}
In[54]:= AbsoluteTiming[r = PolynomialMod[p, f];
q3 = Together[(p - r)/f];]
Out[54]= {0.086507, Null}
In[59]:= AbsoluteTiming[q4 = Algebra`IPExactQuotient[p, f];]
Out[59]= {0.013560, Null}
In[69]:= Together[q] === q2 === q3 === q4
Out[69]= True
Regards,
Daniel
Prev by Date:
**NDSolve is not deterministic in its solutions??**
Next by Date:
**How to get the Real and Imaginary part of an expression**
Previous by thread:
**NDSolve is not deterministic in its solutions??**
Next by thread:
**Re: PolynomialQuotient slow**
| |