Abyss of lala land

I am roticv

Monday, December 29, 2008

square root

Joy. I've just learnt how to manually calculate square root (maybe it is a useless skill in a world where we have calculators, but nevertheless I still know how to do it). Converted the algorithm to code and produced the following (the digits are correct to 40 dp but they are not rounded properly).

sqrt(2): 1.4142135623730950488016887242096980785696
sqrt(3): 1.7320508075688772935274463415058723669428
sqrt(5): 2.2360679774997896964091736687312762354406
sqrt(6): 2.4494897427831780981972840747058913919659
sqrt(7): 2.6457513110645905905016157536392604257102
sqrt(8): 2.8284271247461900976033774484193961571393
sqrt(10): 3.1622776601683793319988935444327185337195
sqrt(11): 3.3166247903553998491149327366706866839270
sqrt(12): 3.4641016151377545870548926830117447338856
sqrt(13): 3.6055512754639892931192212674704959462512
sqrt(14): 3.7416573867739413855837487323165493017560
sqrt(15): 3.8729833462074168851792653997823996108329
sqrt(17): 4.1231056256176605498214098559740770251471
sqrt(18): 4.2426406871192851464050661726290942357090
sqrt(19): 4.3588989435406735522369819838596156591370
sqrt(20): 4.4721359549995793928183473374625524708812
sqrt(21): 4.5825756949558400065880471937280084889844
sqrt(22): 4.6904157598234295545656301135444662805882
sqrt(23): 4.7958315233127195415974380641626939199967
sqrt(24): 4.8989794855663561963945681494117827839318
sqrt(26): 5.0990195135927848300282241090227819895637
sqrt(27): 5.1961524227066318805823390245176171008284
sqrt(28): 5.2915026221291811810032315072785208514205
sqrt(29): 5.3851648071345040312507104915403295562951
sqrt(30): 5.4772255750516611345696978280080213395274
sqrt(31): 5.5677643628300219221194712989185495204763
sqrt(32): 5.6568542494923801952067548968387923142786
sqrt(33): 5.7445626465380286598506114682189293182202
sqrt(34): 5.8309518948453004708741528775455830765213
sqrt(35): 5.9160797830996160425673282915616170484155
sqrt(37): 6.0827625302982196889996842452020670620849
sqrt(38): 6.1644140029689764502501923814542442252356
sqrt(39): 6.2449979983983982058468931209397944610729
sqrt(40): 6.3245553203367586639977870888654370674391
sqrt(41): 6.4031242374328486864882176746218132645204
sqrt(42): 6.4807406984078602309659674360879966577052
sqrt(43): 6.5574385243020006523441099976360016279269
sqrt(44): 6.6332495807107996982298654733413733678541
sqrt(45): 6.7082039324993690892275210061938287063218
sqrt(46): 6.7823299831252681390645563266259691051957
sqrt(47): 6.8556546004010441249358714490848489604606
sqrt(48): 6.9282032302755091741097853660234894677712
sqrt(50): 7.0710678118654752440084436210484903928483
sqrt(51): 7.1414284285428499979993998113672652787661
sqrt(52): 7.2111025509279785862384425349409918925025
sqrt(53): 7.2801098892805182710973024915270327937776
sqrt(54): 7.3484692283495342945918522241176741758978
sqrt(55): 7.4161984870956629487113974408007130609799
sqrt(56): 7.4833147735478827711674974646330986035120
sqrt(57): 7.5498344352707496972366848069461170582221
sqrt(58): 7.6157731058639082856614110271583230053607
sqrt(59): 7.6811457478686081757696870217313724730624
sqrt(60): 7.7459666924148337703585307995647992216658
sqrt(61): 7.8102496759066543941297227357591014135683
sqrt(62): 7.8740078740118110196850344488120078636810
sqrt(63): 7.9372539331937717715048472609177812771307
sqrt(65): 8.0622577482985496523666132303037711311343
sqrt(66): 8.1240384046359603604598835682660403485042
sqrt(67): 8.1853527718724499699537037247339294588804
sqrt(68): 8.2462112512353210996428197119481540502943
sqrt(69): 8.3066238629180748525842627449074920102322
sqrt(70): 8.3666002653407554797817202578518748939281
sqrt(71): 8.4261497731763586306341399062027360316080
sqrt(72): 8.4852813742385702928101323452581884714180
sqrt(73): 8.5440037453175311678716483262397064345944
sqrt(74): 8.6023252670426267717294735350497136320275
sqrt(75): 8.6602540378443864676372317075293618347140
sqrt(76): 8.7177978870813471044739639677192313182740
sqrt(77): 8.7749643873921220604063883074163095608758
sqrt(78): 8.8317608663278468547640427269592539641746
sqrt(79): 8.8881944173155888500914416754087278170764
sqrt(80): 8.9442719099991587856366946749251049417624
sqrt(82): 9.0553851381374166265738081669840664130521
sqrt(83): 9.1104335791442988819456261046886691900991
sqrt(84): 9.1651513899116800131760943874560169779689
sqrt(85): 9.2195444572928873100022742817627931572468
sqrt(86): 9.2736184954957037525164160739901746262634
sqrt(87): 9.3273790530888150455544755423205569832762
sqrt(88): 9.3808315196468591091312602270889325611764
sqrt(89): 9.4339811320566038113206603776226407169836
sqrt(90): 9.4868329805051379959966806332981556011586
sqrt(91): 9.5393920141694564915262158602322654025462
sqrt(92): 9.5916630466254390831948761283253878399934
sqrt(93): 9.6436507609929549957600310474326631839069
sqrt(94): 9.6953597148326580281488811508453133936521
sqrt(95): 9.7467943448089639068384131998996002992525
sqrt(96): 9.7979589711327123927891362988235655678637
sqrt(97): 9.8488578017961047217462114149176244816961
sqrt(98): 9.8994949366116653416118210694678865499877
sqrt(99): 9.9498743710661995473447982100120600517812

Labels:

1 Comments:

At December 31, 2008 at 2:15 AM , Blogger The_Laptop said...

You do realise that if you guess an initial point close enough to the square root of some nonnegative integer, you could refine it in <3 applications of Newton's Method right?

Quake uses Newton's Method to compute reciprocals of square roots, using only bit-shifts and adds. Here's a link:

http://betterexplained.com/articles/understanding-quakes-fast-inverse-square-root/

 

Post a Comment

Subscribe to Post Comments [Atom]

<< Home