Function reference · Math

continued_fraction

Returns a continued-fraction decomposition of a value.

continued_fraction(value[, depth]) returns a Collection containing the sign, whole part, and a Vector of partial quotients. The optional depth limits the expansion.

Examples

These examples use Nerdamer Notation.

Decompose an exact rational value into its sign, whole part, and partial quotients.

continued_fraction(415/93)
// → (1, 4, [2, 6, 7])

Limit the continued-fraction expansion to the requested depth.

continued_fraction(415/93,2)
// → (1, 4, [2, 6])

Preserve the sign separately for a negative rational value.

continued_fraction(-415/93)
// → (-1, 4, [2, 6, 7])

Expose the compact continued fraction of a familiar rational approximation to pi.

continued_fraction(355/113)
// → (1, 3, [7, 16])

Interfaces

The same operation is available through the interfaces below.

Nerdamer Notation · nerdamer API

Nerdamer Notation

Use this form inside input passed to nerdamer(...).

continued_fraction(arg1, [arg2])

nerdamer.continued_fraction

Call the operation through the default nerdamer import.

nerdamer.continued_fraction(x: ExpressionInput, depth: ExpressionInput): Collection

Parameters

NameTypeDescription
xExpressionInput—
depthExpressionInput—

Returns

Collection

Browse the nerdamer API →

← Back to Function reference