<< primes Discrete mathematics elementarymatrices >>

Scilab help >> Elementary Functions > Discrete mathematics > rat

rat

浮動小数点数の有理数近似

呼び出し手順

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

パラメータ

x

実数のベクトルまたは行列

n

整数のベクトルまたは行列

d

整数のベクトルまたは行列

y

実数のベクトルまたは行列

説明

[N,D] = rat(x,tol) は, abs(N./D - X) <= tol*abs(x)の意味で N./Dがxに近くなるような 2つの整数行列を返します. 有理数近似は分数展開を丸めることにより生成されます. デフォルトは tol = 1.e-6*norm(X,1) です. y = rat(x,tol) は商 N./Dを返します.

例

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

参照

<< primes Discrete mathematics elementarymatrices >>