I have been using
seq(coeff(series( f(x), x, n+1), x, n), n = 0 .. 40);
to obtain the coefficients of series expansions. It seems efficient enough until some comparisons are made with other platforms.
For example: the script
seq(coeff(series(1/mul(1-x^j, j = 1 .. 11), x, n+1), x, n), n = 0 .. 70);
takes 0.134 seconds to calculate in Maple but the same script in Mathematica
CoefficientList[Series[1/Product[1 - x^j, {j, 1, 11}], {x, 0, 70}], x]
takes 0.00739489 seconds. Pari has a similar fast calculation time.
The question becomes: Is there a faster, or more efficient, method to calculate the coefficients of a series?
This takes approximately 0.005 sec in my Maple 2019:
These two steps take (in total) approximately 0.002 sec in my Maple 2019:
The relative performance of the above two techniques may vary as the degree gets very large. If I recall correctly the
CoefficientListprocedure was intended for doing a single pass through the structure, and thus may scale up better than the approach of callingcoeffmany times.On such a small example as yours, measuring the performance of this operation is delicate -- you have to be careful not to trick yourself.
For example, you may well wish to suppress printing of the results, because the computations are so very fast here. You don't really want a major portion of your measurements to reflect the time taken for the programs' interfaces to render/print/pretty-print these results, do you?
And, as James mentioned, you may want to avoid inadvertent duplicate re-creation of the series 70 times. Even deliberately doing such duplication in all those programs may be problematic for a comparison, as the programs may differ in how they each memoize parts of the computation.
Also, how will you ensure that none of these mentioned program are not (by chance) doing a garbage-collection (memory management act) during your requested computation. That might conceivably consume as much time as your actual computation.
And what about initialization of the commands in question? Are you deliberately timing how long the first such computation takes in a fresh session, or how long such computations take on average (after all relevant functions are loaded into memory)?
Just to illustrate how delicate such a timing measurement may be for such a small and quick computation, compare these: