Julia could have a Tau constant

Use rationalize(x, tol=0) to get the exact rational (equality without rounding).

julia> rationalize(2π, tol=0)
884279719003555//140737488355328

julia> big(884279719003555) / big(140737488355328) == big(2π)
true

julia> big(411557987) / big(65501488) == big(2π)
false

By exact rational, I mean the exact rational representation of the floating point number.

3 Likes

Ah, now, this is bike-shedding at its best. :wink:

5 Likes

Better yet:

julia> rationalize(2π, tol=0.01)
44//7
2 Likes

Would it make sense to have some Unicode symbol to represent and define it as an irrational?

It could be named tupi: Julia_2pi_unicode_xsmall

1 Like

Type 2*pi: four strokes. Type \tau (plus tab): five strokes.

Tau (τ) is used in many branches of science to mean something else. That is not (so much) the case of pi (π).

4 Likes

FWIW, IrrationalConstants is a fairly popular dependency, and includes twoπ::Irrational

1 Like

I don’t understand this at all. Isn’t big supposed to be arbitrary precision? In what sense are these equal?

julia> big(884279719003555) / big(140737488355328)                                                                     
6.28318530717958623199592693708837032318115234375                                                                      
                                                                                                                       
julia> big(2π)                                                                                                         
6.28318530717958623199592693708837032318115234375   

In this (non)sense. :wink:

big is only truly arbitrary precision for integers. For floating points it is simply high (and configurable) precision. Also note the difference between big(2π) and 2big(π). The latter is the 256-bit (by default) representation of 2\pi, the former is the 256-bit representation of the closest Float64 to 2\pi. You can also request even more precision:

julia> setprecision(2^10)
1024

julia> rationalize(BigInt, 2*big(π), tol=0)
70595244323653213475748973969839712487465689684599845073220063281233204645809879117205215246043868086453695444145281754132077860204527277798754423506966312151816646904717821499392277022395900374573709695725767100279967506814101297022110117432460606180004570560230120737271889596773074378462451852653613476301//11235582092889474423308157442431404585112356118389416079589380072358292237843810195794279832650471001320007117491962084853674360550901038905802964414967132773610493339054092829768888725077880882465817684505312860552384417646403930092119569408801702322709406917786643639996702871154982269052209770601514008576

julia> setprecision(2^15)

julia> rationalize(BigInt, 2*big(π), tol=0)
555850247071683027907765035803151150651220608134135153463075627995451700201953337408927011322481689349085716780327575831428508982355421676993315457720343496596493459485419736931752800974283455084080110557998280201545714357229303322943839557292790612452052577522065693372045984673425640730242662271086298635188225329165576630355690737955090234651540919399046739305906992303446860001130203451307975055346936629384056875372135055025954563906600878658644254862084062932985743512277790365459721911874360908692721617379047958091174869665397142717067435350325564859750503498440494406404168161428789998627338161673233337432130752796240389037761256664974853033598561112786836739850847485928138211850868940680578367559281410579453317403233131967271123466906524292483736871055937477867465864201493636515787083694134021102709713139393112121392045371370296492722354816868421405708756378160492050607174769499286715819565413804372292639548732717828406142904381669408043096332764906331314259140321850662355374128920802258259911479641636828960632369054024400167054622134907030365640159872134360456730294024401833294083879333649531884998209875873608186129157433629669502298616299251869251642239954197982286961773393703420561574373249425055456154137632530846038361836093894058876614229117826119021027494642515256045953234606680326936734889615541744979444531708690124426198943663528112417011518717422537484931793732089377089469488257878274057559426966523988512633523949533340901444951428325481105667704947264792126542568865169126959751790823274095550418167781298721928041696264457413105508247094001294527052941859112275854240508307374813707146131115664372572606979603561166585970851797222240732489706200710421274418418506844190773480864475769194112974968097112286209773370396181807788069877722345269108747582484237077142796535747024122412310588086523187957287602760540777359100321450399302175897471589791632581618205513588552729173447362383237436310282639214049716545821503697971096784569874287775839616717112374459757806294042806754377425111683124737564988939023547558920697897304751187814787668291740144852026857057156734010397339001918667996742536717519111064484344191816055125460463568892272991996099186233421236304002542221350082149662353512537465828532752021223402604974744363878051302675263827811554949831731288635329633360417633965117484022410880108085647915062015789854723123530971799524310140399854588732919250275411424098782419571281912994539607435248745870657138218686380840609496490374782594211704816054340086693182869919401126926359202116506412305436178703683529542495545043992316857177161278817360632047302175555150431982089241286977161696539873505995027370770694333677080159600408047613680583617628365498838682931642011844253185858122496288163292538579166670558252261549922169161675263495413545932859367432065998198931176490837085573817551404331068596410926309654105111414459570432212129493128434349280332066083881801877746689351087819650610553490113047447565130016474745239304408156947059290453295585330878791640424349928553031964057607877665124662424017404863521824020799666140988954441512598784814701943974481382923109303734723239274399495321020207747657636038685377136112732447721837892071049457153876655397492904737210646822190984104211570376741213516498381196064244119519798714695134866206476168953213683799417129755673832070617766181180786008242421873443358245919919092086448260961418319178875679828514824698291947317236009625935436841242507218069299318108340155416120761662500841068161781388421972691421531524400054975011420236710792344445507948251680674099711463527515231486064925418558293167278124664505046385793022499920168615097620159094746956494844745595778899064512698498664760717940435782414423772976729459563116160183718747468374937141739412553572018867482865642082393703188890185513223691038301841350276101631351330554646513950989932110804329124023484801488700824626994203880824772706266771038559396783149872539796689886976496560625017840985031071394135667160804480206315159188693647529059368679739650106151078321954251239422453048615090394022589064061659272784158751842302508388581173336863055590405412608620264796793438485794178579716232294615707491649067606798055379865152883973590940631204945055929295864529462362936868362439444018409966377767348580291086876071637083505655040562344931056613681442465526797377296439944392303378833381459186355796836520430441365956911317445518476419778615341328068465282311485056952374638323627514159596216527818921179290778008258129355693184414355561922712415567340144767020734210325018001426874854980349000580054151126827975545003874122915548923486684471207785506749217311577091692530780817356153336355932989981591585534653530423012572292596452474427240749376404395097736289843705992106717022658773513495490949388391766369486459558014863131797960267826225638656128990685615418159730747860770046446650475183276783701505048262293928020190983787178690897031514888068685282782868560329796494192074006713316359278166899968750828444901184582448529489603764086735001469299569615357774898101695736799322159108959458545484088868158961994903795336784051367778341056403358817793787122396297373836642715303166509962588324141415141920547642854443160213156339347730673545622756251077576681113360540468960817005726915169580256952664437981231365080106482028171950927056420936639006543112000462987691586357643266733606386659236208177533023122977585959306550040423802122652682327122107175359386231983001054050543763837317832606145530027530157910107807709956809182514607699099535626787649102696174768122851092453924368713688650132527665999652051839308503726589458044257884489241065910048859045979491522650652740511966284913377127714496617540196036686834886522052399969095838393696509021892174785461428445558584398518178516719164754859377253655679106450757558630353527530103842222910437999272799201396499481819041595767338890884468332741342245423841569190823278736005962558471086186668871429985279114120498141275023664825914042524296857550344836079409827840154192688042133916376131878382870626542911969231973874105310092400266082012273917374387409187591883446228090170272395565253111010196547297026949976630265315717262187709538702384712447236540131161360396907132043900650980731211657601739571392455004194045860357326329987065827864935349807235491989036739036304390661421098147395396327770562068813396072704701709767822266648606719279086606949055023668853028933925260376420702261254069407224822687469587713800448788329584570045585065508699446969502965125934369413167817101645339451981112912427500520195348148163658153827398657084226631137384655760167690403045824692553531730771737584085926420592254930948880030190177981799600524870239548867158207108000815601795616297437450239714407149791177625172123326079088393351639165653074273067734792595105143835522230214109357562461092710388862408650512467509911067928697588560441018551116181138944990402613333921546929046060131068224644321231127905390660561294779638266616028750229446627536801167196032424829239287602346151390258536461802220588105733824516209006827125657863430536795313632922949741759560246462717151427010134157743033727550641867654077385462373924585328997500169201818427132076781664491371103364941331885230159805243066681803986251132584944845921009411380212166653648977737513139305506008523101228765595218857072753206606107225787283349799782274903256029973096213989590807516848294710494474178735931395026733325201959587027824522693867537572682236424744604365675333052216570779090767029733404669988262571325307712734291488654669944707990040342843499302539832720738634915230625625771223293350413990688885714194186166190664771827228732931979897145217345391901432126446170074378871080947285443008135244350761211123932692735934470554186916086618623896324707432793755381196664078493998960589687859598024801414894630040238859235637473778974739746993001961685156159912084254687870718923496810066845939692784922009229578550479088332177672126072137806299539883679030573084385425211512206948281178271274156357046325212109171099191452012749381622676399952801087599364279695493932605774781048786566707040726284103032855213685152820811523882393096989536463771630531554328876788141787593111105549657592480923989483962128096379410752537124970433700804587104192299677742615822885958249212056958040703153187803873917339917432196063665988782281231510613336095901831588173522956244779816257781433523403452092705582320831662963341640921895280638581745208928380920743319480260867500352728947225657286784914195069856285533606526347513779567264105803849632570046489080610202778906589769267002590490844548895088303441197251079043535397271757285159349919912330639881813907706079337982485160300670575414496625964295627124281996366858727586715722051184744587643913027124424611098893622828142815930117146304238807299887724493075784405284297978586301281593258189725827359533433537580849724139161401908974783888964775461904093628569522847580320739547009430931049130927115537273215473230603877661019162297897191343061986002523485202332613740621744436739727401842132238655245172711125529504209793323629375021536265897948767800929278028746736170004288475172899663216089460104558771932075251995450163554482477018616705115024933737423974085467130709245027810790700566141777857624050687155314706527518158075777801111074325480959034499918901148509745225181261114647918370444513564390564319514054981746762402488972166042354428407237897614401888249422160294380162357913382218545864569325260421574673328377196433902683081036485272636589765026606252976444511818527446430259543752699415851897649091911597690226557472301208069826258574882189971318979359623544853040626534622435947707124550517276787602886199132402439736839559773498265491177716064637908316140428623579321612988257163428710914775164162727005553307935129628171812030094451822196557677702782226322679590210165783852813596527170479934522220294241358764495//88466314440309674312597064234059475084258169467024260452149109267022914640052828349751584779790525942217242060103507905774363036221546115555121143515679574483995487096557063190635165704872314365435013236452683345075471588342810616053240696330532197700092687211815943591288881164729687709620576517411433479026016410798331759579844646655019585749288289342592722652386183059929236115629512394760927578247224437292001165318352553175229976888772950086490304174465580296094891425820192714939827729902526306071245236142434548144519923645562805909191593067349802212251072100198128148206375922652742043819461222155269357416394180236000654709277593350030746467440079499557512208248941558131635295452589933804855322791184290930385727570279623476640102046884382915960623813830848129127644092655377555197852241427233039815378647025234755359105702467118618249942873521575231541247947339202470989781695853556800952880008699723091317000393849398309676921165274446126004084008195700475266503368590051806541377948952148596714205480746358845996656930186931529866449092112408024253778598057996477120245554542620468876848310195677553428358746067305064727886211440967714617253212627350901546806435563634949157488190721585497943985448926231820967438695730206833174835900512333739470452440044744257013318445423169850375080556180585669431015553897593991825325908556766137307610349566582837052270758912150695912717219335376759105644146912616205953831016458188667642269847984345910691173264722979972307515049319316907578374195689453993893314671522959808281872011801779710144457277830264290030588863078983651476933202689057161741495508419949131510291287834750099497673665398643463353735673915436202268066413527651129473189955159455584303017157680816222607366262127168640112805470704692381850227322530994223749710401227276064307973336979411299801157879639130938398449339911201004479846297880350350256632689791854214667357717042222778686979454275881300064465869858541621705309792180252206663830404073987418365787487707788741573866015276379952105455906783525532567963679619281137669412317529655015613678625718183157407044612425226818852419767411179634075901814136642287643063280282926879790459801797804895482919988526792431512996528555899574123943146690323555420770390869518603095277492525231339410422586272495347407669887622142969849210452969423604933416529534290486690519145673178898125970366125342484779468701702806321425359360597761547075747951451638310260354928537805776061557193588935033382645840867311329952722860399487269475321826414270515958316346492345365376837781695555628324340157971541571344598196011695429682162604359399530381281723027627926986289439533785879871517153389255477452608551156572734994397820749414559216437075286576132651999520241515309212149402416022276502341995780278261659105756406467441912497113947824638188731047535954026675178018939487769108345764253136267877135948057426716289127641791143446294182190449315593286187290655875367646066946875304309762087912074052414605879275613993964821526086002448389688190826802928214013622198306432415687725686506775165683084962269102144565443045319564942300746255631865973642871114322763348538301388146747359121708190467657834162658915823556238079925514549784845739509390610578350041743891751853856259352054283872266632470502655408375923673740436360064572187953920635167247157513867961544399190732614329494849518441073099346231647604442630925587866986904288952180994674779024376203697969610741552054314750977846387188028506163439896751775050187862621559822267671648721216890662734716584924142592255377785493357195664744684130335100773296420789877335767977118569893953127272243609888098063140378222714319328491558640345284387536263642144675608629688923478201273381576700994137830796994916691279708037076585487066316901381795862561490969224487900841310286599707272498198705267725295716791784092797586359224477483528338743528082717899814423524860075161904227344092086888890591045255827417659860173864970683639609455124975544459759239728449702291628522229927618116392750917128690812198138794462777813297915137707162023232037179873021454075639549883438956194832386985647820237942919023863109975141259475812306062143386630279726196132590955899349117139861977168831007784386229503717864891027865408162446103905052584023531499327789584063504430449882526339723482889824332010113626346750399343823899590107008877809567016501042299938226538769515404284665898221544834701733759851817921231917240325624508333877196502435066618290837011429726433291879237402120930731844992365674638718215499260010745770687905976267505884341523715634567837889067591992474118380494755758851484521569546941731447900230072645745018233802961809852019440833901634559207750726745139117408745938935913503923427444405567505885935802566756375415354843705860568210178357456309923451380541931857743463429154025047269654392622627142283219534000607885915587496098858732382373901085061622391216780339786670855416235689417354042369087595147502618280121965883460033807338193650767920239417044556912711671758521804878534109132008881944791249111399892226695153088394196296837805253797116481626517564467846166633333302224863594663520733007436386289301478604291756226362490125697376297985799557018673049100910901001207534137299592876167367784419741913000311801873634310436298133555272076684365853408853489814343626064442871478777529129751217464698815339806115334440549277506391792362391070923380104647324709927985076662728315017124090123888832380488489694207348200740075989100403334282568621025845018499891296940048668983772894366999944669840066823926611437268713226442963438056933831455261383224049988513170502140972230497299080492943683870483599947489024907973338944858015802485557446563632374724871642641559157733855698803652574648336693685595632927125932728539240570566386821598304388264119341533182470727130637898196645103987329987860001780955505303011211253370714725261407344787551496046119994748381474447977431179484626154385786827186837315743314285897830555643986264949663908638470763295972206212346427834414335097521699716205420597573014711464308176773680479887349414006898266708672291775931220383655054171694676963417973730727251286625852229722439593040607566390258924247525253560081636001436327677561551588862321899619357117811919250540895472376601192138329419640776969698227437156607509021718886615533008062503476856463918464065450594886098570531957218253725857647920288458998022333307761948627622297070808849770131328151066800873581468627121288361943732510924173365293545877125641821222117388274194281759913927483349602182435976038335515242675524469327800425583617685333668846594043224344853154514973797136846728111877376656669231860193634296657751938362533243179803639210031354760117166371651977995598284749560456159591947043341965780007493600510833547078757778281925958338525584814352079073288387728957900623509568904192711195599257052330044444459155681184238025128900076810199635169478588937401828973704782213375061190858791420863539561344283445532402516125423899518053806488950464801299565117619193361992182352239365925509415055931695475026886575143841087405845819494937131303359610747268339385160375710072698059591386750639488687513354361277991054453035273599031817868049867734221144323863168788439514097693188543092173765838285708664098863620066346834534849270228722667228160220949134047152097283734193645165225596405382532057341481669566191514422682772101123253343282944949541135740709122356298285740124886002266837493063280046567245311279961896833295881423400000507504591346283785690719185687744038967771547625320396619091618363618461120508724784371045006280625835997287868075047974793004122567250217000349118138912165938151882695459479082303916467799122902891483789035304709477548807731437929256715049391980183502706554598728061873660734681177549324030008098152936939344047413524569155470207582031715877300541700629600134018128163725663421133721455353084186649575818903553987104094533353495746361908601188787795662590198828166376230468231971710037319866061077551069377483572084700778421619236695698723666029410470940637043896733728332018157656616975806124401872616096876939604107852999248921991775455920652332469083486401580645276749644273435050417777213527869238569198018646434073936599631955093717030984343852651127670917572410028140081829941488546629188517174716364548418687985901493484292350962240530860354516997329916534146447600570425626765888416227101576495906808230733036501771397291833289716129997321739611843856052236359264680307443348392270647161115123453100243694087944055986724891476917450414237277109627849838073531402429225033563554948119654672177501519495135602961773747050157740442506402455319535359479857898325105525203404174316919598450891012028278064319377533624664214033275226261242503532420076194298210879602382419942075710455969648544287283580887784006243974422148228511166060010638604739509579260286979625281264942108968915506194101534286718346551592454411858905905948826482645605834091789956686907694937227535440158210598570694572439211363004459186975282119153149888714143806200291402218286155354159623405795198366236092838307938504271344719839819696065648296892454909270799949612462509635402675089206879783563757496004593451373424496234990385558878462334834267386128152564030625368363641059916586810700082683230035865380282813520764040429163593177031005311980635723939334538114780681757091541771489374084474409559080273285873643467818621930817026469912873880342947154384689079314115877790406035778030951583943516368523683217680205416094303701804280490261529942971153373384011687805272910078545212798261927974125533997584316945699481808955958604024011533298416343952869391090745219725481972481592383284752512353963431992821481124091550456831062681890656581392985588271090074960026532447544784555680176049773643555102614248840814700452109503969923923655858989231756869593322683261401726703815392510516872379846320166756539607023616
7 Likes

Why not 2pi (three strokes)?

3 Likes

I have never been a fan of 2x and such. Even 2pi is too crowded and hard to read.

Yes, I was trying to show that (2pi)::Float64 is exactly equal to that fraction.
(2pi)::Float64 is of course not exactly equal to the rational number.

The Float64 value is also not exactly equal to 411557987 // 65501488, but this number is close enough to round to it when converted to Float64.

2 Likes

xkcd weighed in on this last week:

5 Likes