       Re: Re: SeriesCoefficient: needs work!

• To: mathgroup at smc.vnet.net
• Subject: [mg83536] Re: [mg83490] Re: SeriesCoefficient: needs work!
• Date: Thu, 22 Nov 2007 04:52:31 -0500 (EST)
• References: <fhrr3r\$53r\$1@smc.vnet.net> <200711210801.DAA06137@smc.vnet.net>

```On Wed, 21 Nov 2007, Peter Pein wrote:

> jackgold at umich.edu schrieb:
>> Hi Everyone,
>>
>> I have been experimenting with the new (ver 6) command,
>> SeriesCoefficient in the form,
>>
>> SeriesCoefficient[fnt,{x,x0,n}].
>>
>> Here fnt is a function of x and n is symbolic.  This command is
>> supposed to return the nth coefficient in the series expansion of fnt
>>
>> I have found the following results on a MacBook Pro running Tiger.
>>
>> 1) SeriesCoefficient[Cos[x] Exp[x], {x, 0, n}] returns itself, unevaluated.
>>
>> 2) SeriesCoefficient[Cos[x] Exp[x]/(1-x), {x, 0, n}] returns an
>> expression involving incomplete Gamma functions with an imaginary
>> argument.  Odd that 1) does not compute but 2) does! Not that the
>> result is terribly revealing, by the way.
>>
>> 3) SeriesCoefficient[Sin[x] Exp[x], {x, 0, n}] so preposterously
>> complicated that most of us would have preferred no result!  (Just
>> joking.  The result is far to complicated to publish here.)
>>
>> My opinion is that this use of SeriesCoefficient should not be offered
>> to the public until some of these obvious glitches are cleaned up.
>> Incidentally, since the nth terms of the individual functions Sin[x],
>> Cos[x], Exp[x] and 1/(1-x) can be found using SeriesCoefficient and
>> surely Mathematica knows how to find the nth coefficient of a product of power
>> series, I suspect the problem lies in the finite summation which
>> results from the use of the Cauchy product formula.
>>
>>
> Strange.
> In Version 5.2 the good old SeriesTerm[] in the package DiscreteMath got its
> difficulties in case 2:
>
> In:=
> << "DiscreteMath`"
> In:=
> SeriesTerm[Cos[x]*E^x, {x, 0, n}]
> Out=
> (1 - I)^n/(2*n!) + (1 + I)^n/(2*n!)
> In:=
> SeriesTerm[(Cos[x]*E^x)/(1 - x),
>  {x, 0, n}]
> Out=
> Piecewise[{{ComplexInfinity, n >= 1}},
>  (I^n*KroneckerDelta[Mod[n, 2]])/
>   Gamma[1 + n]]
> In:=
> SeriesTerm[Sin[x]*E^x, {x, 0, n}]
> Out=
> -((1/Pi)*(2^(1 + n/2)*
>    (Cos[(n*Pi)/4] + Cos[(3*n*Pi)/4])*
>    Gamma[-n]*Sin[(n*Pi)/4]^2))
>
> And the package SpecialFunctions by Prof. Wolfram Koepf (
> http://www.mathematik.uni-kassel.de/~koepf/CA/index.html ) has got problems
> with case 2 too:
>
> In:=
> << "SpecialFunctions`"
>> From In:=
> "SpecialFunctions, (C) Wolfram Koepf, version 2.01, 2006"
>> From In:=
> "Fast Zeilberger, (C) Peter Paule and Markus Schorn (V 2.2) loaded"
> In:=
> PS[Cos[x]*Exp[x], x, 0]
> Out=
> sum[(2^(k/2)*x^k*Cos[(k*Pi)/4])/k!, {k, 0, Infinity}]
> In:=
> PS[Cos[x]*(Exp[x]/(1 - x)), x, 0]
> Out=
> SpecialFunctions`Private`df
> In:=
> PS[Sin[x]*Exp[x], x, 0]
> Out=
> sum[(2^(k/2)*x^k*Sin[(k*Pi)/4])/k!, {k, 0, Infinity}]
>
>
> Shouldn't the V6-function SeriesCoefficient be at least as smart as the
> V5.2-package is? But maybe the new version gets some series representations
> where the old one fails.
>
> Peter
>
Hello,

Thank you for these examples and observations about SeriesCoefficient
in Mathematica 6.

The problem with the first and third examples (general series coefficients
for Cos[x]*Exp[x] and Sin[x]*Exp[x]) is indeed caused by difficulties in
evaluating the underlying finite sums. A partial workaround is to use
TrigToExp in these cases as shown below (for completeness, all three
examples are evaluated along with checks using the Series function).

==============================

In:= \$Version

Out= 6.0 for Linux x86 (32-bit) (June 28, 2007)

In:= SeriesCoefficient[Cos[x] Exp[x] // TrigToExp, {x, 0, n}]//InputForm

Out//InputForm= (1 - I)^n/(2*n!) + (1 + I)^n/(2*n!)

In:= Table[%, {n, 0, 7}] // InputForm

Out//InputForm= {1, 1, 0, -1/3, -1/6, -1/30, 0, 1/630}

In:= Normal[Series[Cos[x] Exp[x], {x, 0, 7}]] // InputForm

Out//InputForm= 1 + x - x^3/3 - x^4/6 - x^5/30 + x^7/630

In:= SeriesCoefficient[Cos[x] Exp[x]/(1 - x), {x, 0, n}] // InputForm

Out//InputForm=
(E^(1 - I)*(1 + n)*Gamma[1 + n, 1 - I])/(2*Gamma[2 + n]) +
(E^(1 + I)*(1 + n)*Gamma[1 + n, 1 + I])/(2*Gamma[2 + n])

In:= Table[%, {n, 0, 7}] // FullSimplify // InputForm

Out//InputForm= {1, 2, 2, 5/3, 3/2, 22/15, 22/15, 185/126}

In:= Normal[Series[Cos[x] Exp[x]/(1 - x), {x, 0, 7}]] // InputForm

Out//InputForm=
1 + 2*x + 2*x^2 + (5*x^3)/3 + (3*x^4)/2 + (22*x^5)/15 + (22*x^6)/15 +
(185*x^7)/126

In:= SeriesCoefficient[Sin[x] Exp[x] // TrigToExp, {x, 0, n}] // InputForm

Out//InputForm= ((I/2)*(1 - I)^n)/n! - ((I/2)*(1 + I)^n)/n!

In:= Table[%, {n, 0, 7}] // InputForm

Out//InputForm= {0, 1, 1, 1/3, 0, -1/30, -1/90, -1/630}

In:= Normal[Series[Sin[x] Exp[x] // TrigToExp, {x, 0, 7}]] //InputForm

Out//InputForm= x + x^2 + x^3/3 - x^5/30 - x^6/90 - x^7/630

===============================

I apologize for the confusion caused by these problems.

Sincerely,