ArticleslgStudy

computer science

Summation algorithm

Summation algorithm is a computer science topic covered in the lgStudy science library. This page brings together a partial reference excerpt, illustrations, worked examples, real-world applications and a short study plan, so you can understand Summation algorithm rather than just read about it. In short: A summation algorithm is an algorithm that computes the sum of a finite list of numbers ∑ L [ i ] {\textstyle \sum L[i]} . It is especially relevant in floating-point arithmetic where the associative property ( a + b ) + c = a + ( b + c ) {\displaystyle (a+b)+c=a+(b+c)} does not hold like it does in (mathematical) real numbers, rational numbers, fixed-point numbers, and unsigned integers, so that the order of calcul…

Key takeaways

  • Summation algorithm belongs to computer science; place it in that map before memorising details.
  • Learn the definition first, then one example that makes the definition concrete.
  • Connect Summation algorithm to a quantity you can measure, compute or draw — that is where exam questions come from.
  • Reproduce the core statement of Summation algorithm from memory before moving on to harder problems.

Reference excerpt

A summation algorithm is an algorithm that computes the sum of a finite list of numbers ∑ L [ i ] {\textstyle \sum L[i]} . It is especially relevant in floating-point arithmetic where the associative property ( a + b ) + c = a + ( b + c ) {\displaystyle (a+b)+c=a+(b+c)} does not hold like it does in (mathematical) real numbers, rational numbers, fixed-point numbers, and unsigned integers, so that the order of calculation can affect the final result. A closely related problem is the calculation of dot products, both of which have numerous proposed algorithms that differ in terms of simplicity, speed (single-thread and parallelized), and accuracy..

Background Floating-point works similarly to a scientific notation with a limited range on the exponent and a limited number of digits on the significand (left part, mantissa). When numbers of very different magnitudes (absolute values) are added together, the result may be unchanged from the one with the larger magnitude, making any information in the smaller one lost. When numbers of very similar magnitudes but of opposite signs are added together, cancellation results, with all but the most inaccurate digits being 0 in the result, with potentially catastrophic consequences for precision. More concretely, the summation operator "+" of floating-point arithmetic is correctly-rounded, i.e. it has to match the rounding mode currently set. In the case of the two "to nearest" modes, the error is guaranteed to be ≤ 0.5 ulp, and for the other modes ≤ 1 ulp; in all cases, it is deterministic. A ulp is a unit in the last place: the magnitude difference represented by the last digit of the mantissa changing from a 0 to 1, and its own magnitude is determined by the exponent. The error incurred by floating-point rules, relative to the ideal of infinite-precision arithmetic, is called the roundoff error. For the basic case of calculating a + b {\displaystyle a+b} versus its floating-point version a ⊕ b {\displaystyle a\oplus b} , an algorithm called 2Sum gives both s := a ⊕ b {\displaystyle s:=a\oplus b} and the exact error t = a + b − ( a ⊕ b ) {\displaystyle t=a+b-(a\oplus b)} . 2Sum forms the basis of many accurate summation algorithms. The intrinsic sensitivity of asummation problem to errors, regardless of how it is computed, is called its condition number and is defined as κ ( L ) = ∑ | L i | / | ∑ | L i | {\textstyle \kappa (L)=\sum |L_{i}|/|\sum |L_{i}|} . The inherent error from machine precision is notated as ε {\displaystyle \varepsilon } .

Naive summation Naive summation works simply by going over the numbers one-by-one, calculating

function sumNaive(L) var sum = 0.0 for i = 1 to L.length do sum = sum + L[i] return sum

The worst-case error for a list L of length n is O ( n ε κ ( L ) ) {\displaystyle O(n\,\varepsilon \kappa (L))} , corresponding to a case where the rounding errors all add up in the same direction. The average error, corresponding to a random walk of roundoff errors, is O ( n ε κ ( L ) ) {\displaystyle O\left({\sqrt {n}}\,\varepsilon \kappa (L)\right)} . Naive summation also has a batched version, blocked summation, which entails dividing L into a number of smaller lists, summing each of them naively, then summing the sums naively. This is usually done to allow parallel computation. It also reduces the error growth by a factor of 1/b.

Precise summation On the other extreme of speed-accuracy tradeoff, the correctly-rounded ∑ L [ i ] {\textstyle \sum L[i]} may be computed. Naively this may be done via arbitrary-precision arithmetic, but more efficient methods exist:

Shewchuk's method, an adaptive method making use of Floating-point expansions. This can take anywhere from linear (optimistic, and near typical) to quadratic time complexity and anywhere from constant to linear space complexity. Kirchner and Kulisch's superaccumulator method, which only uses integer arithmetic. a hardware implementation was described by Müller, Rüb and Rülling. Zhu and Hayes's HybridSum, which splits into different accumulators by the floating-point exponent field. Uses iFastSum (below) for the final sum. Neal's xsum, two superaccumulator methods optimized for 64-bit processors. Integer-only for the main phase of accumulation. The small superaccumulator is 67 64-bit integers covering the whole exponent range, with carry-propagation so it can act like a 2176-bit integer. The large superaccumulator, used when the array is very large, collects a partial sum for every possible combination of exponent bits and sign bit to ease the load on the small superaccumulator. Zhu and Hayes's iFastSum, a "distillation" method that performs multiple passes of compensated summation.

… excerpt ends here. Continue reading the full article.

Worked examples

Example 1 — a first encounter with Summation algorithm

Start with the simplest possible case. Write down what Summation algorithm claims or describes in one sentence, then invent the smallest concrete situation in which that sentence is true. In computer science, the smallest case is usually a single object, a single equation or a single measurement. Check that every symbol or term in your sentence has a meaning in that case.

Example 2 — changing one variable

Take the situation from Example 1 and change exactly one quantity: double it, halve it, or set it to zero. Predict what should happen to Summation algorithm before you calculate. Comparing your prediction with the result is the fastest way to find out whether you understand the idea or only the words.

Example 3 — an exam-style question

Typical questions about Summation algorithm ask you to (a) state it precisely, (b) apply it to given data, and (c) explain a limitation. Practise writing all three answers in under five minutes; the third part is what separates a full-mark answer from an average one.

Applications of Summation algorithm

In research
Summation algorithm appears in computer science research whenever the underlying quantities have to be modelled precisely. Papers usually cite it as a starting assumption and then explore where it breaks down.
In technology and industry
Engineering practice reuses Summation algorithm in design rules, simulations and safety margins. Knowing the idea lets you read a specification sheet and understand why the numbers look the way they do.
In the classroom
Summation algorithm is common in secondary-school and first-year university syllabi. It links to neighbouring topics Computer arithmetic, Floating point, Numerical analysis, so understanding it makes those chapters shorter.
In everyday life
Look for Summation algorithm outside the textbook — in sport, cooking, traffic, electronics or the sky above you. An example you found yourself is remembered far longer than one you were given.

Affiliate

Preply — study more efficiently by working with a personal tutor. 50% off.

How to study Summation algorithm in 20 minutes

  1. Read the reference excerpt below once, without taking notes.
  2. Close the page and write down what Summation algorithm means in your own words.
  3. Compare your version with the excerpt and mark what you missed.
  4. Work through the three examples above with pen and paper.
  5. Explain Summation algorithm out loud to somebody else — or to Teacher Smith in the lgStudy chat.

Frequently asked questions

What is Summation algorithm in simple terms?

A summation algorithm is an algorithm that computes the sum of a finite list of numbers ∑ L [ i ] {\textstyle \sum L[i]} . It is especially relevant in floating-point arithmetic where the associative property ( a + b ) + c = a + ( b + c ) {\displaystyle (a+b)+c=a+(b+c)} does not hold like it does i…

Why does Summation algorithm matter?

Because it connects several computer science ideas at once: it gives you a definition you can apply, a quantity you can calculate, and a way to check whether a result is plausible.

How should I study Summation algorithm?

Read the excerpt, restate it from memory, then work through the examples and applications listed on this page. The five-step study plan above takes about twenty minutes.

What does this page cover?

It gives you a compact reference excerpt plus original lgStudy explanations, examples, applications and study material on Summation algorithm.

Tags

  • Computer arithmetic
  • Floating point
  • Numerical analysis

Keep exploring