フィルターのクリア

wrong rational numbers generated by Matlab

2 ビュー (過去 30 日間)
S H
S H 2020 年 1 月 13 日
コメント済み: Steven Lord 2020 年 1 月 13 日
Example:
23/52
ans =
0.4423
rats(0.4423)
ans =
' 1100/2487 '
The correct answer is 23/52 and not 1100/2487 generated by Matlab. This error is very problemtaic because it ruins the possibility to express a given series with their proper closed-form expression in terms of an input number such as n.

採用された回答

Guillaume
Guillaume 2020 年 1 月 13 日
Hum:
>> rats(23/52)
ans =
' 23/52 '
So, no issue there.
Of course, 23/52 is not equal to 0.4423, so if you give a rounded down input of 0.4423, why would you expect 23/52 when 1100/2487 is actually closer in value:
>> 23/52 - .4423
ans =
7.69230769226414e-06
>> 1100/2487 - 0.4423
ans =
-4.02090872819727e-08
Note:
>> format longg
>> 23/52
ans =
0.442307692307692
  1 件のコメント
Steven Lord
Steven Lord 2020 年 1 月 13 日
Taking Guillaume's last code segment the next logical step by showing both numbers:
>> format longg
>> format compact
>> 23/52, 1100/2487
ans =
0.442307692307692
ans =
0.442299959790913

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeMathematics についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by