Previous Page Next Page Contents

numlib::sqrt2cfrac -- continued fraction expansion of square roots

Introduction

numlib::sqrt2cfrac(a) returns the continued fraction expansion of the square root of a as a sequence of two lists: the first one contains the non-periodic (integer) part, the second one contains the periodic part of the expansion.

Call(s)

numlib::sqrt2cfrac(a)

Parameters

a - a positive integer

Returns

If a is a perfect square, numlib::sqrt2cfrac returns a list with one entry; otherwise numlib::sqrt2cfrac returns a sequence of two lists, the first consisting of one integer, the second consisting of one or more integers.

Related Functions

numlib::contfrac

Example 1

The square root of 87 can be written as 9+q, where q is a rational number satisfying q= 1/(3+1/(18+q)) :

>> numlib::sqrt2cfrac(87)
                               [9], [3, 18]

Example 2

Since 81 is a perfect square, there is no periodic part in the continued fraction expansion of its square root:

>> numlib::sqrt2cfrac(81)
                                    [9]

Changes




Do you have questions or comments?


Copyright © SciFace Software GmbH & Co. KG 2000