up
previous
next
CFApprox, CFApproximants, ContFrac
Syntax
CFApprox(X:RAT, Prec:RAT): RAT
CFApproximants(X:RAT): LIST of INT and RAT
ContFrac(X:RAT):LIST of INT
Summary
continued fractions
Description
CFApprox finds the
simplest rational approximation within a
maximum specified relative error.
CFApproximants returns a list of all continued fraction approximants
to a specified rational
ContFrac returns a list of the continued fraction
denominators
for a given rational number.
example
CFApprox(1.414213, 10^(-2));
17/12
-------------------------------
CFApproximants(1.414213);
[1, 3/2, 7/5, 17/12, 41/29, 99/70, 239/169, 577/408, 816/577, 1393/985,
6388/4517, 7781/5502, 14169/10019, 21950/15521, 36119/25540, 58069/41061,
152257/107662, 210326/148723, 1414213/1000000]
-------------------------------
ContFrac(1.414213);
[1, 2, 2, 2, 2, 2, 2, 2, 1, 1, 4, 1, 1, 1, 1, 1, 2, 1, 6]
-------------------------------