ebook img

Modern Computer Arithmetic PDF

240 Pages·2010·2.14 MB·English
Save to my drive
Quick download
Download
Most books are stored in the elastic cloud where traffic is expensive. For this reason, we have a limit on daily download.

Preview Modern Computer Arithmetic

Cambridge University Press 978-0-521-19469-3 - Modern Computer Arithmetic Richard P. Brent and Paul Zimmermann Frontmatter More information CAMBRIDGE MONOGRAPHS ON APPLIED AND COMPUTATIONAL MATHEMATICS SeriesEditors M. ABLOWITZ, S. DAVIS, J. HINCH, A. ISERLES, J. OCKENDON, P. OLVER 18 Modern Computer Arithmetic © in this web service Cambridge University Press www.cambridge.org Cambridge University Press 978-0-521-19469-3 - Modern Computer Arithmetic Richard P. Brent and Paul Zimmermann Frontmatter More information TheCambridgeMonographsonAppliedandComputationalMathematicsseriesreflects thecrucialroleofmathematicalandcomputationaltechniquesincontemporaryscience. Theseriespublishesexpositionsonallaspectsofapplicableandnumericalmathemat- ics,withanemphasisonnewdevelopmentsinthisfast-movingareaofresearch. State-of-the-artmethodsandalgorithmsaswellasmodernmathematicaldescriptions ofphysicalandmechanicalideasarepresentedinamannersuitedtograduateresearch studentsandprofessionalsalike.Soundpedagogicalpresentationisaprerequisite.Itis intendedthatbooksintheserieswillservetoinformanewgenerationofresearchers. Acompletelistofbooksintheseriescanbefoundat http://www.cambridge.org/uk/series/sSeries.asp?code=MACM Recenttitlesincludethefollowing: 6. Thetheoryofcomposites,GraemeW.Milton 7. Geometryandtopologyformeshgeneration,HerbertEdelsbrunner 8. Schwarz–Christoffelmapping,TobinA.Driscoll&LloydN.Trefethen 9. High-ordermethodsforincompressiblefluidflow,M.O.Deville, P.F.Fischer& E.H.Mund 10. Practicalextrapolationmethods,AvramSidi 11. GeneralizedRiemannproblemsincomputationalfluiddynamics,Matania Ben-Artzi&JosephFalcovitz 12. Radialbasisfunctions,MartinD.Buhmann 13. IterativeKrylovmethodsforlargelinearsystems,HenkvanderVorst 14. SimulatingHamiltoniandynamics,BenedictLeimkuhler& SebastianReich 15. CollocationmethodsforVolterraintegralandrelatedfunctionaldifferential equations,HermannBrunner 16. Topologyforcomputing,AfraJ.Zomorodian 17. Scattereddataapproximation,HolgerWendland 18. Moderncomputerarithmetic,RichardP.Brent&PaulZimmermann 19. Matrixpreconditioningtechniquesandapplications,KeChen 21. Spectralmethodsfortime-dependentproblems,JanHesthaven, SigalGottlieb& DavidGottlieb 22. Themathematicalfoundationsofmixing,RobSturman,JulioM.Ottino& StephenWiggins 23. Curveandsurfacereconstruction,TamalK.Dey 24. Learningtheory,FelipeCucker&DingXuanZhou 25. Algebraicgeometryandstatisticallearningtheory,SumioWatanabe 26. Apracticalguidetotheinvariantcalculus,ElizabethLouiseMansfield © in this web service Cambridge University Press www.cambridge.org Cambridge University Press 978-0-521-19469-3 - Modern Computer Arithmetic Richard P. Brent and Paul Zimmermann Frontmatter More information Modern Computer Arithmetic RICHARD P. BRENT AustralianNationalUniversity,Canberra PAUL ZIMMERMANN INRIA,Nancy © in this web service Cambridge University Press www.cambridge.org Cambridge University Press 978-0-521-19469-3 - Modern Computer Arithmetic Richard P. Brent and Paul Zimmermann Frontmatter More information CAMBRIDGE UNIVERSITY PRESS Cambridge,NewYork,Melbourne,Madrid,CapeTown,Singapore, Sa˜oPaulo,Delhi,Dubai,Tokyo,MexicoCity CambridgeUniversityPress TheEdinburghBuilding,CambridgeCB28RU,UK PublishedintheUnitedStatesofAmericabyCambridgeUniversityPress,NewYork www.cambridge.org Informationonthistitle:www.cambridge.org/9780521194693 (cid:1)c R.BrentandP.Zimmermann2011 Thispublicationisincopyright.Subjecttostatutoryexception andtotheprovisionsofrelevantcollectivelicensingagreements, noreproductionofanypartmaytakeplacewithoutthewritten permissionofCambridgeUniversityPress. Firstpublished2011 PrintedintheUnitedKingdomattheUniversityPress,Cambridge AcataloguerecordforthispublicationisavailablefromtheBritishLibrary LibraryofCongressCataloguinginPublicationdata ISBN978-0-521-19469-3Hardback CambridgeUniversityPresshasnoresponsibilityforthepersistenceor accuracyofURLsforexternalorthird-partyinternetwebsitesreferredto inthispublication,anddoesnotguaranteethatanycontentonsuch websitesis,orwillremain,accurateorappropriate. © in this web service Cambridge University Press www.cambridge.org Cambridge University Press 978-0-521-19469-3 - Modern Computer Arithmetic Richard P. Brent and Paul Zimmermann Frontmatter More information Contents Preface pageix Acknowledgements xi Notation xiii 1 Integerarithmetic 1 1.1 Representationandnotations 1 1.2 Additionandsubtraction 2 1.3 Multiplication 3 1.3.1 Naivemultiplication 4 1.3.2 Karatsuba’salgorithm 5 1.3.3 Toom–Cookmultiplication 6 1.3.4 UseofthefastFouriertransform(FFT) 8 1.3.5 Unbalancedmultiplication 8 1.3.6 Squaring 11 1.3.7 Multiplicationbyaconstant 13 1.4 Division 14 1.4.1 Naivedivision 14 1.4.2 Divisorpreconditioning 16 1.4.3 Divideandconquerdivision 18 1.4.4 Newton’smethod 21 1.4.5 Exactdivision 21 1.4.6 Onlyquotientorremainderwanted 22 1.4.7 Divisionbyasingleword 23 1.4.8 Hensel’sdivision 24 1.5 Roots 25 1.5.1 Squareroot 25 1.5.2 kthroot 27 1.5.3 Exactroot 28 © in this web service Cambridge University Press www.cambridge.org Cambridge University Press 978-0-521-19469-3 - Modern Computer Arithmetic Richard P. Brent and Paul Zimmermann Frontmatter More information vi Contents 1.6 Greatestcommondivisor 29 1.6.1 NaiveGCD 29 1.6.2 ExtendedGCD 32 1.6.3 HalfbinaryGCD,divideandconquerGCD 33 1.7 Baseconversion 37 1.7.1 Quadraticalgorithms 37 1.7.2 Subquadraticalgorithms 38 1.8 Exercises 39 1.9 Notesandreferences 44 2 ModulararithmeticandtheFFT 47 2.1 Representation 47 2.1.1 Classicalrepresentation 47 2.1.2 Montgomery’sform 48 2.1.3 Residuenumbersystems 48 2.1.4 MSBvsLSBalgorithms 49 2.1.5 Linkwithpolynomials 49 2.2 Modularadditionandsubtraction 50 2.3 TheFouriertransform 50 2.3.1 Theoreticalsetting 50 2.3.2 ThefastFouriertransform 51 2.3.3 TheScho¨nhage–Strassenalgorithm 55 2.4 Modularmultiplication 58 2.4.1 Barrett’salgorithm 58 2.4.2 Montgomery’smultiplication 60 2.4.3 McLaughlin’salgorithm 63 2.4.4 Specialmoduli 65 2.5 Modulardivisionandinversion 65 2.5.1 Severalinversionsatonce 67 2.6 Modularexponentiation 68 2.6.1 Binaryexponentiation 70 2.6.2 Exponentiationwithalargerbase 70 2.6.3 Slidingwindowandredundantrepresentation 72 2.7 Chineseremaindertheorem 73 2.8 Exercises 75 2.9 Notesandreferences 77 3 Floating-pointarithmetic 79 3.1 Representation 79 3.1.1 Radixchoice 80 3.1.2 Exponentrange 81 © in this web service Cambridge University Press www.cambridge.org Cambridge University Press 978-0-521-19469-3 - Modern Computer Arithmetic Richard P. Brent and Paul Zimmermann Frontmatter More information Contents vii 3.1.3 Specialvalues 82 3.1.4 Subnormalnumbers 82 3.1.5 Encoding 83 3.1.6 Precision:local,global,operation,operand 84 3.1.7 Linktointegers 86 3.1.8 Ziv’salgorithmanderroranalysis 86 3.1.9 Rounding 87 3.1.10 Strategies 90 3.2 Addition,subtraction,comparison 91 3.2.1 Floating-pointaddition 92 3.2.2 Floating-pointsubtraction 93 3.3 Multiplication 95 3.3.1 IntegermultiplicationviacomplexFFT 98 3.3.2 Themiddleproduct 99 3.4 Reciprocalanddivision 101 3.4.1 Reciprocal 102 3.4.2 Division 106 3.5 Squareroot 111 3.5.1 Reciprocalsquareroot 112 3.6 Conversion 114 3.6.1 Floating-pointoutput 115 3.6.2 Floating-pointinput 117 3.7 Exercises 118 3.8 Notesandreferences 120 4 Elementaryandspecialfunctionevaluation 125 4.1 Introduction 125 4.2 Newton’smethod 126 4.2.1 Newton’smethodforinverseroots 127 4.2.2 Newton’smethodforreciprocals 128 4.2.3 Newton’smethodfor(reciprocal)squareroots 129 4.2.4 Newton’smethodforformalpowerseries 129 4.2.5 Newton’smethodforfunctionalinverses 130 4.2.6 Higher-orderNewton-likemethods 131 4.3 Argumentreduction 132 4.3.1 Repeateduseofadoublingformula 134 4.3.2 Lossofprecision 134 4.3.3 Guarddigits 135 4.3.4 Doublingversustripling 136 4.4 Powerseries 136 © in this web service Cambridge University Press www.cambridge.org Cambridge University Press 978-0-521-19469-3 - Modern Computer Arithmetic Richard P. Brent and Paul Zimmermann Frontmatter More information viii Contents 4.4.1 Directpowerseriesevaluation 140 4.4.2 Powerserieswithargumentreduction 140 4.4.3 Rectangularseriessplitting 141 4.5 Asymptoticexpansions 144 4.6 Continuedfractions 150 4.7 Recurrencerelations 152 4.7.1 EvaluationofBesselfunctions 153 4.7.2 EvaluationofBernoulliandtangentnumbers 154 4.8 Arithmetic-geometricmean 158 4.8.1 Ellipticintegrals 158 4.8.2 FirstAGMalgorithmforthelogarithm 159 4.8.3 Thetafunctions 160 4.8.4 SecondAGMalgorithmforthelogarithm 162 4.8.5 ThecomplexAGM 163 4.9 Binarysplitting 163 4.9.1 Abinarysplittingalgorithmforsin,cos 166 4.9.2 Thebit-burstalgorithm 167 4.10 Contourintegration 169 4.11 Exercises 171 4.12 Notesandreferences 179 5 Implementationsandpointers 185 5.1 Softwaretools 185 5.1.1 CLN 185 5.1.2 GNUMP(GMP) 185 5.1.3 MPFQ 186 5.1.4 GNUMPFR 187 5.1.5 Othermultiple-precisionpackages 187 5.1.6 Computationalalgebrapackages 188 5.2 Mailinglists 189 5.2.1 TheGMPlists 189 5.2.2 TheMPFRlist 190 5.3 On-linedocuments 190 References 191 Index 207 © in this web service Cambridge University Press www.cambridge.org Preface This is a book about algorithms for performing arithmetic, and their imple- mentation on modern computers. We are concerned with software more than hardware–wedonotcover computerarchitectureorthedesignofcomputer hardware since good books are already available on these topics. Instead, we focus on algorithms for efficiently performing arithmetic operations such as addition, multiplication, and division, and their connections to topics such as modular arithmetic, greatest common divisors, the fast Fourier transform (FFT),andthecomputationofspecialfunctions. The algorithms that we present are mainly intended for arbitrary-precision arithmetic.Thatis,theyarenotlimitedbythecomputerwordsizeof32or64 bits,onlybythememoryandtimeavailableforthecomputation.Weconsider bothintegerandreal(floating-point)computations. Thebookisdividedintofourmainchapters,plusoneshortchapter(essen- tially an appendix). Chapter 1 covers integer arithmetic. This has, of course, been considered in many other books and papers. However, there has been much recent progress, inspired in part by the application to public key cryp- tography,somostofthepublishedbooksarenowpartlyoutofdateorincom- plete.Ouraimistopresentthelatestdevelopmentsinaconcisemanner.Atthe sametime,weprovideaself-containedintroductionforthereaderwhoisnot anexpertinthefield. Chapter2isconcernedwithmodulararithmeticandtheFFT,andtheirappli- cationstocomputerarithmetic.Weconsiderdifferentnumberrepresentations, fastalgorithmsformultiplication,divisionandexponentiation,andtheuseof theChineseremaindertheorem(CRT). Chapter 3 covers floating-point arithmetic. Our concern is with high- precision floating-point arithmetic, implemented in software if the precision provided by the hardware (typically IEEE standard 53-bit significand) is

See more

The list of books you might like

Most books are stored in the elastic cloud where traffic is expensive. For this reason, we have a limit on daily download.