Why is expression not evaluated completely? [closed]
$begingroup$
I have a simple sum of complex numbers. In my example their sum is zero.
sum = Total[{1 , E^(2*I/3*Pi) , E^((4*I)/3*Pi)}]
Print[sum]
Try it online!
When computing this sum, I just get back this "symbolic" expression:
1 + E^((-2*I)/3*Pi) + E^((2*I)/3*Pi)
(I already learned that this can be reduced to a single number using Simplify
to get the result I expect.)
But when I replace this list of complex numbers with e.g. a list of integers {1,2,3}
it does get evaluated to a single number.
I didn't understand why these two cases behave differently, so can you explain why I get an expression back for the first case and a fully simplified number in the second case?
simplifying-expressions evaluation
$endgroup$
closed as off-topic by Daniel Lichtblau, m_goldberg, Bill Watts, Sumit, MarcoB Feb 5 at 4:50
This question appears to be off-topic. The users who voted to close gave this specific reason:
- "This question arises due to a simple mistake such as a trivial syntax error, incorrect capitalization, spelling mistake, or other typographical error and is unlikely to help any future visitors, or else it is easily found in the documentation." – Daniel Lichtblau, m_goldberg, Bill Watts, Sumit, MarcoB
If this question can be reworded to fit the rules in the help center, please edit the question.
add a comment |
$begingroup$
I have a simple sum of complex numbers. In my example their sum is zero.
sum = Total[{1 , E^(2*I/3*Pi) , E^((4*I)/3*Pi)}]
Print[sum]
Try it online!
When computing this sum, I just get back this "symbolic" expression:
1 + E^((-2*I)/3*Pi) + E^((2*I)/3*Pi)
(I already learned that this can be reduced to a single number using Simplify
to get the result I expect.)
But when I replace this list of complex numbers with e.g. a list of integers {1,2,3}
it does get evaluated to a single number.
I didn't understand why these two cases behave differently, so can you explain why I get an expression back for the first case and a fully simplified number in the second case?
simplifying-expressions evaluation
$endgroup$
closed as off-topic by Daniel Lichtblau, m_goldberg, Bill Watts, Sumit, MarcoB Feb 5 at 4:50
This question appears to be off-topic. The users who voted to close gave this specific reason:
- "This question arises due to a simple mistake such as a trivial syntax error, incorrect capitalization, spelling mistake, or other typographical error and is unlikely to help any future visitors, or else it is easily found in the documentation." – Daniel Lichtblau, m_goldberg, Bill Watts, Sumit, MarcoB
If this question can be reworded to fit the rules in the help center, please edit the question.
$begingroup$
Is there some reason to expect any result other than the one indicates? Stated differently, what result is expected from1+ E^((-2*I)/3*Pi)+E^((2*I)/3*Pi)
? Or, for that matter, from just adding the last two terms:E^((-2*I)/3*Pi)+E^((2*I)/3*Pi)
?
$endgroup$
– Daniel Lichtblau
Feb 3 at 15:08
$begingroup$
@DanielLichtblau As there exists a much simpler representation I expected Mathematica to find that, just as it finds the most "simple" representation of a fraction or a sum. (I mean it would not return a fraction like4/10
or a sum like1+2+3
.) Of course such simple sums might be easier to compute, but the original sum that I was referring to was also just an algebraic expression which are computationally not too difficult to simplify.
$endgroup$
– flawr
Feb 3 at 15:27
3
$begingroup$
Arithmetic involves basic evaluation so for example entering1+2+3
will give6
. But finding "simplest" forms in general is outside the scope of the core evaluator. Functions such asSimplify
can be used for this purpose.
$endgroup$
– Daniel Lichtblau
Feb 3 at 15:31
add a comment |
$begingroup$
I have a simple sum of complex numbers. In my example their sum is zero.
sum = Total[{1 , E^(2*I/3*Pi) , E^((4*I)/3*Pi)}]
Print[sum]
Try it online!
When computing this sum, I just get back this "symbolic" expression:
1 + E^((-2*I)/3*Pi) + E^((2*I)/3*Pi)
(I already learned that this can be reduced to a single number using Simplify
to get the result I expect.)
But when I replace this list of complex numbers with e.g. a list of integers {1,2,3}
it does get evaluated to a single number.
I didn't understand why these two cases behave differently, so can you explain why I get an expression back for the first case and a fully simplified number in the second case?
simplifying-expressions evaluation
$endgroup$
I have a simple sum of complex numbers. In my example their sum is zero.
sum = Total[{1 , E^(2*I/3*Pi) , E^((4*I)/3*Pi)}]
Print[sum]
Try it online!
When computing this sum, I just get back this "symbolic" expression:
1 + E^((-2*I)/3*Pi) + E^((2*I)/3*Pi)
(I already learned that this can be reduced to a single number using Simplify
to get the result I expect.)
But when I replace this list of complex numbers with e.g. a list of integers {1,2,3}
it does get evaluated to a single number.
I didn't understand why these two cases behave differently, so can you explain why I get an expression back for the first case and a fully simplified number in the second case?
simplifying-expressions evaluation
simplifying-expressions evaluation
asked Feb 2 at 21:50
flawrflawr
1205
1205
closed as off-topic by Daniel Lichtblau, m_goldberg, Bill Watts, Sumit, MarcoB Feb 5 at 4:50
This question appears to be off-topic. The users who voted to close gave this specific reason:
- "This question arises due to a simple mistake such as a trivial syntax error, incorrect capitalization, spelling mistake, or other typographical error and is unlikely to help any future visitors, or else it is easily found in the documentation." – Daniel Lichtblau, m_goldberg, Bill Watts, Sumit, MarcoB
If this question can be reworded to fit the rules in the help center, please edit the question.
closed as off-topic by Daniel Lichtblau, m_goldberg, Bill Watts, Sumit, MarcoB Feb 5 at 4:50
This question appears to be off-topic. The users who voted to close gave this specific reason:
- "This question arises due to a simple mistake such as a trivial syntax error, incorrect capitalization, spelling mistake, or other typographical error and is unlikely to help any future visitors, or else it is easily found in the documentation." – Daniel Lichtblau, m_goldberg, Bill Watts, Sumit, MarcoB
If this question can be reworded to fit the rules in the help center, please edit the question.
$begingroup$
Is there some reason to expect any result other than the one indicates? Stated differently, what result is expected from1+ E^((-2*I)/3*Pi)+E^((2*I)/3*Pi)
? Or, for that matter, from just adding the last two terms:E^((-2*I)/3*Pi)+E^((2*I)/3*Pi)
?
$endgroup$
– Daniel Lichtblau
Feb 3 at 15:08
$begingroup$
@DanielLichtblau As there exists a much simpler representation I expected Mathematica to find that, just as it finds the most "simple" representation of a fraction or a sum. (I mean it would not return a fraction like4/10
or a sum like1+2+3
.) Of course such simple sums might be easier to compute, but the original sum that I was referring to was also just an algebraic expression which are computationally not too difficult to simplify.
$endgroup$
– flawr
Feb 3 at 15:27
3
$begingroup$
Arithmetic involves basic evaluation so for example entering1+2+3
will give6
. But finding "simplest" forms in general is outside the scope of the core evaluator. Functions such asSimplify
can be used for this purpose.
$endgroup$
– Daniel Lichtblau
Feb 3 at 15:31
add a comment |
$begingroup$
Is there some reason to expect any result other than the one indicates? Stated differently, what result is expected from1+ E^((-2*I)/3*Pi)+E^((2*I)/3*Pi)
? Or, for that matter, from just adding the last two terms:E^((-2*I)/3*Pi)+E^((2*I)/3*Pi)
?
$endgroup$
– Daniel Lichtblau
Feb 3 at 15:08
$begingroup$
@DanielLichtblau As there exists a much simpler representation I expected Mathematica to find that, just as it finds the most "simple" representation of a fraction or a sum. (I mean it would not return a fraction like4/10
or a sum like1+2+3
.) Of course such simple sums might be easier to compute, but the original sum that I was referring to was also just an algebraic expression which are computationally not too difficult to simplify.
$endgroup$
– flawr
Feb 3 at 15:27
3
$begingroup$
Arithmetic involves basic evaluation so for example entering1+2+3
will give6
. But finding "simplest" forms in general is outside the scope of the core evaluator. Functions such asSimplify
can be used for this purpose.
$endgroup$
– Daniel Lichtblau
Feb 3 at 15:31
$begingroup$
Is there some reason to expect any result other than the one indicates? Stated differently, what result is expected from
1+ E^((-2*I)/3*Pi)+E^((2*I)/3*Pi)
? Or, for that matter, from just adding the last two terms: E^((-2*I)/3*Pi)+E^((2*I)/3*Pi)
?$endgroup$
– Daniel Lichtblau
Feb 3 at 15:08
$begingroup$
Is there some reason to expect any result other than the one indicates? Stated differently, what result is expected from
1+ E^((-2*I)/3*Pi)+E^((2*I)/3*Pi)
? Or, for that matter, from just adding the last two terms: E^((-2*I)/3*Pi)+E^((2*I)/3*Pi)
?$endgroup$
– Daniel Lichtblau
Feb 3 at 15:08
$begingroup$
@DanielLichtblau As there exists a much simpler representation I expected Mathematica to find that, just as it finds the most "simple" representation of a fraction or a sum. (I mean it would not return a fraction like
4/10
or a sum like 1+2+3
.) Of course such simple sums might be easier to compute, but the original sum that I was referring to was also just an algebraic expression which are computationally not too difficult to simplify.$endgroup$
– flawr
Feb 3 at 15:27
$begingroup$
@DanielLichtblau As there exists a much simpler representation I expected Mathematica to find that, just as it finds the most "simple" representation of a fraction or a sum. (I mean it would not return a fraction like
4/10
or a sum like 1+2+3
.) Of course such simple sums might be easier to compute, but the original sum that I was referring to was also just an algebraic expression which are computationally not too difficult to simplify.$endgroup$
– flawr
Feb 3 at 15:27
3
3
$begingroup$
Arithmetic involves basic evaluation so for example entering
1+2+3
will give 6
. But finding "simplest" forms in general is outside the scope of the core evaluator. Functions such as Simplify
can be used for this purpose.$endgroup$
– Daniel Lichtblau
Feb 3 at 15:31
$begingroup$
Arithmetic involves basic evaluation so for example entering
1+2+3
will give 6
. But finding "simplest" forms in general is outside the scope of the core evaluator. Functions such as Simplify
can be used for this purpose.$endgroup$
– Daniel Lichtblau
Feb 3 at 15:31
add a comment |
3 Answers
3
active
oldest
votes
$begingroup$
Exact numeric expressions are treated symbolically, and there are a very limited number of transformations that will be applied automatically. Adding "actual numbers" (see NumberQ
) is one such transformation that occurs. But E^((-2*I)/3*Pi)
is not converted to a number, unless such a transformation is explicitly requested (as is done by Simplify
, ComplexExpand
, and so forth). A similar thing happens with the following:
Total@ArcTan@Range@3
(* π/4 + ArcTan[2] + ArcTan[3] *)
FullSimplify[%]
(* π *)
$endgroup$
add a comment |
$begingroup$
sum = Total[{1, E^(2*I/3*Pi), E^((4*I)/3*Pi)}]
(* 1+E^(-((2 I π)/3))+E^((2 I π)/3) *)
Using machine precision, the sum is not identically zero
sum // N
(* 4.44089*10^-16+0. I *)
In fact, basic symbolic and numerical methods used internally do not show that sum
has value zero
sum // PossibleZeroQ
(* PossibleZeroQ::ztest1: Unable to decide whether numeric quantity
1-(-1)^(1/3)+(-1)^(2/3) is equal to zero. Assuming it is.
True *)
Consequently, sum
does not automatically evaluate to zero. More robust methods are required such as
#@sum& /@ {Simplify, ComplexExpand, RootReduce}
(* {0,0,0} *)
$endgroup$
add a comment |
$begingroup$
Try
sum = Total[{1, E^(2*I/3*Pi), E^((4*I)/3*Pi)}] // ExpToTrig
(*0*)
$endgroup$
add a comment |
3 Answers
3
active
oldest
votes
3 Answers
3
active
oldest
votes
active
oldest
votes
active
oldest
votes
$begingroup$
Exact numeric expressions are treated symbolically, and there are a very limited number of transformations that will be applied automatically. Adding "actual numbers" (see NumberQ
) is one such transformation that occurs. But E^((-2*I)/3*Pi)
is not converted to a number, unless such a transformation is explicitly requested (as is done by Simplify
, ComplexExpand
, and so forth). A similar thing happens with the following:
Total@ArcTan@Range@3
(* π/4 + ArcTan[2] + ArcTan[3] *)
FullSimplify[%]
(* π *)
$endgroup$
add a comment |
$begingroup$
Exact numeric expressions are treated symbolically, and there are a very limited number of transformations that will be applied automatically. Adding "actual numbers" (see NumberQ
) is one such transformation that occurs. But E^((-2*I)/3*Pi)
is not converted to a number, unless such a transformation is explicitly requested (as is done by Simplify
, ComplexExpand
, and so forth). A similar thing happens with the following:
Total@ArcTan@Range@3
(* π/4 + ArcTan[2] + ArcTan[3] *)
FullSimplify[%]
(* π *)
$endgroup$
add a comment |
$begingroup$
Exact numeric expressions are treated symbolically, and there are a very limited number of transformations that will be applied automatically. Adding "actual numbers" (see NumberQ
) is one such transformation that occurs. But E^((-2*I)/3*Pi)
is not converted to a number, unless such a transformation is explicitly requested (as is done by Simplify
, ComplexExpand
, and so forth). A similar thing happens with the following:
Total@ArcTan@Range@3
(* π/4 + ArcTan[2] + ArcTan[3] *)
FullSimplify[%]
(* π *)
$endgroup$
Exact numeric expressions are treated symbolically, and there are a very limited number of transformations that will be applied automatically. Adding "actual numbers" (see NumberQ
) is one such transformation that occurs. But E^((-2*I)/3*Pi)
is not converted to a number, unless such a transformation is explicitly requested (as is done by Simplify
, ComplexExpand
, and so forth). A similar thing happens with the following:
Total@ArcTan@Range@3
(* π/4 + ArcTan[2] + ArcTan[3] *)
FullSimplify[%]
(* π *)
edited Feb 2 at 22:25
answered Feb 2 at 22:18
Michael E2Michael E2
149k12200480
149k12200480
add a comment |
add a comment |
$begingroup$
sum = Total[{1, E^(2*I/3*Pi), E^((4*I)/3*Pi)}]
(* 1+E^(-((2 I π)/3))+E^((2 I π)/3) *)
Using machine precision, the sum is not identically zero
sum // N
(* 4.44089*10^-16+0. I *)
In fact, basic symbolic and numerical methods used internally do not show that sum
has value zero
sum // PossibleZeroQ
(* PossibleZeroQ::ztest1: Unable to decide whether numeric quantity
1-(-1)^(1/3)+(-1)^(2/3) is equal to zero. Assuming it is.
True *)
Consequently, sum
does not automatically evaluate to zero. More robust methods are required such as
#@sum& /@ {Simplify, ComplexExpand, RootReduce}
(* {0,0,0} *)
$endgroup$
add a comment |
$begingroup$
sum = Total[{1, E^(2*I/3*Pi), E^((4*I)/3*Pi)}]
(* 1+E^(-((2 I π)/3))+E^((2 I π)/3) *)
Using machine precision, the sum is not identically zero
sum // N
(* 4.44089*10^-16+0. I *)
In fact, basic symbolic and numerical methods used internally do not show that sum
has value zero
sum // PossibleZeroQ
(* PossibleZeroQ::ztest1: Unable to decide whether numeric quantity
1-(-1)^(1/3)+(-1)^(2/3) is equal to zero. Assuming it is.
True *)
Consequently, sum
does not automatically evaluate to zero. More robust methods are required such as
#@sum& /@ {Simplify, ComplexExpand, RootReduce}
(* {0,0,0} *)
$endgroup$
add a comment |
$begingroup$
sum = Total[{1, E^(2*I/3*Pi), E^((4*I)/3*Pi)}]
(* 1+E^(-((2 I π)/3))+E^((2 I π)/3) *)
Using machine precision, the sum is not identically zero
sum // N
(* 4.44089*10^-16+0. I *)
In fact, basic symbolic and numerical methods used internally do not show that sum
has value zero
sum // PossibleZeroQ
(* PossibleZeroQ::ztest1: Unable to decide whether numeric quantity
1-(-1)^(1/3)+(-1)^(2/3) is equal to zero. Assuming it is.
True *)
Consequently, sum
does not automatically evaluate to zero. More robust methods are required such as
#@sum& /@ {Simplify, ComplexExpand, RootReduce}
(* {0,0,0} *)
$endgroup$
sum = Total[{1, E^(2*I/3*Pi), E^((4*I)/3*Pi)}]
(* 1+E^(-((2 I π)/3))+E^((2 I π)/3) *)
Using machine precision, the sum is not identically zero
sum // N
(* 4.44089*10^-16+0. I *)
In fact, basic symbolic and numerical methods used internally do not show that sum
has value zero
sum // PossibleZeroQ
(* PossibleZeroQ::ztest1: Unable to decide whether numeric quantity
1-(-1)^(1/3)+(-1)^(2/3) is equal to zero. Assuming it is.
True *)
Consequently, sum
does not automatically evaluate to zero. More robust methods are required such as
#@sum& /@ {Simplify, ComplexExpand, RootReduce}
(* {0,0,0} *)
answered Feb 3 at 0:42
Bob HanlonBob Hanlon
60.8k33597
60.8k33597
add a comment |
add a comment |
$begingroup$
Try
sum = Total[{1, E^(2*I/3*Pi), E^((4*I)/3*Pi)}] // ExpToTrig
(*0*)
$endgroup$
add a comment |
$begingroup$
Try
sum = Total[{1, E^(2*I/3*Pi), E^((4*I)/3*Pi)}] // ExpToTrig
(*0*)
$endgroup$
add a comment |
$begingroup$
Try
sum = Total[{1, E^(2*I/3*Pi), E^((4*I)/3*Pi)}] // ExpToTrig
(*0*)
$endgroup$
Try
sum = Total[{1, E^(2*I/3*Pi), E^((4*I)/3*Pi)}] // ExpToTrig
(*0*)
answered Feb 3 at 16:28
Ulrich NeumannUlrich Neumann
9,568617
9,568617
add a comment |
add a comment |
$begingroup$
Is there some reason to expect any result other than the one indicates? Stated differently, what result is expected from
1+ E^((-2*I)/3*Pi)+E^((2*I)/3*Pi)
? Or, for that matter, from just adding the last two terms:E^((-2*I)/3*Pi)+E^((2*I)/3*Pi)
?$endgroup$
– Daniel Lichtblau
Feb 3 at 15:08
$begingroup$
@DanielLichtblau As there exists a much simpler representation I expected Mathematica to find that, just as it finds the most "simple" representation of a fraction or a sum. (I mean it would not return a fraction like
4/10
or a sum like1+2+3
.) Of course such simple sums might be easier to compute, but the original sum that I was referring to was also just an algebraic expression which are computationally not too difficult to simplify.$endgroup$
– flawr
Feb 3 at 15:27
3
$begingroup$
Arithmetic involves basic evaluation so for example entering
1+2+3
will give6
. But finding "simplest" forms in general is outside the scope of the core evaluator. Functions such asSimplify
can be used for this purpose.$endgroup$
– Daniel Lichtblau
Feb 3 at 15:31