Why is expression not evaluated completely? [closed]












3












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



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








  • 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
















3












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



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








  • 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














3












3








3


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








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








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










3 Answers
3






active

oldest

votes


















7












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





















    4












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

      Try



      sum = Total[{1, E^(2*I/3*Pi), E^((4*I)/3*Pi)}] // ExpToTrig
      (*0*)





      share|improve this answer









      $endgroup$




















        3 Answers
        3






        active

        oldest

        votes








        3 Answers
        3






        active

        oldest

        votes









        active

        oldest

        votes






        active

        oldest

        votes









        7












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


















          7












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
















            7












            7








            7





            $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 Feb 2 at 22:25

























            answered Feb 2 at 22:18









            Michael E2Michael E2

            149k12200480




            149k12200480























                4












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


















                  4












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
















                    4












                    4








                    4





                    $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 Feb 3 at 0:42









                    Bob HanlonBob Hanlon

                    60.8k33597




                    60.8k33597























                        1












                        $begingroup$

                        Try



                        sum = Total[{1, E^(2*I/3*Pi), E^((4*I)/3*Pi)}] // ExpToTrig
                        (*0*)





                        share|improve this answer









                        $endgroup$


















                          1












                          $begingroup$

                          Try



                          sum = Total[{1, E^(2*I/3*Pi), E^((4*I)/3*Pi)}] // ExpToTrig
                          (*0*)





                          share|improve this answer









                          $endgroup$
















                            1












                            1








                            1





                            $begingroup$

                            Try



                            sum = Total[{1, E^(2*I/3*Pi), E^((4*I)/3*Pi)}] // ExpToTrig
                            (*0*)





                            share|improve this answer









                            $endgroup$



                            Try



                            sum = Total[{1, E^(2*I/3*Pi), E^((4*I)/3*Pi)}] // ExpToTrig
                            (*0*)






                            share|improve this answer












                            share|improve this answer



                            share|improve this answer










                            answered Feb 3 at 16:28









                            Ulrich NeumannUlrich Neumann

                            9,568617




                            9,568617















                                Popular posts from this blog

                                Questions related to Moebius Transform of Characteristic Function of the Primes

                                List of scandals in India

                                Can not write log (Is /dev/pts mounted?) - openpty in Ubuntu-on-Windows?