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?
$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 calculated[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
$endgroup$
add a comment |
$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 calculated[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
$endgroup$
add a comment |
$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 calculated[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
$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 calculated[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
summation
edited 2 hours ago
Carl Lange
6,15911447
6,15911447
asked 3 hours ago
Analysis801Analysis801
383
383
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
$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$
$endgroup$
add a comment |
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
);
);
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%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
$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$
$endgroup$
add a comment |
$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$
$endgroup$
add a comment |
$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$
$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$
answered 2 hours ago
MassDefectMassDefect
2,685311
2,685311
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%2f198049%2fhow-to-evaluate-sum-with-one-million-summands%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