Skip to main content
Added missing word.
Source Link
Somos
  • 5.1k
  • 1
  • 10
  • 16

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 change in future versions.

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 they are constant. Perhaps that may change in future versions.

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.

Light edits. Added last sentence.
Source Link
Somos
  • 5.1k
  • 1
  • 10
  • 16

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

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. That isTherefore, you may want to use the pattern k_?NumberQ instead of just k_. For more securitygenerality, 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 we moveis 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 evaluteevaluate 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 they are constant, for whatever reasons. Perhaps that may change in future versions.

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 case the 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. That is, you may want to use k_?NumberQ instead of just k_. For more security 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 we move outside the summation does not depend on the summation index. Also notice that the rule allows summations over 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 evalute 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 decided not to implement a general rule which would move factors out of a summation even they are constant, for whatever reasons.

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 they are constant. Perhaps that may change in future versions.

Added explanation of transformations.
Source Link
Somos
  • 5.1k
  • 1
  • 10
  • 16

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 case the 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 wishedwanted. However, the code is too loose. That is, you may want to use k_?NumberQ instead of just k_. For more security 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 whatTrue as you would expect. Notice the use of FreeQ to ensure that what we move outside the summation does not depend on the summation index. Also notice that the rule allows summations over 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 evalute 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 decided not to implement a general rule which would move factors out of a summation even they are constant, for whatever reasons.

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 case the 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 wished. However, the code is too loose. That is, you may want to use k_?NumberQ instead of just k_. For more security try the code

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

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

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 case the 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. That is, you may want to use k_?NumberQ instead of just k_. For more security 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 we move outside the summation does not depend on the summation index. Also notice that the rule allows summations over 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 evalute 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 decided not to implement a general rule which would move factors out of a summation even they are constant, for whatever reasons.

Replace More --> For. Also z_ --> z___.
Source Link
Somos
  • 5.1k
  • 1
  • 10
  • 16
Loading
Replace More --> For
Source Link
Somos
  • 5.1k
  • 1
  • 10
  • 16
Loading
Light edit.
Source Link
Somos
  • 5.1k
  • 1
  • 10
  • 16
Loading
Light edits.
Source Link
Somos
  • 5.1k
  • 1
  • 10
  • 16
Loading
Added k_?NumberQ
Source Link
Somos
  • 5.1k
  • 1
  • 10
  • 16
Loading
Source Link
Somos
  • 5.1k
  • 1
  • 10
  • 16
Loading