4
$\begingroup$

I have a function defined explicitly as a power series: $$\sum_{n=0}^\infty{T_n}\frac{x^n}{n!}=\frac{\frac{x^3}{3!}}{e^x-1-x-\frac{x^2}{2!}}$$ and I would like to extract the coefficients $T_k$ as $k$ runs over the whole numbers. I know there is a coefficient function and a table function which I think would probably be the easiest. Taking this one step further, can I extract just the denominator of each coefficient?

If I define $t[n]=\frac{\frac{x^3}{3!}}{e^x-1-x-\frac{x^2}{2!}}$, should I just use seriescoefficient and set my bounds as say run it over $n=0..25$

$\endgroup$

3 Answers 3

6
$\begingroup$

Here's something which returns the denominators. Is this what you are looking for?

Denominator[(#! SeriesCoefficient[(x^3/6)/(
      E^x - 1 - x - x^2/2), {x, 0, #}] & /@ Range[0, 25])]

which returns

{1, 4, 40, 160, 5600, 896, 19200, 76800, 14784000, 19712000, \
512512000, 186368000, 19568640000, 6021120000, 20889600000, \
7798784000, 71310131200000, 16778854400000, 503365632000000, \
15138816000000, 221798793216000000, 6035341312000000, \
38406717440000000, 6679429120000000, 3857370316800000000, \
24687170027520000}
$\endgroup$
5
  • $\begingroup$ yes, my only issue is I'm looking explicitly for the coefficients $T_k$. The denominators here include the factorial term inherent in the power series. For example, $T_2=\frac{1}{40}$, but the sequence above has $\frac{1}{40}\frac{1}{2!}$... $\endgroup$ Commented Oct 18, 2014 at 13:14
  • $\begingroup$ @ybeltukov: D'oh! $\endgroup$ Commented Oct 18, 2014 at 13:22
  • $\begingroup$ @Eleven-Eleven: Fixed it (I think?). $\endgroup$ Commented Oct 18, 2014 at 13:23
  • $\begingroup$ That looks more like it to me...Thank you for the help! $\endgroup$ Commented Oct 18, 2014 at 13:27
  • 1
    $\begingroup$ The #! is really jarring to those of us used to the unix shell. $\endgroup$
    – Igor Rivin
    Commented Oct 18, 2014 at 20:11
4
$\begingroup$

Use SeriesCoefficient.

Let

g[x_] := x^3/3!/(Exp[x] - 1 - 1 - x^2/2!)

Then calculate the power series up to power m

s[m_] := Series[g[x], {x, 0, m}]

Finally, your coefficients are

t[n_]:=SeriesCoefficient[s[n], n] n!

Example

Table[t[n], {n, 0, 10}]

(* {0, 0, 0, -1, -4, -20, -140, -1155, -10696, -111132, -1285320} *)

Regards, Wolfgang

$\endgroup$
1
  • 1
    $\begingroup$ I noticed the numbers are not right. I'm thinking it is due to your definition of the function: in the denominator you have Exp{x}-1-1-x^2/2! instead of Exp{x}-1-x-x^2/2!. That would probably fix it. $\endgroup$ Commented Oct 20, 2014 at 2:09
1
$\begingroup$

Since SeriesData is a documented data structure, it seems suitable to take advantage of it. We can calculate the series just once, which in this case will be more than 40 times faster than DumpsterDoofus's method and 12 times faster than Dr. Wolgang Hintze's. (It's tricky to time, since Series/SeriesData cache their results to make subsequent calls a bit faster. I had forgotten that. In this comparison each timing was made with a fresh kernel. If the maximum power goes up to 100, the ratios of the times decreases to 12 and 2.5 times, respective, although the absolute time difference increases.)

With[{s = Series[(x^3/6)/(E^x - 1 - x - x^2/2), {x, 0, 25}]},
 PadRight[s[[3]], -s[[4]] + s[[5]]] Range[s[[4]], s[[5]] - 1]! // Denominator
 ]
(* {1, 4, 40, 160, ..., 24687170027520000} *)

SeriesData has the structure

SeriesData[x, x0, coefficients, min, max, den]

where x is the variable, x0 is the center, min and max are the limits on the powers, and den is the denominator in fractional power series. The code above assumes the usual sort of power series with den == 1. The coefficients are obtained with s[[3]]. The range of powers is s[[4]] to s[[5]]. One thing to beware is that the coefficients are trimmed of zeros at the ends. This is the reason for the padding and the arguments to Range. To always get the coefficients from the power 0 to the maximum power, one could use

PadRight[ArrayPad[s[[3]], {s[[4]], 0}], s[[5]]] Range[0, s[[5]] - 1]!
$\endgroup$
11
  • $\begingroup$ (at) Michael E2: interesting function SeriesData, but the exection time is not an argument. I have chosen delayed assignment in s[m_]:=... because m is unknown. If we know it in advance (as you do in your example with m = 25) we let s[m_] = ... and even for m = 320 the table of values (without displaying it) is calculated very quickly in 0.016 secs. $\endgroup$ Commented Oct 19, 2014 at 20:40
  • $\begingroup$ @Dr.WolfgangHintze Yes, I did the timing wrong. One has to start each trial from a fresh kernel. I forgot that the SeriesData is cached. For m = 100, I get about 0.4 sec. for your code and 0.15 sec. for mine. For m = 320, I got tired of waiting. $\endgroup$
    – Michael E2
    Commented Oct 19, 2014 at 21:08
  • $\begingroup$ (at) Michael E2: for the sake of completeness, I repeated the run with a fresh kernel. The result is the same (0.016 secs), Version 8. $\endgroup$ Commented Oct 19, 2014 at 21:27
  • $\begingroup$ @Dr.WolfgangHintze In V10, your Table[t[n], {n, 0, 320}]; //AbsoluteTiming took 37.9 sec. In V8, it took 75.5 sec. That's quite a difference from your timings. (I'm on a 2.7GHz quad-core i7 Mac. I included the code in case we're trying different things.) $\endgroup$
    – Michael E2
    Commented Oct 19, 2014 at 21:34
  • $\begingroup$ @ Michael E2: you are right, my numbers were wrong. I wrote 1 instead of x in g[]. But after correcting it the execution time remained the same. BTW it needs 4.368 secs to calculate s[m] with m=320. My code see next comment. $\endgroup$ Commented Oct 20, 2014 at 9:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.