       Re: Re: general nth term of series

• To: mathgroup at smc.vnet.net
• Subject: [mg63102] Re: [mg63018] Re: general nth term of series
• Date: Wed, 14 Dec 2005 04:36:04 -0500 (EST)
• References: <dnbmun\$5qm\$1@smc.vnet.net> <dnedel\$cn\$1@smc.vnet.net> <200512110956.EAA23300@smc.vnet.net>
• Sender: owner-wri-mathgroup at wolfram.com

```On Sun, 11 Dec 2005, Peter Pein wrote:

> Peter Pein schrieb:
>> Hi Ash,
>>
>> SeriesTerm[(1 - 2*x*u + u^2)^(-1/2), {u, 0, n}]
>> gives LegendreP[n,x] without any Gammas in Version 5.1
>>
>> Use SeriesTerm with care. It is quite buggy for general n:
>>
>> Series[Sin[x]/(1 + x), {x, 0, 5}]//Normal
>> --> x - x^2 + (5*x^3)/6 - (5*x^4)/6 + (101*x^5)/120
>>
>> SeriesTerm[Sin[x]/(1 + x), {x, 0, 5}]
>> --> 101/120
>>
>> is OK, but:
>>
>> SeriesTerm[Sin[x]/(1 + x), {x, 0, n}] /. n -> 5
>> --> Sqrt[Pi/2]*BesselJ[1/2, 1]
>>
>> N[120 %]
>> --> 100.977
>>
>> _Incidentally_ almost good...
>>
>> SeriesTerm gives for this example (-(-1)^n)*Sqrt[Pi/2]*BesselJ[1/2, 1]
>> as coefficient of x^n. :-\
>>
>> Peter
>>
>
> I should have pointed out that Sqrt[Pi/2]BesselJ[1/2,1]==Sin which is
> not too far from the coefficient of x^(2k+1) in
> f[x]=(1 - x)Sum[Round[Sin(2k + 1)!]/(2k + 1)!*x^(2k + 1),{k, 0, â??}].
> I have no idea how Mathematica should derive the representation
> f[x]=Sum[(-1)^(k)*Sum[(-1)^j/(2*j + 1)!, {j, 0, Floor[k/2]}]x^(k + 1),
> {k, 0, â??}], because the result of
> RSolve[{a==0,a==1,a==0,(k+1)(k+2)(a[k+1]+a[k+2])+a[k]+a[k-1]==0},a,k]
> is spectacular ;-) but doesn't really help :-(.
>
> Peter
>
Hello Peter,

Thank you for reporting the problems with SeriesTerm and RSolve described
above.

In the case of SeriesTerm, we use InverseZTransform which proceeds by
finding the general terms in the expansions of the individual factors
(Sin[x] and 1/(1+x)). However, there is a problem while "convolving" these
general terms using symbolic summation, to arrive at the final answer. As
noted by you, using a non-default set of assumptions allows us to work
around the problem. For comparison, I have given below the incorrect
answer from SeriesTerm (ans1), the output with non-default assumptions
(ans2), the complete answer from symbolic summation (ans3) and the
result of applying Series directly (ans4).

=======================================================
In:= \$Version

Out= 5.2 for Linux (June 27, 2005)

In:= << DiscreteMath`

In:= ans1 = SeriesTerm[Sin[x]/(1 + x), {x, 0, n}]

n      Pi          1
Out= -((-1)  Sqrt[--] BesselJ[-, 1])
2           2

In:= Table[ans1, {n,0,11}]//FullSimplify

Out= {-Sin, Sin, -Sin, Sin, -Sin, Sin, -Sin,
Sin, -Sin, Sin, -Sin, Sin}

In:=  N[%]

Out= {-0.841471, 0.841471, -0.841471, 0.841471, -0.841471, 0.841471,
-0.841471, 0.841471, -0.841471, 0.841471, -0.841471, 0.841471}

In:= (ans2 = SeriesTerm[Sin[x]/(1 + x), {x, 0, n},
Assumptions -> n > -1]//FullSimplify)//InputForm

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

In:= Table[ans2, {n,0,11}]//FullSimplify//InputForm

Out//InputForm=
{0, 1, -1, 5/6, -5/6, 101/120, -101/120, 4241/5040, -4241/5040,
305353/362880, -305353/362880, 33588829/39916800}

In:= N[%]

Out= {0., 1., -1., 0.833333, -0.833333, 0.841667, -0.841667, 0.841468,
-0.841468, 0.841471, -0.841471, 0.841471}

In:=  ans3 = (-(-1)^n)*(Sqrt[Pi/2]*BesselJ[1/2, 1] +
((-1)^Floor[(1/2)*(-1 + n)]*HypergeometricPFQ[{1},
{2 + Floor[(1/2)*(-1 + n)], 5/2 + Floor[(1/2)*(-1 + n)]},
-(1/4)])/Gamma[4 + 2*Floor[(1/2)*(-1 + n)]])*
UnitStep[-1 + n]^2;

In:= Table[ans3, {n,0,11}]//FullSimplify//InputForm

Out//InputForm=
{0, 1, -1, 5/6, -5/6, 101/120, -101/120, 4241/5040, -4241/5040,
305353/362880, -305353/362880, 33588829/39916800}

In:= N[%]

Out= {0., 1., -1., 0.833333, -0.833333, 0.841667, -0.841667, 0.841468,
-0.841468, 0.841471, -0.841471, 0.841471}

In:= (ans4 = CoefficientList[Normal[Series[Sin[x]/(1 + x), {x, 0,
11}]], x])//InputForm

Out//InputForm=
{0, 1, -1, 5/6, -5/6, 101/120, -101/120, 4241/5040, -4241/5040,
305353/362880, -305353/362880, 33588829/39916800}

In:= N[%]

Out= {0., 1., -1., 0.833333, -0.833333, 0.841667, -0.841667, 0.841468,
-0.841468, 0.841471, -0.841471, 0.841471}

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

For the third-order difference equation given by you, RSolve finds
one element of the basis for the general solution ((-1)^k)) easily,
but has difficulty in solving the second-order equation to which
the problem is reduced at this stage. Clearly, the final solution
is not very useful at all.

Sorry for the confusion caused by these problems.

Sincerely,