# Question:sum of binomial giving wrong results

## Question:sum of binomial giving wrong results

Maple 2022

I was looking for rewriting some expression in simpler forms and ened up getting wrong values from maple

Is something wrong on how I'm using it or is this a bug ?

This is the code with the output:

```> NumericStatus(invalid_operation=false):
> simplify(sum(
>         (A-B)
>         *(-1+combinat:-binomial(N-2,i))
>         *(A)^(i)
>         *(B)^(N-2-i)
>     ,i=0..N-2));
(N - 1)    (N - 1)
B        - A

> NumericStatus(invalid_operation);
false
```

This is the wrong answer, is missing the part with the binomial, somehow its set to zero but the NumericStatus is still telling that everythig is fine.
It has not issues when one replaces the N-2 with N,

```> simplify(sum(
>         (A-B)
>         *(-1+combinat:-binomial(N,i))
>         *(A)^(i)
>         *(B)^(N-i)
>     ,i=0..N));
(N + 1)    (N + 1)                  N
B        - A        + (A - B) (A + B)

> NumericStatus(invalid_operation);
false
```

If I drop the (-1) in front I get the right contribution from the binomial regardless of using N or N-2

```> simplify(sum(
>         (A-B)
>         *(combinat:-binomial(N-2,i))
>         *(A)^(i)
>         *(B)^(N-2-i)
>     ,i=0..N-2));
/A + B\N          N
|-----|  (A - B) B
\  B  /
-------------------
2
(A + B)

> NumericStatus(invalid_operation);
false```

which is equal to (A+B)^(N-2)*(A-B)

If I use assume(N>2) it still gives the same result but this time is flagged ad an invalid operation (which is not supposed to).
Interesting enough also if I set assume(N>0) in the second example gives me invalid_operation=true but return the correct result.

﻿