How to evaluate sum with one million summands?Plotting a Double SumHow to correctly implement in a new function the scoping behavior of Table, Sum and other commands that use Block to localize iterators?Mathematica Infinite Summation ConfusionGet Mathematica to Apply Chu-Vandermonde ConvolutionFinding given sums over one variable in sums over multiple variablesHow to work out sums symbolically?Why is $sumlimits_k=1^100 0.01 $ different than $sumlimits_k=1^100 frac1100$?Perform an explicit summation, if possible, over a restricted range of two indices both varying from 0 to infinityHandling cases of cross terms for multi-sumsHow to optimize Mathematica code that depends on eigenvalues of big matrices and big sums?

What food production methods would allow a metropolis like New York to become self sufficient

Cryptography and elliptic curves

Why does increasing the sampling rate make implementing an anti-aliasing filter easier?

Can a surprised creature fall prone voluntarily on their turn?

Was the Highlands Ranch shooting the 115th mass shooting in the US in 2019

Why use steam instead of just hot air?

Has there been evidence of any other gods?

Company threw a surprise party for the CEO, 3 weeks later management says we have to pay for it, do I have to?

What can cause an unfrozen indoor copper drain pipe to crack?

The concept of information structure in incomplete information games

What was the plan for an abort of the Enola Gay's mission to drop the atomic bomb?

How can I avoid subordinates and coworkers leaving work until the last minute, then having no time for revisions?

Is it nonsense to say B > [A > B]?

Is every story set in the future "science fiction"?

Why is the Sun made of light elements only?

What does formal training in a field mean?

What does this quote in Small Gods refer to?

What's the "magic similar to the Knock spell" referenced in the Dungeon of the Mad Mage adventure?

Exception propagation: When to catch exceptions?

How to efficiently lower your karma

My perfect evil overlord plan... or is it?

When do you stop "pushing" a book?

Why does it take longer to fly from London to Xi'an than to Beijing

How can a demonic viral infection spread throughout the body without being noticed?



How to evaluate sum with one million summands?


Plotting a Double SumHow to correctly implement in a new function the scoping behavior of Table, Sum and other commands that use Block to localize iterators?Mathematica Infinite Summation ConfusionGet Mathematica to Apply Chu-Vandermonde ConvolutionFinding given sums over one variable in sums over multiple variablesHow to work out sums symbolically?Why is $sumlimits_k=1^100 0.01 $ different than $sumlimits_k=1^100 frac1100$?Perform an explicit summation, if possible, over a restricted range of two indices both varying from 0 to infinityHandling cases of cross terms for multi-sumsHow to optimize Mathematica code that depends on eigenvalues of big matrices and big sums?













2












$begingroup$


For a research project I am working on currently, I need to do a very simple and straightforward calculation. Unfortunately, I do not know how to include Mathematica code here, but it is very short anyway:



b[x_] := x^2 - x + 1/2

bp[x_] := b[Mod[x, 1]]

d[n_, q_] := Sum[bp[k/n]* bp[q*k/n], k, 0, n - 1]


Now I need to compare two values of d[n,q], in particular, I need to calculate
d[1346269,514229] and d[1346269,1137064] to see which one is larger. It works perfectly fine for smaller numbers, e.g. I tried d[75025, 28657] and got the correct result in a reasonable amount of time. However, when I tried evaluating d[1346269,514229] after some time I got the result



(1/9760128332100732436)(4744910246749618660646829 - 
4880064166050366218 Hold[$ConditionHold[$ConditionHold[
System`Dump`AutoLoad[Hold[Sum`InfiniteSum],
Hold[Sum`InfiniteSum, Sum`SumInfiniteRationalSeries,
Sum`SumInfiniteRationalExponentialSeries,
Sum`SumInfiniteLogarithmicSeries,
Sum`SumInfiniteBernoulliSeries,
Sum`SumInfiniteFibonacciSeries, Sum`SumInfiniteLucasLSeries,
Sum`SumInfiniteArcTangentSeries,
Sum`SumInfiniteArcCotangentSeries,
Sum`SumInfiniteqArcTangentSeries,
Sum`SumInfiniteqArcCotangentSeries,
Sum`SumInfiniteStirlingNumberSeries,
Sum`SumInfiniteqRationalSeries], "Sum`InfiniteSum`"]]]][(1 -
Ceiling[(1 - Sum`FiniteSumDump`l)/1346269] +
Floor[(1346268 - Sum`FiniteSumDump`l)/1346269]) Mod[(
514229 Sum`FiniteSumDump`l)/1346269, 1], Sum`FiniteSumDump`l,
0, 1346268, True])


Now, I am not too familiar with Mathematica, so I am not sure where the problem is exactly. However, I would need the two results of d[1346269,1137064] and d[1346269,514229] exactly (i.e. not numerically) as they are super close together, so any rounding could already change the results sufficiently much to alter the order of the two. Is there any way of computing those sums symbolically?










share|improve this question











$endgroup$
















    2












    $begingroup$


    For a research project I am working on currently, I need to do a very simple and straightforward calculation. Unfortunately, I do not know how to include Mathematica code here, but it is very short anyway:



    b[x_] := x^2 - x + 1/2

    bp[x_] := b[Mod[x, 1]]

    d[n_, q_] := Sum[bp[k/n]* bp[q*k/n], k, 0, n - 1]


    Now I need to compare two values of d[n,q], in particular, I need to calculate
    d[1346269,514229] and d[1346269,1137064] to see which one is larger. It works perfectly fine for smaller numbers, e.g. I tried d[75025, 28657] and got the correct result in a reasonable amount of time. However, when I tried evaluating d[1346269,514229] after some time I got the result



    (1/9760128332100732436)(4744910246749618660646829 - 
    4880064166050366218 Hold[$ConditionHold[$ConditionHold[
    System`Dump`AutoLoad[Hold[Sum`InfiniteSum],
    Hold[Sum`InfiniteSum, Sum`SumInfiniteRationalSeries,
    Sum`SumInfiniteRationalExponentialSeries,
    Sum`SumInfiniteLogarithmicSeries,
    Sum`SumInfiniteBernoulliSeries,
    Sum`SumInfiniteFibonacciSeries, Sum`SumInfiniteLucasLSeries,
    Sum`SumInfiniteArcTangentSeries,
    Sum`SumInfiniteArcCotangentSeries,
    Sum`SumInfiniteqArcTangentSeries,
    Sum`SumInfiniteqArcCotangentSeries,
    Sum`SumInfiniteStirlingNumberSeries,
    Sum`SumInfiniteqRationalSeries], "Sum`InfiniteSum`"]]]][(1 -
    Ceiling[(1 - Sum`FiniteSumDump`l)/1346269] +
    Floor[(1346268 - Sum`FiniteSumDump`l)/1346269]) Mod[(
    514229 Sum`FiniteSumDump`l)/1346269, 1], Sum`FiniteSumDump`l,
    0, 1346268, True])


    Now, I am not too familiar with Mathematica, so I am not sure where the problem is exactly. However, I would need the two results of d[1346269,1137064] and d[1346269,514229] exactly (i.e. not numerically) as they are super close together, so any rounding could already change the results sufficiently much to alter the order of the two. Is there any way of computing those sums symbolically?










    share|improve this question











    $endgroup$














      2












      2








      2





      $begingroup$


      For a research project I am working on currently, I need to do a very simple and straightforward calculation. Unfortunately, I do not know how to include Mathematica code here, but it is very short anyway:



      b[x_] := x^2 - x + 1/2

      bp[x_] := b[Mod[x, 1]]

      d[n_, q_] := Sum[bp[k/n]* bp[q*k/n], k, 0, n - 1]


      Now I need to compare two values of d[n,q], in particular, I need to calculate
      d[1346269,514229] and d[1346269,1137064] to see which one is larger. It works perfectly fine for smaller numbers, e.g. I tried d[75025, 28657] and got the correct result in a reasonable amount of time. However, when I tried evaluating d[1346269,514229] after some time I got the result



      (1/9760128332100732436)(4744910246749618660646829 - 
      4880064166050366218 Hold[$ConditionHold[$ConditionHold[
      System`Dump`AutoLoad[Hold[Sum`InfiniteSum],
      Hold[Sum`InfiniteSum, Sum`SumInfiniteRationalSeries,
      Sum`SumInfiniteRationalExponentialSeries,
      Sum`SumInfiniteLogarithmicSeries,
      Sum`SumInfiniteBernoulliSeries,
      Sum`SumInfiniteFibonacciSeries, Sum`SumInfiniteLucasLSeries,
      Sum`SumInfiniteArcTangentSeries,
      Sum`SumInfiniteArcCotangentSeries,
      Sum`SumInfiniteqArcTangentSeries,
      Sum`SumInfiniteqArcCotangentSeries,
      Sum`SumInfiniteStirlingNumberSeries,
      Sum`SumInfiniteqRationalSeries], "Sum`InfiniteSum`"]]]][(1 -
      Ceiling[(1 - Sum`FiniteSumDump`l)/1346269] +
      Floor[(1346268 - Sum`FiniteSumDump`l)/1346269]) Mod[(
      514229 Sum`FiniteSumDump`l)/1346269, 1], Sum`FiniteSumDump`l,
      0, 1346268, True])


      Now, I am not too familiar with Mathematica, so I am not sure where the problem is exactly. However, I would need the two results of d[1346269,1137064] and d[1346269,514229] exactly (i.e. not numerically) as they are super close together, so any rounding could already change the results sufficiently much to alter the order of the two. Is there any way of computing those sums symbolically?










      share|improve this question











      $endgroup$




      For a research project I am working on currently, I need to do a very simple and straightforward calculation. Unfortunately, I do not know how to include Mathematica code here, but it is very short anyway:



      b[x_] := x^2 - x + 1/2

      bp[x_] := b[Mod[x, 1]]

      d[n_, q_] := Sum[bp[k/n]* bp[q*k/n], k, 0, n - 1]


      Now I need to compare two values of d[n,q], in particular, I need to calculate
      d[1346269,514229] and d[1346269,1137064] to see which one is larger. It works perfectly fine for smaller numbers, e.g. I tried d[75025, 28657] and got the correct result in a reasonable amount of time. However, when I tried evaluating d[1346269,514229] after some time I got the result



      (1/9760128332100732436)(4744910246749618660646829 - 
      4880064166050366218 Hold[$ConditionHold[$ConditionHold[
      System`Dump`AutoLoad[Hold[Sum`InfiniteSum],
      Hold[Sum`InfiniteSum, Sum`SumInfiniteRationalSeries,
      Sum`SumInfiniteRationalExponentialSeries,
      Sum`SumInfiniteLogarithmicSeries,
      Sum`SumInfiniteBernoulliSeries,
      Sum`SumInfiniteFibonacciSeries, Sum`SumInfiniteLucasLSeries,
      Sum`SumInfiniteArcTangentSeries,
      Sum`SumInfiniteArcCotangentSeries,
      Sum`SumInfiniteqArcTangentSeries,
      Sum`SumInfiniteqArcCotangentSeries,
      Sum`SumInfiniteStirlingNumberSeries,
      Sum`SumInfiniteqRationalSeries], "Sum`InfiniteSum`"]]]][(1 -
      Ceiling[(1 - Sum`FiniteSumDump`l)/1346269] +
      Floor[(1346268 - Sum`FiniteSumDump`l)/1346269]) Mod[(
      514229 Sum`FiniteSumDump`l)/1346269, 1], Sum`FiniteSumDump`l,
      0, 1346268, True])


      Now, I am not too familiar with Mathematica, so I am not sure where the problem is exactly. However, I would need the two results of d[1346269,1137064] and d[1346269,514229] exactly (i.e. not numerically) as they are super close together, so any rounding could already change the results sufficiently much to alter the order of the two. Is there any way of computing those sums symbolically?







      summation






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited 2 hours ago









      Carl Lange

      6,15911447




      6,15911447










      asked 3 hours ago









      Analysis801Analysis801

      383




      383




















          1 Answer
          1






          active

          oldest

          votes


















          5












          $begingroup$

          I find that this evaluates much faster. Mathematica is much faster at evaluating functions with a list of 1 million data points than it is at evaluate a function 1 million times with a single point each.



          b[x] := x^2 - x + 1/2
          bp[x_] := b[Mod[x, 1]]
          d[n_, q_] := Total[bp[Range[0, n - 1]/n] bp[q Range[0, n - 1]/n]]
          d[1346269, 1137064]


          This takes about 17 seconds to evaluate on my machine and gives me:



          $frac14599731344021534525766739760128332100732436$



          Evaluating d[1346269, 514229] gives me:



          $frac14599731343994714468596179760128332100732436$



          The difference is:



          $frac6705014292642440032083025183109$



          Evaluated to 100 digits with N[difference, 100], I get



          2.74792054550653169316510562953899839764312057350982296551104800194 089580643554604005134744886010933307817655482572397565420836194
          $cdot 10^-7$






          share|improve this answer









          $endgroup$













            Your Answer








            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%2f198049%2fhow-to-evaluate-sum-with-one-million-summands%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown

























            1 Answer
            1






            active

            oldest

            votes








            1 Answer
            1






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            5












            $begingroup$

            I find that this evaluates much faster. Mathematica is much faster at evaluating functions with a list of 1 million data points than it is at evaluate a function 1 million times with a single point each.



            b[x] := x^2 - x + 1/2
            bp[x_] := b[Mod[x, 1]]
            d[n_, q_] := Total[bp[Range[0, n - 1]/n] bp[q Range[0, n - 1]/n]]
            d[1346269, 1137064]


            This takes about 17 seconds to evaluate on my machine and gives me:



            $frac14599731344021534525766739760128332100732436$



            Evaluating d[1346269, 514229] gives me:



            $frac14599731343994714468596179760128332100732436$



            The difference is:



            $frac6705014292642440032083025183109$



            Evaluated to 100 digits with N[difference, 100], I get



            2.74792054550653169316510562953899839764312057350982296551104800194 089580643554604005134744886010933307817655482572397565420836194
            $cdot 10^-7$






            share|improve this answer









            $endgroup$

















              5












              $begingroup$

              I find that this evaluates much faster. Mathematica is much faster at evaluating functions with a list of 1 million data points than it is at evaluate a function 1 million times with a single point each.



              b[x] := x^2 - x + 1/2
              bp[x_] := b[Mod[x, 1]]
              d[n_, q_] := Total[bp[Range[0, n - 1]/n] bp[q Range[0, n - 1]/n]]
              d[1346269, 1137064]


              This takes about 17 seconds to evaluate on my machine and gives me:



              $frac14599731344021534525766739760128332100732436$



              Evaluating d[1346269, 514229] gives me:



              $frac14599731343994714468596179760128332100732436$



              The difference is:



              $frac6705014292642440032083025183109$



              Evaluated to 100 digits with N[difference, 100], I get



              2.74792054550653169316510562953899839764312057350982296551104800194 089580643554604005134744886010933307817655482572397565420836194
              $cdot 10^-7$






              share|improve this answer









              $endgroup$















                5












                5








                5





                $begingroup$

                I find that this evaluates much faster. Mathematica is much faster at evaluating functions with a list of 1 million data points than it is at evaluate a function 1 million times with a single point each.



                b[x] := x^2 - x + 1/2
                bp[x_] := b[Mod[x, 1]]
                d[n_, q_] := Total[bp[Range[0, n - 1]/n] bp[q Range[0, n - 1]/n]]
                d[1346269, 1137064]


                This takes about 17 seconds to evaluate on my machine and gives me:



                $frac14599731344021534525766739760128332100732436$



                Evaluating d[1346269, 514229] gives me:



                $frac14599731343994714468596179760128332100732436$



                The difference is:



                $frac6705014292642440032083025183109$



                Evaluated to 100 digits with N[difference, 100], I get



                2.74792054550653169316510562953899839764312057350982296551104800194 089580643554604005134744886010933307817655482572397565420836194
                $cdot 10^-7$






                share|improve this answer









                $endgroup$



                I find that this evaluates much faster. Mathematica is much faster at evaluating functions with a list of 1 million data points than it is at evaluate a function 1 million times with a single point each.



                b[x] := x^2 - x + 1/2
                bp[x_] := b[Mod[x, 1]]
                d[n_, q_] := Total[bp[Range[0, n - 1]/n] bp[q Range[0, n - 1]/n]]
                d[1346269, 1137064]


                This takes about 17 seconds to evaluate on my machine and gives me:



                $frac14599731344021534525766739760128332100732436$



                Evaluating d[1346269, 514229] gives me:



                $frac14599731343994714468596179760128332100732436$



                The difference is:



                $frac6705014292642440032083025183109$



                Evaluated to 100 digits with N[difference, 100], I get



                2.74792054550653169316510562953899839764312057350982296551104800194 089580643554604005134744886010933307817655482572397565420836194
                $cdot 10^-7$







                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered 2 hours ago









                MassDefectMassDefect

                2,685311




                2,685311



























                    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%2f198049%2fhow-to-evaluate-sum-with-one-million-summands%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

                    Canceling a color specificationRandomly assigning color to Graphics3D objects?Default color for Filling in Mathematica 9Coloring specific elements of sets with a prime modified order in an array plotHow to pick a color differing significantly from the colors already in a given color list?Detection of the text colorColor numbers based on their valueCan color schemes for use with ColorData include opacity specification?My dynamic color schemes

                    Invision Community Contents History See also References External links Navigation menuProprietaryinvisioncommunity.comIPS Community ForumsIPS Community Forumsthis blog entry"License Changes, IP.Board 3.4, and the Future""Interview -- Matt Mecham of Ibforums""CEO Invision Power Board, Matt Mecham Is a Liar, Thief!"IPB License Explanation 1.3, 1.3.1, 2.0, and 2.1ArchivedSecurity Fixes, Updates And Enhancements For IPB 1.3.1Archived"New Demo Accounts - Invision Power Services"the original"New Default Skin"the original"Invision Power Board 3.0.0 and Applications Released"the original"Archived copy"the original"Perpetual licenses being done away with""Release Notes - Invision Power Services""Introducing: IPS Community Suite 4!"Invision Community Release Notes

                    François Viète Contents Biography Work and thought Bibliography See also Notes Further reading External links Navigation menup. 21Google Bookspp. 75–77Google BooksDe thou (from University of Saint Andrews)ArchivedGoogle BooksGoogle BooksGoogle BooksGoogle booksGoogle Bookscc-parthenay.frL'histoire universelle (fr)Universal History (en)ArchivedAdsabs.harvard.eduPagesperso-orange.frArchive.orgChikara Sasaki. Descartes' mathematical thought p.259Google BooksGoogle BooksGoogle Bookspp. 152 and onwardGoogle BooksGoogle BooksScribd.comGoogle Books1257-7979Google BooksGoogle BooksGoogle BooksGoogle BooksGoogle BooksGoogle BooksGallica.bnf.frGoogle BooksGoogle Books"François Viète"Francois Viète: Father of Modern Algebraic NotationThe Lawyer and the GamblerAbout TarporleySite de Jean-Paul GuichardL'algèbre nouvelle"About the Harmonicon"cb120511976(data)1188044800000 0001 0913 5903n82164680ola2013766880073431702w6vt1sb70287374827140948071409480