Next Page Contents

numlib::contfrac -- the domain of continued fractions

Introduction

numlib::contfrac(a, n) creates a continued fraction approximation for a, using the first n digits of its floating-point evaluation.

Creating Elements

numlib::contfrac(a <,n>)

Parameters

n - positive integer
a - numerical expression

Details

Method approx: rational approximation

Method unapprox: find simple continued fraction in interval

Method _plus: sum of two continued fractions

Method _mult: product of two continued fractions

Method _invert: Inverse of a continued fraction

Method _power: Integer power of a continued fraction

Example 1

numlib::contfrac can also compute continued fraction expansions of irrational numbers:

>> a:= numlib::contfrac(PI, 5): 
   b:= numlib::contfrac(sqrt(7), 2): 
   a, b
                      1                          1
            ---------------------- + 3, ------------------- + 2
                    1                          1
            ------------------ + 7      --------------- + 1
                  1                          1
            ------------- + 15          ----------- + 1
                1                          1
            --------- + 1               ------- + 1
             1                           1
            --- + 292                   --- + 4
            ...                         ...

All basic arithmetical operations are available:

>> a + b, a*b, a^3
                  1                1               1
           --------------- + 5, ------- + 8, ------------- + 31
                1                1              1
           ----------- + 1      --- + 3      ------- + 159
              1                 ...           1
           ------- + 3                       --- + 3
            1                                ...
           --- + 1
           ...

Changes




Do you have questions or comments?


Copyright © SciFace Software GmbH & Co. KG 2000