3
$\begingroup$

I would like to perform a summation from $1$ to $M$ of a simple piecewise function. For example,

a[i_] := Piecewise[{{a, i == 1}}, b];
Assuming[Element[M, Integers] && M >= 1, Sum[a[i], {i, 1, M}]]

For $M \geq 1$, the exact solution is $a - b + bM$. With Mathematica, however, I get

$$ \begin{cases} a & M\leq1 \\ a - b + bM & \text{True} \end{cases} $$

This is not wrong, but I would like to simplify out the redundant first case. I cannot seem to find the correct set of assumptions and simplifications necessary to do this.

$\endgroup$
  • 1
    $\begingroup$ You may not find this satisfying, but Sum[c[i], {i, M}] // Last works. $\endgroup$ – bbgodfrey May 17 '17 at 15:39
  • 1
    $\begingroup$ Simplify[Sum[a[i], {i, 1, M}], M > 1] $\endgroup$ – yohbs May 17 '17 at 19:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.