Git Product home page Git Product logo

continuedfractions.jl's Introduction

ContinuedFractions.jl

Build Status codecov

Usage

julia> using ContinuedFractions

julia> cf = ContinuedFraction(sqrt(2))
ContinuedFraction{Int64}([1,2,2,2,2,2,2,2,2,2    2,2,2,2,2,2,2,2,2,3])

julia> collect(convergents(cf))
22-element Array{Rational{Int64},1}:
        0//1
        1//1
        3//2
        7//5
       17//12
       41//29
       99//70
      239//169
      577//408
     1393//985
         
    47321//33461
   114243//80782
   275807//195025
   665857//470832
  1607521//1136689
  3880899//2744210
  9369319//6625109
 22619537//15994428
 77227930//54608393

For additional significant digits you can use BigInt / BigFloat.

julia> cf = ContinuedFraction(sqrt(big(2)))
julia> collect(convergents(cf))

101-element Array{Rational{BigInt},1}:
                                       1//1                                      
                                       3//2                                      
                                       7//5                                      
                                      17//12                                     
                                      41//29                                     
                                      99//70                                     
                                     239//169                                    
                                     577//408                                    
                                    1393//985                                    
                                    3363//2378                                   
                                    8119//5741                                   
                                   19601//13860                                  
                                   47321//33461                                  
                                                                                
     14085805418356991727446091676022499//9960168529794442859224531878561050     
     34006142477945877445895155433144599//24045973948151434586670623554583549    
     82098090374248746619236402542311697//58052116426097312032565778987728148    
    198202323226443370684367960517767993//140150206800346058651802181530039845   
    478502736827135487987972323577847683//338352530026789429336170142047807838   
   1155207796880714346660312607673463359//816855266853924917324142465625655521   
   2788918330588564181308597538924774401//1972063063734639263984455073299118880  
   6733044458057842709277507685523012161//4760981394323203445293052612223893281  
  16255007246704249599863612909970798723//11494025852381046154570560297746905442 
  39243058951466341909004733505464609607//27749033099085295754434173207717704165 
  94741125149636933417873079920900017937//66992092050551637663438906713182313772 
 228725309250740208744750893347264645481//161733217200188571081311986634082331709

continuedfractions.jl's People

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.