Why is expression not evaluated completely?












1












$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?










share|improve this question









$endgroup$

















    1












    $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?










    share|improve this question









    $endgroup$















      1












      1








      1





      $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?










      share|improve this question









      $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






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked 4 hours ago









      flawrflawr

      1105




      1105






















          2 Answers
          2






          active

          oldest

          votes


















          6












          $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[%]
          (* π *)





          share|improve this answer











          $endgroup$





















            1












            $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} *)





            share|improve this answer









            $endgroup$













              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
              });


              }
              });














              draft saved

              draft discarded


















              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

























              2 Answers
              2






              active

              oldest

              votes








              2 Answers
              2






              active

              oldest

              votes









              active

              oldest

              votes






              active

              oldest

              votes









              6












              $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[%]
              (* π *)





              share|improve this answer











              $endgroup$


















                6












                $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[%]
                (* π *)





                share|improve this answer











                $endgroup$
















                  6












                  6








                  6





                  $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[%]
                  (* π *)





                  share|improve this answer











                  $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[%]
                  (* π *)






                  share|improve this answer














                  share|improve this answer



                  share|improve this answer








                  edited 3 hours ago

























                  answered 3 hours ago









                  Michael E2Michael E2

                  147k12197469




                  147k12197469























                      1












                      $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} *)





                      share|improve this answer









                      $endgroup$


















                        1












                        $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} *)





                        share|improve this answer









                        $endgroup$
















                          1












                          1








                          1





                          $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} *)





                          share|improve this answer









                          $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} *)






                          share|improve this answer












                          share|improve this answer



                          share|improve this answer










                          answered 1 hour ago









                          Bob HanlonBob Hanlon

                          59.6k33596




                          59.6k33596






























                              draft saved

                              draft discarded




















































                              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.




                              draft saved


                              draft discarded














                              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





















































                              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







                              Popular posts from this blog

                              How to make a Squid Proxy server?

                              第一次世界大戦

                              Touch on Surface Book