Re: Generation of polynomials
- To: mathgroup at smc.vnet.net
- Subject: [mg113042] Re: Generation of polynomials
- From: Andrzej Kozlowski <akoz at mimuw.edu.pl>
- Date: Tue, 12 Oct 2010 04:24:24 -0400 (EDT)
"Simplest" is arguable. Performance is measurable.
poly[m_] :=
FromCoefficientRules[
Thread[Flatten[Table[{i, n - i}, {n, 0, m}, {i, 0, n}], 1] ->
1], {x, y}];
f[n_] := (Expand[
Normal[Series[
Product[Sum[(q*t)^i, {i, 0, n}], {q, {x, y}}], {t, 0, n}]]]) /.
t -> 1
Table[poly[i], {i, 1, 100}]; // Timing
{1.51514,Null}
Table[f[i], {i, 1, 100}]; // Timing
{4.94317,Null}
Andrzej Kozlowski
On 11 Oct 2010, at 11:16, Richard Fateman wrote:
>
>
> f[n_] := (Expand[Normal[
> Series[Product[Sum[(q*t)^i, {i, 0, n}], {q , {x, y}}], {t, 0,
> n}]]]) /. t -> 1
>
>
> from which one can generate polynomials e.g. f[1],f[2],f[3].
>
> Now this does not generate the same display as given since Mathematica
> has a different ordering of terms in mind.
>
> Sometimes the simplest way to produce a mathematical expression is to do
> mathematics, not hacking lists, tables, etc.
>
>
>