Pairwise summation

In numerical analysis, pairwise summation, also called cascade summation, is a technique to sum a sequence of finite-precision floating-point numbers that substantially reduces the accumulated round-off error compared to naively accumulating the sum in sequence.[1] Although there are other techniques such as Kahan summation that typically have even smaller round-off errors, pairwise summation is nearly as good (differing only by a logarithmic factor) while having much lower computational cost—it can be implemented so as to have nearly the same cost (and exactly the same number of arithmetic operations) as naive summation.

In particular, pairwise summation of a sequence of n numbers xn works by recursively breaking the sequence into two halves, summing each half, and adding the two sums: a divide and conquer algorithm. Its worst-case roundoff errors grow asymptotically as at most O(ε log n), where ε is the machine precision (assuming a fixed condition number, as discussed below).[1] In comparison, the naive technique of accumulating the sum in sequence (adding each xi one at a time for i = 1, ..., n) has roundoff errors that grow at worst as On).[1] Kahan summation has a worst-case error of roughly O(ε), independent of n, but requires several times more arithmetic operations.[1] If the roundoff errors are random, and in particular have random signs, then they form a random walk and the error growth is reduced to an average of for pairwise summation.[2]

A very similar recursive structure of summation is found in many fast Fourier transform (FFT) algorithms, and is responsible for the same slow roundoff accumulation of those FFTs.[2][3]

The algorithm

In pseudocode, the pairwise summation algorithm for an array x of length n ≥ 0 can be written:

s = pairwise(x[1...n])
      if nN     base case: naive summation for a sufficiently small array
          s = 0
          for i = 1 to n
              s = s + x[i]
      else         divide and conquer: recursively sum two halves of the array
          m = floor(n / 2)
          s = pairwise(x[1...m]) + pairwise(x[m+1...n])
      end if

For some sufficiently small N, this algorithm switches to a naive loop-based summation as a base case, whose error bound is O(Nε).[4] The entire sum has a worst-case error that grows asymptotically as O(ε log n) for large n, for a given condition number (see below).

In an algorithm of this sort (as for divide and conquer algorithms in general[5]), it is desirable to use a larger base case in order to amortize the overhead of the recursion. If N = 1, then there is roughly one recursive subroutine call for every input, but more generally there is one recursive call for (roughly) every N/2 inputs if the recursion stops at exactly n = N. By making N sufficiently large, the overhead of recursion can be made negligible (precisely this technique of a large base case for recursive summation is employed by high-performance FFT implementations[3]).

Regardless of N, exactly n−1 additions are performed in total, the same as for naive summation, so if the recursion overhead is made negligible then pairwise summation has essentially the same computational cost as for naive summation.

A variation on this idea is to break the sum into b blocks at each recursive stage, summing each block recursively, and then summing the results, which was dubbed a "superblock" algorithm by its proposers.[6] The above pairwise algorithm corresponds to b = 2 for every stage except for the last stage which is b = N.

Dalton, Wang & Blainey (2014) describe a iterative, "shift-reduce" formulation for pairwise summation. It can be unrolled and sped up using SIMD instructions. The non-unrolled version is:[7]

double shift_reduce_sum(double x, size_t n) {
  double stack[64], v;
  size_t p = 0;
  for (size_t i = 0; i < n; ++i) {
    v = x[i];                               // shift
    for (size_t b = 1; i & b; b <<= 1, −−p) // reduce
      v += stack[p1];
    stack[p++] = v;
  }
  double sum = 0.0;
  while (p)
    sum += stack[−−p];
  return sum;
}

Accuracy

Suppose that one is summing n values xi, for i = 1, ..., n. The exact sum is:

(computed with infinite precision).

With pairwise summation for a base case N = 1, one instead obtains , where the error is bounded above by:[1]

where ε is the machine precision of the arithmetic being employed (e.g. ε ≈ 10−16 for standard double precision floating point). Usually, the quantity of interest is the relative error , which is therefore bounded above by:

In the expression for the relative error bound, the fraction (Σ|xi|/|Σxi|) is the condition number of the summation problem. Essentially, the condition number represents the intrinsic sensitivity of the summation problem to errors, regardless of how it is computed.[8] The relative error bound of every (backwards stable) summation method by a fixed algorithm in fixed precision (i.e. not those that use arbitrary-precision arithmetic, nor algorithms whose memory and time requirements change based on the data), is proportional to this condition number.[1] An ill-conditioned summation problem is one in which this ratio is large, and in this case even pairwise summation can have a large relative error. For example, if the summands xi are uncorrelated random numbers with zero mean, the sum is a random walk and the condition number will grow proportional to . On the other hand, for random inputs with nonzero mean the condition number asymptotes to a finite constant as . If the inputs are all non-negative, then the condition number is 1.

Note that the denominator is effectively 1 in practice, since is much smaller than 1 until n becomes of order 21/ε, which is roughly 101015 in double precision.

In comparison, the relative error bound for naive summation (simply adding the numbers in sequence, rounding at each step) grows as multiplied by the condition number.[1] In practice, it is much more likely that the rounding errors have a random sign, with zero mean, so that they form a random walk; in this case, naive summation has a root mean square relative error that grows as and pairwise summation has an error that grows as on average.[2]

Software implementations

Pairwise summation is the default summation algorithm in NumPy[9] and the Julia technical-computing language,[10] where in both cases it was found to have comparable speed to naive summation (thanks to the use of a large base case).

Other software implementations include the HPCsharp library[11] for the C# language and the standard library summation[12] in D.

References

  1. ^ a b c d e f g Higham, Nicholas J. (1993), "The accuracy of floating point summation", SIAM Journal on Scientific Computing, 14 (4): 783–799, Bibcode:1993SJSC...14..783H, CiteSeerX 10.1.1.43.3535, doi:10.1137/0914050
  2. ^ a b c Manfred Tasche and Hansmartin Zeuner Handbook of Analytic-Computational Methods in Applied Mathematics Boca Raton, FL: CRC Press, 2000).
  3. ^ a b S. G. Johnson and M. Frigo, "Implementing FFTs in practice, in Fast Fourier Transforms, edited by C. Sidney Burrus (2008).
  4. ^ Higham, Nicholas (2002). Accuracy and Stability of Numerical Algorithms (2 ed). SIAM. pp. 81–82.
  5. ^ Radu Rugina and Martin Rinard, "Recursion unrolling for divide and conquer programs," in Languages and Compilers for Parallel Computing, chapter 3, pp. 34–48. Lecture Notes in Computer Science vol. 2017 (Berlin: Springer, 2001).
  6. ^ Anthony M. Castaldo, R. Clint Whaley, and Anthony T. Chronopoulos, "Reducing floating-point error in dot product using the superblock family of algorithms," SIAM J. Sci. Comput., vol. 32, pp. 1156–1174 (2008).
  7. ^ Dalton, Barnaby; Wang, Amy; Blainey, Bob (16 February 2014). SIMDizing pairwise sums: a summation algorithm balancing accuracy with throughput. 2014 Workshop on Workshop on Programming Models for SIMD/Vector Processing - WPMVP ’14. pp. 65–70. doi:10.1145/2568058.2568070.
  8. ^ L. N. Trefethen and D. Bau, Numerical Linear Algebra (SIAM: Philadelphia, 1997).
  9. ^ ENH: implement pairwise summation, github.com/numpy/numpy pull request #3685 (September 2013).
  10. ^ RFC: use pairwise summation for sum, cumsum, and cumprod, github.com/JuliaLang/julia pull request #4039 (August 2013).
  11. ^ https://github.com/DragonSpit/HPCsharp HPCsharp nuget package of high performance C# algorithms
  12. ^ "std.algorithm.iteration - D Programming Language". dlang.org. Retrieved 2021-04-23.

Read other articles:

17+Nama alternatif17+ Babak 2Genre Drama Komedi SkenarioFirman TriyadiCeritaFirman TriyadiSutradaraUcik SupraPemeran Latief Sitepu Ochi Rosdiana Jeremie Moeremans Merry Mustaf Jonathan Andriano Penggubah lagu tema Mai Armada Rizal Armada Radha Lagu pembukaKeluarga oleh ArmadaLagu penutupKeluarga oleh ArmadaPenata musikWiwiex SoedarnoNegara asalIndonesiaBahasa asliBahasa IndonesiaJmlh. musim1Jmlh. episode32ProduksiProduserDavid S. SuwartoSinematografiRudi KoerwetPenyunting Hendrajat Bas...

 

 

Not to be confused with Eastern College Athletic Conference. American collegiate ice hockey conference ECAC HockeyFormerlyEastern College Athletic Conference (1962–2004)ECAC Hockey League (2004–2007)AssociationNCAAFounded1961; 63 years ago (1961)CommissionerDoug ChristiansenSports fielded Ice hockey men's: 12 teams women's: 12 teams DivisionDivision INo. of teams12HeadquartersClifton Park, New YorkRegionNortheastern United StatesOfficial websitewww.ecachockey.comLocation...

 

 

Liga Utama AzerbaijanNegaraAzerbaijanKonfederasiUEFADibentuk1992; 32 tahun lalu (1992)Jumlah tim10Tingkat pada piramida1Piala domestikPiala AzerbaijanPiala internasionalUEFA Champions LeagueUEFA Europa Conference LeagueJuara bertahan ligaQarabağ (10 gelar) (2022–23)Klub tersuksesQarabağ (10 gelar)Televisi penyiarCBC SportSitus webpfl.az 2022–23 Azerbaijan Premier League Liga Utama Azerbaijan (bahasa Azerbaijan: Azərbaycan Premyer Liqası), saat ini bernama Topaz Premyer Liqas�...

Pesawat Garuda Indonesia dan Lion Air di Bandar Udara Internasional Ngurah Rai, Bali pada 2014 Penerbangan di Indonesia merupakan sarana penting untuk menghubungkan ribuan pulau di Nusantara. Indonesia adalah negara kepulauan yang memiliki 17.508 pulau,[1] sebanyak 922 di antaranya dihuni secara menetap.[a] Dengan jumlah penduduk ditaksir sebanyak lebih dari 255 juta jiwa — menjadikan negara ini sebagai negara berpenduduk terbesar keempat di dunia — juga berkat pertumbuhan...

 

 

イスラームにおける結婚(イスラームにおけるけっこん)とは、二者の間で行われる法的な契約である。新郎新婦は自身の自由な意思で結婚に同意する。口頭または紙面での規則に従った拘束的な契約は、イスラームの結婚で不可欠だと考えられており、新郎と新婦の権利と責任の概要を示している[1]。イスラームにおける離婚は様々な形をとることができ、個�...

 

 

40°43′12″N 74°00′32″W / 40.72000°N 74.00889°W / 40.72000; -74.00889 Street in Manhattan, New York North Moore Street is a moderately trafficked street in TriBeCa, a neighborhood in the New York City borough of Manhattan. It runs roughly east–west between West Broadway and West Street. Automotive traffic is westbound only. Naming On street signs and maps, the street is usually written as N. Moore Street. The street was named in 1790 for Benjamin Moore (174...

FACTS redirects here. For the Australian television industry body formerly abbreviated as FACTS, see FreeTV Australia. For true data, see Fact. Flexible AC Transmission SystemTwo poles of a Thyristor Valve Stack Background Automatic generation control Droop speed control Electric power Electric power quality Electrical fault Energy demand management Grid strength Power factor Power-flow study Power-voltage curve Utility frequency Traditional Compensation Shunt Capacitor Bank Shunt Reactor Ser...

 

 

Part of a series onBritish law Acts of Parliament of the United Kingdom Year      1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 ...

 

 

Sumber referensi dari artikel ini belum dipastikan dan mungkin isinya tidak benar. Mohon periksa, kembangkan artikel ini, dan tambahkan sumber yang benar pada bagian yang diperlukan. (Pelajari cara dan kapan saatnya untuk menghapus pesan templat ini) Endemol GroupIndustriProduksiDistribusiLisensiMediaGenrePerusahaan produksiNasibBergabung dengan Shine Group dan membentuk Endemol Shine Group, kemudian berubah nama menjadi BanijayPenerusBanijayDidirikan1994PendiriJoop van den EndeJohn de MolDit...

هذه المقالة يتيمة إذ تصل إليها مقالات أخرى قليلة جدًا. فضلًا، ساعد بإضافة وصلة إليها في مقالات متعلقة بها. (أغسطس 2019) (171486) 1996 MO المكتشف سبايس واتش  موقع الاكتشاف مرصد قمة كت الوطني  تاريخ الاكتشاف 23 يونيو 1996  الأسماء البديلة 1996 MO  فئةالكوكب الصغير كويكبات أبولو  �...

 

 

Park in the Bronx, NYC Raoul Wallenberg ForestLocationBronx, New YorkCoordinates40°53′15″N 73°55′04″W / 40.88750°N 73.91778°W / 40.88750; -73.91778Elevation138 ftEtymologynamed after Raoul WallenbergStatusOpen Raoul Wallenberg Forest is a New York City park[1] located in Riverdale, New York named after Raoul Wallenberg, a Swedish diplomat who saved thousands of Hungarian Jewish people.[2] References ^ Raoul Wallenberg Forest : NYC Parks...

 

 

Questa voce o sezione sugli argomenti vescovi italiani e filosofi italiani non cita le fonti necessarie o quelle presenti sono insufficienti. Puoi migliorare questa voce aggiungendo citazioni da fonti attendibili secondo le linee guida sull'uso delle fonti. Segui i suggerimenti dei progetti di riferimento 1, 2. Giovanni Andrea Triaarcivescovo della Chiesa cattolica  Incarichi ricoperti Vescovo di Cariati e Cerenzia (1720-1726) Vescovo di Larino (1726-1741) Arcivescovo titolare di T...

Disambiguazione – Se stai cercando il quasi omonimo calciatore francese classe 2001, vedi Mohamed Lamine Diaby. Questa voce sull'argomento Calciatori francesi è solo un abbozzo. Contribuisci a migliorarla secondo le convenzioni di Wikipedia. Segui i suggerimenti del progetto di riferimento. Mohamed DiabyNazionalità Francia Altezza197 cm Peso77 kg Calcio RuoloCentrocampista Squadra Sheffield Wednesday CarrieraSquadre di club1 2016-2017 Salgueiros1 (0)2017 Sporting...

 

 

MerlettaiaAutoreJan Vermeer Data1669-1670 circa Tecnicaolio su tela riportata su tavola Dimensioni23,9×20,5 cm UbicazioneMuseo del Louvre, Parigi La Merlettaia è un dipinto a olio su tela riportata su tavola (23,9x20,5 cm) di Jan Vermeer, databile al 1669-1670 circa e conservato nel Museo del Louvre di Parigi. È firmato «IV Meer» in alto a destra, con lettere leggermente sbiadite. Il soggetto è una fanciulla che, con molta attenzione, si dedica all'arte del ricamo. Gli interni...

 

 

American baseball player (born 1980) Baseball player Reggie AbercrombieAbercrombie batting for the Round Rock Express, Triple-A affiliates of the Houston Astros, in 2008.OutfielderBorn: (1980-07-15) July 15, 1980 (age 44)Columbus, Georgia, U.S.Batted: RightThrew: RightMLB debutApril 4, 2006, for the Florida MarlinsLast appearanceSeptember 28, 2008, for the Houston AstrosMLB statisticsBatting average.223Home runs9Runs batted in34 Teams Florida Marlins (2006�...

Digital photograph manipulation application developed by Apple Inc. PhotosPhotos app running in OS X YosemiteDeveloper(s)Apple Inc.Operating system iOS (all versions) iPadOS (all versions) OS X Yosemite onward watchOS (all versions) tvOS 10 onward TypePhoto gallery and editing softwareWebsitewww.apple.com/macos/photos/  Part of a series onmacOS Features History Transition to Intel processors Transition to Apple silicon Architecture Built-in apps List of applications List of games Version...

 

 

Arne FriedrichNazionalità Germania Altezza185 cm Peso76 kg Calcio RuoloDifensore Termine carriera23 giugno 2013 CarrieraGiovanili 1985-1987FC Bad Oeynhausen1987-1992TuS Lohe1992-1995SC Herford1995-1999FC Gütersloh1999-2000SC Verl Squadre di club1 2000-2002 Arminia Bielefeld47 (1)2002-2010 Hertha Berlino231 (14)2010-2011 Wolfsburg15 (0)2012-2013 Chicago Fire23 (1) Nazionale 2000-2001 Germania U-215 (0)2002-2011 Germania82 (1) Palmarès  Mondiali di calcio Bronzo...

 

 

喜多 修平生誕 (1980-07-29) 1980年7月29日(44歳)出身地 日本・大阪府泉南郡熊取町学歴 和泉市立国府小学校卒浪速中学校卒浪速高等学校卒大阪芸術大学卒ジャンル アニメソング、ゲームソング職業 歌手担当楽器 歌活動期間 2008年 -レーベル アニプレックス(2008年)ランティス(2009年 - )事務所 HIGHWAY STAR公式サイト 喜多修平 Official Website 喜多 修平(きた しゅうへい、1980...

American sociologist (1927–2013) Robert N. BellahBellah in 2008BornRobert Neelly Bellah(1927-02-23)February 23, 1927Altus, Oklahoma, U.S.DiedJuly 30, 2013(2013-07-30) (aged 86)Oakland, California, U.S.Spouse Melanie Hyman ​ ​(m. 1948; died 2010)​Academic backgroundEducationHarvard University (BA, PhD)ThesisReligion and Society in Tokugawa Japan (1955)Doctoral advisorTalcott Parsons[1]John PelzelOther advisorsDavid AberleInflu...

 

 

Checklist for a journalist's lead/lede: Who? What? Where? When? Why? How? Not to be confused with 5 whys. For other uses, see 5W and W5. Journalism News Writing style (Five Ws) Ethics (code of ethics) Culture Objectivity News values Attribution Defamation Sensationalism Editorial independence Journalism school Index of journalism articles Areas Arts Business Data Entertainment Environment Fashion Medicine Music Politics Science Sports Technology Traffic Video games War Weather World Genres A...