Advertisement
mllm

rat 2 dec with pari-gp

Nov 23rd, 2021 (edited)
239
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. \\ So we have a rational number with nominator called 'p' and denom called 'q'.
  2. \\ The person that gave us these numbers claims that the rational approximates Pi.
  3. \\ We want to test this hypothesis.
  4. \\ Using the following version of PARI/GP:
  5. \\   GP/PARI CALCULATOR Version 2.9.4 (released)
  6. \\   amd64 running linux (x86-64/GMP-6.1.2 kernel) 64-bit version
  7. \\   compiled: Dec 19 2017, gcc version 7.3.0 (Ubuntu 7.3.0-1ubuntu1)
  8. \\   threading engine: pthread
  9. \\   (readline v7.0 disabled, extended help enabled)
  10. \\
  11. \\ For a more recent version check here: http://pari.math.u-bordeaux.fr/download.html
  12.  
  13. \\ First define the nominator.
  14. p = 169621521599715008276219171512587640647841095442456069002320644182266868459617619753889122898655162183404136973947180752187359905902753260425513050548229467432513862416424894942454713985465278932529328431801828096801920887765994271135011232692744581328925613143089416369332765923820914844366872416498286310709782023849335976275636317740764835591903828756560907312090101454770517747287108619058818385005663195977504011488807928750255014263206030308478008789858365581938685005925857190843815093499376975642422198241136503493946530984537459852215831260865709362658168293949557761906738505201661019132792725659665127352812617496756168506523926285934972259335392327959749209119904008499118043974118384243889708663618255952472658431205999918317575607657740236649567997214307671993864889895393839141039506162002967032097850104329360630620037199839999142283857127423583660420412640713389114512448981659186654920369410109397250843678564086072047059266513900405454076350312323975218753628513160246104286440957540497492228327530693076123214774002565781816122426929452997664845839935152576597214412838642199080522538526785632514871374048614455166761773227562170331518842728241937247564343923818495125376084747425403562295453185186235744629977833817398516530400483769490658446407168075399793934693849926911293460509164677.
  15. \\ %01 = 1.6962152159971500827621917151258764065 E1307
  16.  
  17. \\ Then define the denominator
  18. q = 53992207234726675278961941928450302452822047623718564385150323747724701281112300190300106635808547972512609385998185753170427113716200847706128220369404709717036269053644161045979852353945911645945115429379410105679831222022124449171708573935148545356552619360430097618490856349218462434207739425221688438345427657734945388360754851355876703517025241721040065222250907032187978825511851598073604902050405347475910190484449194196262402616451203465800884163477391039657283777500697293141096800015886292794390305130398878990902018844921870933047995171901635986345004445034969192966427479779117696471307624934148805180535413821861248354813884290062923803439746267128219005135975738755802559525508507324875485007341328779475078894735722877157533192681548668962657606446758705361666748320254297731413043617929690439214061599103967718073490431270227525555253221083788818740709945739088997644645878720664836566515847158951628965993677079199266744574662134053159976336619213638568983033487260628088204640814188076260382314091548602410696939680031879020944602729449902120056631834098794391928608779141524686795239077451960200846097922780695588801746583663247036517735360081178649014537721782789452025926453581219061848116302188155364930920220240513762484943105388217395949984758122066857243133095444913227856394518646.
  19. \\ %02 = 5.3992207234726675278961941928450302453 E1306
  20.  
  21. \\ Then do the division
  22. p / q
  23. \\ %03 = 3.1415926535897932384626433832795028842
  24.  
  25. \\ Compare the result of the division with the value of Pi in the current precision of the system.
  26. Pi
  27. \\ %04 = 3.1415926535897932384626433832795028842
  28.  
  29. \\ Checking again.
  30. Pi - (p / q)
  31. \\ %05 = 0.E-37
  32.  
  33. \\ Checking again.
  34. Pi - (p / q) == 0
  35. \\ %06 = 1
  36.  
  37. \\ Conclusion: According to the above results its apparent that the rational p/q approximates Pi with accuracy of 37 decimal digits.
  38. \\ Not bad at all, PARI/GP. We'll surely talk with you again, thank you for your assistance.
Advertisement
RAW Paste Data Copied
Advertisement