Yary, There already is a Perl 6 continue fractions module. Spoiler alert: it doesn't work in the least. But I'd be happy to give you a commit bit.

I don't think we should even begin to think about including something like that in the Perl 6 core before we have a complete, working implementation in a module. Frankly, I'm much more concerned with making the math functions we already have support the types we already have. For instance, right now most such operations use standard floating point doubles under the hood. The exact range of Ints and Rats vastly exceeds that of doubles, so this means that (at least in theory) there are perfectly good mathematical answers we could return that we're not. So, for instance, according to Wolfram Alpha, ln(3 * 10 ** 500) = 1152.391158785690951700390972579104629505198234872209237468398... On the other hand, if I give Rakudo that same problem (switch ln to log), we get "Inf", because 3 * 10 ** 500 cannot be presented as a double. That said, I'm not terrible concerned about that problem, either. But if you were hankering for a Perl 6 math problem to work on, IMO it would be a much better one than trying to exactly represent irrational numbers. On Mon, Jun 22, 2015 at 1:41 PM, yary <not....@gmail.com> wrote: > Thinking over my programming career, there were a few occasions I had to > spend time working around floating point errors, and it was a nuisance. > There were even fewer times when I worked with transcendental numbers- > programs dealing with geometry or tones or logarithmic scales- and those > times, floating point was good enough. > > Which is to say, Perl 6's Rats would have solved my nuisance issues, and I > would not have appreciated exact types for irrational numbers in my tasks > to date. > > Still, I couldn't resist thinking about them and web-searching on them a > bit more, and here's my brain-dump. Periodic continued fractions > <https://en.wikipedia.org/wiki/Continued_fraction> can represent any quadratic > root > <http://www.millersville.edu/~bikenaga/number-theory/periodic-continued-fractions/periodic-continued-fractions.html>. > Haskel has this package implementing a quadratic irrational type > <https://hackage.haskell.org/package/quadratic-irrational-0.0.2/docs/Numeric-QuadraticIrrational.html>, > and it can translate between those and continued fractions. ... here is a > decent intro to continued fractions > <http://www.maths.surrey.ac.uk/hosted-sites/R.Knott/Fibonacci/cfINTRO.html> > . > > That's a comprehensive answer for square roots of rationals, but not for > transcendental > numbers <http://sprott.physics.wisc.edu/pickover/trans.html>. My math is > not so hot, but perhaps a generalized continued fraction > <https://en.wikipedia.org/wiki/Generalized_continued_fraction> type could > perfectly represent transcendental constants like pi and e, with trig and > log/exponentiation functions using them. Then Perl 6 could get this famous > relationship *exactly right*: > > say 1 + e ** (pi * i) > > ... though I suspect it really does take a symbolic math package to get > all combinations of the trig & exponential functions right > <https://cloud.sagemath.com/projects/3966ff36-7109-449d-83a9-49e48e078fea/files/2015-06-22-133206.sagews> > . > > -y > -- Solomon Foster: colo...@gmail.com HarmonyWare, Inc: http://www.harmonyware.com