Re: Re: SeriesCoefficient: needs work!
- To: mathgroup at smc.vnet.net
- Subject: [mg83536] Re: [mg83490] Re: SeriesCoefficient: needs work!
- From: Devendra Kapadia <dkapadia at wolfram.com>
- 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 >> about x0. >> >> 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[1]:= > << "DiscreteMath`" > In[2]:= > SeriesTerm[Cos[x]*E^x, {x, 0, n}] > Out[2]= > (1 - I)^n/(2*n!) + (1 + I)^n/(2*n!) > In[3]:= > SeriesTerm[(Cos[x]*E^x)/(1 - x), > {x, 0, n}] > Out[3]= > Piecewise[{{ComplexInfinity, n >= 1}}, > (I^n*KroneckerDelta[Mod[n, 2]])/ > Gamma[1 + n]] > In[4]:= > SeriesTerm[Sin[x]*E^x, {x, 0, n}] > Out[4]= > -((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[1]:= > << "SpecialFunctions`" >> From In[1]:= > "SpecialFunctions, (C) Wolfram Koepf, version 2.01, 2006" >> From In[1]:= > "Fast Zeilberger, (C) Peter Paule and Markus Schorn (V 2.2) loaded" > In[3]:= > PS[Cos[x]*Exp[x], x, 0] > Out[3]= > sum[(2^(k/2)*x^k*Cos[(k*Pi)/4])/k!, {k, 0, Infinity}] > In[4]:= > PS[Cos[x]*(Exp[x]/(1 - x)), x, 0] > Out[4]= > SpecialFunctions`Private`df[3] > In[5]:= > PS[Sin[x]*Exp[x], x, 0] > Out[5]= > 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[1]:= $Version Out[1]= 6.0 for Linux x86 (32-bit) (June 28, 2007) In[2]:= SeriesCoefficient[Cos[x] Exp[x] // TrigToExp, {x, 0, n}]//InputForm Out[2]//InputForm= (1 - I)^n/(2*n!) + (1 + I)^n/(2*n!) In[3]:= Table[%, {n, 0, 7}] // InputForm Out[3]//InputForm= {1, 1, 0, -1/3, -1/6, -1/30, 0, 1/630} In[4]:= Normal[Series[Cos[x] Exp[x], {x, 0, 7}]] // InputForm Out[4]//InputForm= 1 + x - x^3/3 - x^4/6 - x^5/30 + x^7/630 In[5]:= SeriesCoefficient[Cos[x] Exp[x]/(1 - x), {x, 0, n}] // InputForm Out[5]//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[6]:= Table[%, {n, 0, 7}] // FullSimplify // InputForm Out[6]//InputForm= {1, 2, 2, 5/3, 3/2, 22/15, 22/15, 185/126} In[7]:= Normal[Series[Cos[x] Exp[x]/(1 - x), {x, 0, 7}]] // InputForm Out[7]//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[8]:= SeriesCoefficient[Sin[x] Exp[x] // TrigToExp, {x, 0, n}] // InputForm Out[8]//InputForm= ((I/2)*(1 - I)^n)/n! - ((I/2)*(1 + I)^n)/n! In[9]:= Table[%, {n, 0, 7}] // InputForm Out[9]//InputForm= {0, 1, 1, 1/3, 0, -1/30, -1/90, -1/630} In[10]:= Normal[Series[Sin[x] Exp[x] // TrigToExp, {x, 0, 7}]] //InputForm Out[10]//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, Devendra Kapadia, Wolfram Research, Inc.
- References:
- Re: SeriesCoefficient: needs work!
- From: Peter Pein <petsie@dordos.net>
- Re: SeriesCoefficient: needs work!