- #1
- 912
- 583
- TL;DR Summary
- Does Mathematica optimize the calculation of a series of partial sums automatically?
In this example,
will Mathematica automatically optimize the procedure -- i.e., will it run a single loop where it calculates the sum up to 20 only once, transferring the partial sums to the output as it goes along? Assume that there is no formula for the sum of f[x], so it has to actually add the terms up one by one.
Code:
DiscretePlot[ Sum[ f[x], {x,1,n} ],{n,1,20}]