Re: Generation of polynomials

• To: mathgroup at smc.vnet.net
• Subject: [mg113086] Re: Generation of polynomials
• From: Richard Fateman <fateman at cs.berkeley.edu>
• Date: Tue, 12 Oct 2010 13:50:17 -0400 (EDT)
• References: <i915vd\$inm\$1@smc.vnet.net>

```On 10/12/2010 1:24 AM, Andrzej Kozlowski wrote:
> "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
>
>
>
...

Leave out the Expand[]  from f.

It is then 2 times faster than your "poly"  program, on my computer.

So your program is not only harder to read, it is considerably
slower.  (Another, shorter and slightly faster, program was
sent to me and Andrzej in email; the author may choose to post
that too :)  )

```

• Prev by Date: Re: something nice I found today, return multiple values from a function
• Next by Date: Re: Graphics3D. How to join random points with a single line
• Previous by thread: Re: Generation of polynomials
• Next by thread: Re: Generation of polynomials