rat

rat — Floating point rational approximation

Calling sequence

[N,D]=rat(x [,tol])  
y=rat(x [,tol])  

Parameters

x : real vector or matrix
n : integer vector or matrix
d : integer vector or matrix
y : real vector or matrix

Description

[N,D] = rat(x,tol) returns two integer matrices so that N./D is close tox in the sense that abs(N./D - X) <= tol*abs(x). The rational approximations are generated by truncating continued fraction expansions. tol = 1.e-6*norm(X,1) is the default. y = rat(x,tol) return the quotient N./D

Examples



[n,d]=rat(%pi)
[n,d]=rat(%pi,1.d-12)
n/d-%pi
 
  

See also

int, round