Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- \\ So we have a rational number with nominator called 'p' and denom called 'q'.
- \\ The person that gave us these numbers claims that the rational approximates Pi.
- \\ We want to test this hypothesis.
- \\ Using the following version of PARI/GP:
- \\ GP/PARI CALCULATOR Version 2.9.4 (released)
- \\ amd64 running linux (x86-64/GMP-6.1.2 kernel) 64-bit version
- \\ compiled: Dec 19 2017, gcc version 7.3.0 (Ubuntu 7.3.0-1ubuntu1)
- \\ threading engine: pthread
- \\ (readline v7.0 disabled, extended help enabled)
- \\
- \\ For a more recent version check here: http://pari.math.u-bordeaux.fr/download.html
- \\ First define the nominator.
- p = 169621521599715008276219171512587640647841095442456069002320644182266868459617619753889122898655162183404136973947180752187359905902753260425513050548229467432513862416424894942454713985465278932529328431801828096801920887765994271135011232692744581328925613143089416369332765923820914844366872416498286310709782023849335976275636317740764835591903828756560907312090101454770517747287108619058818385005663195977504011488807928750255014263206030308478008789858365581938685005925857190843815093499376975642422198241136503493946530984537459852215831260865709362658168293949557761906738505201661019132792725659665127352812617496756168506523926285934972259335392327959749209119904008499118043974118384243889708663618255952472658431205999918317575607657740236649567997214307671993864889895393839141039506162002967032097850104329360630620037199839999142283857127423583660420412640713389114512448981659186654920369410109397250843678564086072047059266513900405454076350312323975218753628513160246104286440957540497492228327530693076123214774002565781816122426929452997664845839935152576597214412838642199080522538526785632514871374048614455166761773227562170331518842728241937247564343923818495125376084747425403562295453185186235744629977833817398516530400483769490658446407168075399793934693849926911293460509164677.
- \\ %01 = 1.6962152159971500827621917151258764065 E1307
- \\ Then define the denominator
- q = 53992207234726675278961941928450302452822047623718564385150323747724701281112300190300106635808547972512609385998185753170427113716200847706128220369404709717036269053644161045979852353945911645945115429379410105679831222022124449171708573935148545356552619360430097618490856349218462434207739425221688438345427657734945388360754851355876703517025241721040065222250907032187978825511851598073604902050405347475910190484449194196262402616451203465800884163477391039657283777500697293141096800015886292794390305130398878990902018844921870933047995171901635986345004445034969192966427479779117696471307624934148805180535413821861248354813884290062923803439746267128219005135975738755802559525508507324875485007341328779475078894735722877157533192681548668962657606446758705361666748320254297731413043617929690439214061599103967718073490431270227525555253221083788818740709945739088997644645878720664836566515847158951628965993677079199266744574662134053159976336619213638568983033487260628088204640814188076260382314091548602410696939680031879020944602729449902120056631834098794391928608779141524686795239077451960200846097922780695588801746583663247036517735360081178649014537721782789452025926453581219061848116302188155364930920220240513762484943105388217395949984758122066857243133095444913227856394518646.
- \\ %02 = 5.3992207234726675278961941928450302453 E1306
- \\ Then do the division
- p / q
- \\ %03 = 3.1415926535897932384626433832795028842
- \\ Compare the result of the division with the value of Pi in the current precision of the system.
- Pi
- \\ %04 = 3.1415926535897932384626433832795028842
- \\ Checking again.
- Pi - (p / q)
- \\ %05 = 0.E-37
- \\ Checking again.
- Pi - (p / q) == 0
- \\ %06 = 1
- \\ Conclusion: According to the above results its apparent that the rational p/q approximates Pi with accuracy of 37 decimal digits.
- \\ Not bad at all, PARI/GP. We'll surely talk with you again, thank you for your assistance.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement