3
$\begingroup$

For a generic symbol A[i]

2 Sum[A[i], {i, 1, n}] == Sum[2 A[i], {i, 1, n}]

does not return True.

Is there any reason behind these behaviors? Do we have any way to evaluate the equation correctly?

ADDED:

I would like to thank everyone who noted the comments. I am afraid my use of Simplify makes everyone confused. I want to ask not the behavior of Simplify, but that of Sum and Equal. Is it intentional or kind of a "bug"?

Edited:

What I would like to ask is about Sum and I have not intended to ask the use of Simplify. So, I edited the title again.

As I have written below, mathematically Sum[2 ..] is equivalent to 2 Sum[..]. I thought that as long as mathematically correct, Mathematica returns immediate values, especially for trivial cases, just like the examples of a + b == b + a or a b == b a. Does not this hold for Sum? Do we have any way to let Mathematica evaluate the relation mathematically correctly? This is my question. I am sorry if my question was ambiguous.

$\endgroup$
5
  • $\begingroup$ I often find getting assumptions to be used properly difficult in Mathematica, but mathematically if you are imposing A[]<100 for the sake of boundedness don't you also want to add A[]>-100. (Not that it matters here, I expect the reason Mathematica does not want to take the 2 out of the sum has more to do with the fact that n has not been fixed and that the assumptions you use on n are not properly being used.) $\endgroup$
    – Kvothe
    Commented May 31, 2019 at 9:45
  • $\begingroup$ Related/duplicate: (21007), (65471) $\endgroup$
    – Michael E2
    Commented May 31, 2019 at 12:23
  • $\begingroup$ Welcome to Mathematica.SE! I suggest the following: 1) As you receive help, try to give it too, by answering questions in your area of expertise. 2) Take the tour! 3) When you see good questions and answers, vote them up by clicking the gray triangles, because the credibility of the system is based on the reputation gained by users sharing their knowledge. Also, please remember to accept the answer, if any, that solves your problem, by clicking the checkmark sign! $\endgroup$
    – Michael E2
    Commented May 31, 2019 at 12:23
  • $\begingroup$ What exactly do you want to know about the behavior Sum and Equal? $\endgroup$
    – Somos
    Commented May 31, 2019 at 14:13
  • $\begingroup$ Well, mathematically Sum[2 ..] is equivalent to 2 Sum[..]. I thought that as long as mathematically correct, Mathematica returns immediate values, just like the examples of a + b == b + a or a b == b a. Does not this hold for Sum? Do we have any way to let Mathematica evaluate the relation mathematically correctly? This is my question. $\endgroup$
    – hfukuda
    Commented Jun 1, 2019 at 13:56

2 Answers 2

1
$\begingroup$

Simplify just transforms the equation into another, hopefully simpler form. Do not expect it to "solve" problems. It is not its purpose.

Simplify also does not give any guarantees about success. It only guarantees that the output is equivalent to the input. Simplify does a heuristic search by applying various transformation. If it does not find a simpler form, it does not mean that one does not exist.

To give some insight into why it handled one case but not the other:

  • Simplify generally works with expressions consisting of plain functions, not things like sums or integrals

  • Setting an explicit value for n allows the sums to evaluate

$\endgroup$
2
  • $\begingroup$ Well, then let me restate my question: why 2 Sum[…] does not equal to Sum[2 …]. For instance, Mathematica correctly results a b == b a or a + b = b + a. What is the difference between the former and the latter? $\endgroup$
    – hfukuda
    Commented May 31, 2019 at 13:59
  • $\begingroup$ @hfukuda "why 2 Sum[…] does not equal to Sum[2 …]" Mathematica did not say that they are not equal. $\endgroup$
    – Szabolcs
    Commented May 31, 2019 at 15:14
1
$\begingroup$

Your question "Do we have any way to evaluate the equation correctly?" is yes because Mathematica allows you to define arbitrary rules to perform manipulation of expressions.

In your particular use case the simplistic code

2 Sum[A[i], {i, n}] == Sum[2 A[i], {i, n}] /. Sum[k_ x_, {y_, z_}] :> k Sum[x, {y, z}]

returns True as you wanted. However, the code is too loose. Therefore, you may want to use the pattern k_?NumberQ instead of just k_. For more generality, try the code

rule =  Sum[Times[Longest[u___], x___] , {y_, z___}] :> 
         Times[u] Sum[Times[x], {y, z}] /; (FreeQ[{u}, y]);
2 b[j] Sum[A[i], {i, n}] == Sum[b[j] 2 A[i], {i, n}] /. rule

which returns True as you would expect. Notice the use of FreeQ to ensure that what is moved outside the summation does not depend on the summation index. Also notice that the rule allows summations over range variations such as {i, a, b} or {i}.

In general, Mathematica does certain transformations to expressions automatically. For example, the Plus and Times functions have attributes Orderless and Flat which means that they are commutative and associative. That is the reason why a + b == b + a and a b == b a evaluate to True automatically by default. However, that does not extend to a (b + c) == a b + a c which seems as though it should be true also. For cases like this Mathematica has certain transformations that are used if requested by Expand or Simplify. That allows the expressions a (b + c) == a b + a c // Expand or a (b + c) == a b + a c // Simplify to evaluate to True as you would expect.

In the particular case of summations, the designers of Mathematica, for unknown reasons, decided not to implement a general rule which would move factors out of a summation even if they are constant. Perhaps that may change in future versions.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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