(octave.info)Rational Approximations


Next: Coordinate Transformations Prev: Special Functions Up: Arithmetic
Enter node , (file) or (file)node

17.7 Rational Approximations
============================

 -- : 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: Note: rats.

 -- : rats (X, LEN)
     Convert X into a rational approximation represented as a string.

     The string can be converted back into a matrix as follows:

          r = rats (hilb (4));
          x = str2num (r)

     The optional second argument defines the maximum length of the
     string representing the elements of X.  By default LEN is 9.

     If the length of the smallest possible rational approximation
     exceeds LEN, an asterisk (*) padded with spaces will be returned
     instead.

     See also: Note: format, Note: rat.


automatically generated by info2www version 1.2.2.9