Sometime ago, a user of r/math
posted this outreageous result and claimed that this fraction approximates pi
.
I confirmed this result of his, using J and using PARI/GP.
But today, I was reading the lemma on tacit programming over aplwiki.com and saw this amazing result:
(1∧⊢,÷)2.625
21 8
So I thought to myself, hmm this is nice.
So this is a nice and pretty short function to go from a decimal form of a number to its fractional form.
I wander what will be the fraction that will be the approximation for the most possible digits of Pi, using Dyalog APL.
Note: All the digits of Pi where taken from the math.com website.
pi ← 3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679
(1∧⊢,÷) pi
5419351 1725033
Confirmation:
5419351÷1725033
3.141592654
Hmmm...why so few digits? I'll have to look into this in the near future.
If I do the following in the Dyalog RIDE IDE, the IDE crashes.
pi ← 3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679821480865132823066470938446095505822317253594081284811174502841027019385211055596446229489549303819644288109756659334461284756482337867831652712019091456485669234603486104543266482133936072602491412737245870066063155881748815209209628292540917153643678925903600113305305488204665213841469519415116094330572703657595919530921861173819326117931051185480744623799627495673518857527248912279381830119491298336733624406566430860213949463952247371907021798609437027705392171762931767523846748184676694051320005681271452635608277857713427577896091736371787214684409012249534301465495853710507922796892589235420199561121290219608640344181598136297747713099605187072113499999983729780499510597317328160963185950244594553469083026425223082533446850352619311881710100031378387528865875332083814206171776691473035982534904287554687311595628638823537875937519577818577805321712268066130019278766111959092164201989
In other words, the assignment operator ← seems to be failing.
The error message I'm getting is the following image:
The very helpful brickviking
from the Discord server of r/apljk found the solution on the previous error.
If one does the following before assigning the number to the variable pi
, the pop up error doesn't get displayed!
⎕FR←1287
⎕PP←34
pi←3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679
pi
3.141592653589793238462643383279503
So, now that we've stored a somewhat long value of Pi in the variable named pi
, let's just see what kind of rational Dyalog APL will return:
⍝ pi_old ← 3.141592653589793238462643383279503
(1∧⊢,÷) pi
139755218526788.999999999999992833 44485467702853.00000000000000228133
This is weird. It seems we've reached some limit, because we didn't get exactly integers, but a set of floats that are very close to certain integers.
- I should take the first part of the returning list.
- I should take the second part of the returning list.
- Round them.
- Divide them.
- Compare this result with
pi_old
.