# [Maxima] Re: GosperSum division by zero

Stavros Macrakis macrakis at alum.mit.edu
Tue Aug 1 14:51:58 CDT 2006

```On 8/1/06, Andrej Vodopivec <andrej.vodopivec at gmail.com> wrote:
> (%i8) expr : cos(b*k);
> (%o8) cos(b*k)
> (%i9) sum(expr, k, D, N), exponentialize, simpsum;
> (%o9) ((%e^(%i*b*(N+1))-%e^(%i*b*D))/(%e^(%i*b)-1)+(%e^(-%i*b*(N+1))-%e^(-%i*b*D))/(%e^(-%i*b)-1))/2
>

You can simplify %o9 very nicely using trigrat:

r1: trigrat(%o9) =>
(sin((2*b*N+b)/2)-sin((2*b*D-b)/2)) / (2*sin(b/2))

In 2d form (might not display properly):

2 b N + b        2 b D - b
sin(---------) - sin(---------)
2                2
-------------------------------
b
2 sin(-)
2

Now a slightly trickier transformation of r1:

r2: substpart(b*multthru(piece/b),r1,1,1,1,2)\$
r3: substpart(b*multthru(piece/b),r2,1,2,1,1);

=> (sin(b*(N+1/2))-sin(b*(D-1/2)))/(2*sin(b/2))

==
1                1
sin(b (N + -)) - sin(b (D - -))
2                2
-------------------------------
b
2 sin(-)
2

A bit messy to do, but a clean result...

-s

```