Navigation

Operators and Keywords

Function List:

C++ API

: s = rat (x, tol)
: [n, d] = rat (x, tol)

Find a rational approximation to x within the tolerance defined by tol using a continued fraction expansion.

For example:

rat (pi) = 3 + 1/(7 + 1/16) = 355/113
rat (e) = 3 + 1/(-4 + 1/(2 + 1/(5 + 1/(-2 + 1/(-7)))))
        = 1457/536

When called with two output arguments return the numerator and denominator separately as two matrices.

See also: rats.

Package: octave