Documentation

This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English verison of the page.

Note: This page has been translated by MathWorks. Please click here
To view all translated materals including this page, select Japan from the country navigator on the bottom of this page.

numlib::contfracPeriodic

Periodic continued fraction expansions

MuPAD® notebooks are not recommended. Use MATLAB® live scripts instead.

MATLAB live scripts support most MuPAD functionality, though there are some differences. For more information, see Convert MuPAD Notebooks to MATLAB Live Scripts.

Syntax

numlib::contfracPeriodic(p, q, n)

Description

numlib::contfracPeriodic(p, q, n) returns the continued fraction expansion of p + q*sqrt(n) as a sequence of two lists: the first one contains the non-periodic part, the second one contains the periodic part of the expansion.

The non-periodic part may be an empty list. No periodic part is returned for rational input, i.e., q = 0 or n square.

Examples

Example 1

The non-periodic part may start with zero. All other coefficients of a continued fraction expansion are positive:

numlib::contfracPeriodic(2/7, 1/7, 2)

The result agrees with that one of contfrac:

op(contfrac(2/7 + 1/7 *sqrt(2)), 1)

Example 2

The golden mean is famous for its simple continued fraction expansion:

numlib::contfracPeriodic(1/2, 1/2, 5)

Example 3

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

numlib::contfracPeriodic(0, 1, 81)

Parameters

p

A rational number

q

A rational number

n

A positive integer

Return Values

If is a rational number, then numlib::contfracPeriodic returns one list, otherwise two lists of integers.

Algorithms

A real number has a periodic continued fraction expansion if and only if it is of the form .

See Also

MuPAD Functions

Was this topic helpful?