Continued Fractions - Maple Help
For the best experience, we recommend viewing online help using Google Chrome or Microsoft Edge.

Online Help

All Products    Maple    MapleSim


Home : Support : Online Help : System : Information : Updates : Maple 16 : Continued Fractions

Enhancements to Continued Fractions in Maple 16

A continued fraction is a mathematical expression of the form  approximating either a constant or a function. Continued fractions are well known to provide very good rational approximations, as demonstrated in the following examples.

 

Example 1: Approximating  by rational numbers

Example 2: Approximating  by a rational function

Periodic continued fractions

Example 1: Approximating  by rational numbers

 

The following command computes the continued fraction approximation to  of order .

(1)

In this case, all "numerators"  are , and all "denominators"  are positive. The successive convergents  of this continued fraction are finite continued fractions, namely rational numbers, giving better and better numerical approximations of . They can be computed by specifying optional arguments:

(2)

(3)

(4)

You can see that the well-known rational approximation  occurs as the second convergent , and it is accurate to  decimal digits after the decimal point.

The best approximations, however, are obtained from the centered continued fraction, which allows "denominators" to be negative as well:

(5)

The ability to obtain the convergents for a centered continued fraction with an optional argument was added in Maple 16.

(6)

(7)

(8)

 

Example 2: Approximating  by a rational function

 

In this example, a continued fraction approximation of order  to the tangent function around  is computed:

(9)

In this example, all the "numerators" are powers of  (up to sign), and the "denominators" exhibit an obvious pattern. Again, the convergents  form approximations of  of higher and higher orders. In this case, we obtain the convergents by calling cfrac twice, since applying cfrac to a continued fraction returns the rational function (or rational number) it represents:

(10)

(11)

(12)

(13)

(14)

(15)

(16)

(17)

In fact, the convergents provide better approximations to then tangent function around  than the Taylor expansion of the same order. Below, this is illustrated for  and the Taylor expansion  to  with the same error term, , by plotting the two differences  and :

(18)

(19)

For example, the absolute errors for the two approximations at  are:

(20)

(21)

The ability to compute a continued fraction at an expansion point other than  was added in Maple 16:

(22)

 

Periodic continued fractions

 

Any rational number has a finite, and therefore periodic, continued fraction. It is a classical fact that more generally a real number has a periodic continued fraction expansion if and only if it is either rational or a real algebraic number of degree , i.e., a number of the form , where  and  are rational numbers and  is a positive integer. For example, the periodic continued fraction expansion for  is:

(23)

Maple's data structure for periodic continued fractions has two components: a list of integers representing the preperiod, and another list of positive integers denoting the repeating period. This representation can be requested using an optional argument:

(24)

As of Maple 16, applying the  command to such a list will return the real number represented by that continued fraction. For example, the following command finds the quadratic irrational number whose continued fraction expansion is an infinite repetition of the period :

(25)

(26)

(27)

 


Download Help Document