Re: Factorising polynomials
- To: mathgroup at smc.vnet.net
- Subject: [mg63975] Re: [mg63970] Factorising polynomials
- From: Daniel Lichtblau <danl at wolfram.com>
- Date: Thu, 26 Jan 2006 03:42:56 -0500 (EST)
- References: <200601251346.IAA25881@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
Tony King wrote: > I am trying to find the number of irreducible polynomials over the integers > in the factorisation of x^n+1 > > I used the following code > > data = Factor[x^# + 1] & /@ Range[6] > > Followed by > > Table[Length[data[[k]]], {k, 1, 6}] > > And Mathematica returned {2,2,2,2,2,2}, one assumes because it was counting > terms such as 1+x as 2 terms. However, when the number of factors exceeds 1, > Mathematica returns them as a list and counts them correctly. The output > that I was looking for should have been {1,1,2,1,2,2}. > > Does anyone have any ideas how I might modify the above code so that it > returns the correct number of terms > > Many thanks > > Tony You'll want to use FactorList. It returns a list of factors (no surprise), the first of which is always numeric. The rest are pairs of the form {factor,power}. To process this for your intended purpose you would drop the numeric factor and sum the powers of the remaining ones. This might be done as below. In[10]:= InputForm[data = FactorList[x^# + 1] & /@ Range[6]] Out[10]//InputForm= {{{1, 1}, {1 + x, 1}}, {{1, 1}, {1 + x^2, 1}}, {{1, 1}, {1 + x, 1}, {1 - x + x^2, 1}}, {{1, 1}, {1 + x^4, 1}}, {{1, 1}, {1 + x, 1}, {1 - x + x^2 - x^3 + x^4, 1}}, {{1, 1}, {1 + x^2, 1}, {1 - x^2 + x^4, 1}}} In[11]:= Map[Apply[Plus,Drop[#,1]]&, Map[Last,data,{2}]] Out[11]= {1, 1, 2, 1, 2, 2} Daniel Lichtblau Wolfram Research
- References:
- Factorising polynomials
- From: "Tony King" <mathstutoring@ntlworld.com>
- Factorising polynomials