Sum function evaluation problem



On 6/04/2011 10:13 PM, Raymond Toy wrote:
>>>>>> "Chi" == Chi Ben writes:
>      Chi>  Hi All,
>      Chi>  I was using this sum function:
>
>      Chi>            sum((tan(1/(2*x))-tan(1/(2*x+1))),x,1,inf),simpsum=true;
>
>      Chi>  However, the evaluated result is the mathematical expression
>      Chi>  instead of a float value, even with simpsum=true.  How do I
>      Chi>  get a value?
>
> Stavros has already explained why you don't get a float value.  But if
> you still want one, you can do
>
> sum(float(tan(1/(2*x))-tan(1/(2*x+1))),x,1,1000) ->  .3435856189171599
>
> But the terms look like 1/4/x^2 for large x, so the series doesn't
> converge very fast, so 1000 terms may not be accurate enough for you.
>
> However, you can let maxima help you evaluate this sum more
> accurately.  First,
>
> taylor(tan(1/(2*x))-tan(1/(2*x+1)),x,inf, 4) ->
> 1/(4*x^2)-1/(8*x^3)+1/(8*x^4)$
>
> So the terms of the series are approximately that for large x.
> Rewrite the series as
>
> sum((tan(1/(2*x))-tan(1/(2*x+1))-(1/(4*x^2)-1/(8*x^3)+1/(8*x^4)),x,1,inf)
>   + sum(1/(4*x^2),x,1,inf)-sum(1/(8*x^3),x,1,inf)+sum(1/(8*x^4),x,1,inf)
>
> These latter sums can be evaluated by maxima:
>
> simpsum:true;
> sum(1/(4*x^2),x,1,inf)-sum(1/(8*x^3),x,1,inf)+sum(1/(8*x^4),x,1,inf);
> ->  -zeta(3)/8+%pi^4/720+%pi^2/24
>
> Then
>
> sum((tan(1/(2*x))-tan(1/(2*x+1))-(1/(4*x^2)-1/(8*x^3)+1/(8*x^4)),x,1,inf)
>
> can be approximated by summing from 1 to 1000, since 1/1000^5 is about
> 1e-15.  Finally, the sum is
>
> sum(float(tan(1/(2*x))-tan(1/(2*x+1))-(1/(4*x^2)-1/(8*x^3)+1/(8*x^4))),x,1,1000)
>   + float(-zeta(3)/8+%pi^4/720+%pi^2/24)
> ->  0.3438354315628996
>
> I hope I got that all right.
>
You could also try the levin package to accelerate the convergence.  
This is not documented in the manual.  You will need to look at the 
files in share/contrib/levin/ for more information. See 
http://maxima.cvs.sourceforge.net/viewvc/maxima/maxima/share/contrib/levin/

Levin transforms are neat when they work, and this seems to be the case 
here.

(%i1) load("levin.mac")$
(%i2) fpprec:16$
(%i3) approx:bfloat(bflevin_u_sum(n/((3*n+1)*(2*n+1)^2),n,1));
(%o3)                        6.517679613678698b-2
(%i4)
(%i1) fpprec;
(%o1)                                 16
(%i2) load("levin.mac")$
(%i3) approx_16:bfloat(bflevin_u_sum((tan(1/(2*x))-tan(1/(2*x+1))),x,1));
(%o3)                        3.438354315628762b-1
(%i4) fpprec:50;
(%o4)                                 50
(%i5) approx_50:bfloat(bflevin_u_sum((tan(1/(2*x))-tan(1/(2*x+1))),x,1));
(%o5)       3.4383543156287618385885647034599140840591675991409b-1