Does matlab supports rational number types?
古いコメントを表示
I see Matlab stores numbers in floating points [1], which causes round of errors!
For eg:

The above round off error is resulted, because 10^-5 is not a valid 64 bit floating point number in matlab.
However in *Mathematica*, numbers can be stored in rational format [2] (ie integer/integer format), which avoids any round off error for the same computations.

So my question is, will it be possible to avoid such round of errors in matlab?
[2]: https://reference.wolfram.com/language/tutorial/LinearAlgebraMatrixTypes.html
2 件のコメント
Adam
2016 年 9 月 29 日
I think you need the Symbolic Maths toolbox to have handling for this.
All binary floating point numbers are rational numbers.
Also note that the proposed solution just shifts the problem: how should those two integers be stored? Presumably they would be finite integers stored on your computer... which means that there will always be rational numbers that cannot be represented (unless you happen to have infinite memory installed on your laptop).
Using (finite) rational numbers (in the sense the OP proposed) does not completely avoid errors: there are many more irrational numbers than rational numbers, some of which are commonly used. For example, there is no way to exactly represent e.g. sqrt(2) or pi or e as ratios of finite integers. Any attempt to store those values numerically will always include some error.
採用された回答
その他の回答 (0 件)
カテゴリ
ヘルプ センター および File Exchange で Mathematics and Optimization についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!