Why is expression not evaluated completely?
$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$
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$
$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
14 hours ago
$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
14 hours ago
2
$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
14 hours ago
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 yesterday
flawrflawr
1205
1205
$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
14 hours ago
$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
14 hours ago
2
$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
14 hours ago
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
14 hours ago
$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
14 hours ago
2
$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
14 hours ago
$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
14 hours ago
$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
14 hours ago
$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
14 hours ago
$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
14 hours ago
2
2
$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
14 hours ago
$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
14 hours ago
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 |
Your Answer
StackExchange.ifUsing("editor", function () {
return StackExchange.using("mathjaxEditing", function () {
StackExchange.MarkdownEditor.creationCallbacks.add(function (editor, postfix) {
StackExchange.mathjaxEditing.prepareWmdForMathJax(editor, postfix, [["$", "$"], ["\\(","\\)"]]);
});
});
}, "mathjax-editing");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "387"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmathematica.stackexchange.com%2fquestions%2f190740%2fwhy-is-expression-not-evaluated-completely%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
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 yesterday
answered yesterday
Michael E2Michael E2
147k12197470
147k12197470
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 yesterday
Bob HanlonBob Hanlon
59.8k33596
59.8k33596
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 13 hours ago
Ulrich NeumannUlrich Neumann
8,487516
8,487516
add a comment |
add a comment |
Thanks for contributing an answer to Mathematica Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
Use MathJax to format equations. MathJax reference.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmathematica.stackexchange.com%2fquestions%2f190740%2fwhy-is-expression-not-evaluated-completely%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
$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
14 hours ago
$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
14 hours ago
2
$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
14 hours ago