2
$\begingroup$

I am taking difference between two sums.

enter image description here

Of course, what I wanted is A_s

But it's not evaluating this.

I tried Simplify, FullSimplify, Expand, and so on. But nothing works. What should I do?


I tried Nasser's suggestion. It is great! However, it works when I write it as you did, but it doesn't work when I write it as visually easy-to-read equation. Why is it like this?

enter image description here

$\endgroup$
  • 1
    $\begingroup$ as far as I know, Mathematica does not simplify sums with symbolic index. But maybe someone knows better. You could always use this trick ((Sum[a[t], {t, 1, s}] - Sum[a[t], {t, 1, s - 1}]) /. s -> 10) /. 10 -> s and this gives a[s] $\endgroup$ – Nasser Sep 2 '16 at 5:06
  • $\begingroup$ @Nasser Thank you!. Just one thing that's going strange. It works when I write it as you did, but it doesn't work when I write it as visually easy-to-read equation. I edited my question to show what I mean. $\endgroup$ – user42459 Sep 2 '16 at 5:53
  • $\begingroup$ I think may be you have syntax error. If you post plain Mathematica code it will be easier. The "/." is the ReplaceAll command. Make sure it is the same in your 2D illustration. $\endgroup$ – Nasser Sep 2 '16 at 6:35
  • $\begingroup$ You need a space between the "." and the "1" to avoid it being interpreted as "0.1". $\endgroup$ – mikado Sep 2 '16 at 18:46
3
$\begingroup$

Try this:

 rule1 = Sum[a_.[t], {t, 1, m_}] - Sum[a_.[t], {t, 1, m_ - k_.}] :> 
   Sum[a[t], {t, m - k + 1, m}];

and then:

(Sum[a[t], {t, 1, s}] - Sum[a[t], {t, 1, s - 1}]) /. rule1

(*  a[s]  *)

Have fun!

$\endgroup$
  • $\begingroup$ Wow this is a magic. Thank you so much. But what is ":>" ?? I googled but couldn't find it. Can you show me some mathematica documentation for ":>" ? Looks so useful. $\endgroup$ – user42459 Sep 2 '16 at 8:06
  • $\begingroup$ @ user42459 Type ?:> in a notebook and evaluate. You will get an answer. Click then over the chevron >> in the end of this answer and you will have more details and examples. $\endgroup$ – Alexei Boulbitch Sep 2 '16 at 8:10
  • $\begingroup$ @user42459 check this: reference.wolfram.com/language/ref/RuleDelayed.html $\endgroup$ – mattiav27 Sep 2 '16 at 8:11

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.