Integration with pi - Rational Approximation?

I'm having trouble understanding the difference between these two integration commands:
clear; syms y;
int(1000*9.8*(10-y)*(pi*6^2),0,10)
int(9.8*1000*(pi*6^2)*(10-y),0,10)
On my machine (2019b - Windows) and MATLAB Online, using format short I get:
ans =
17640000*pi
ans =
14876074069235525/268435456
I often receive odd rational approximations when integrating using pi (note that leaving pi out of the integral fixes the issue). I haven't been able to find an answer as to why this happens. I'm assuming MATLAB computes a decimal answer using pi, cuts the approximation at the 14 or 15th decimal place, then creates a fraction out of the result, but why does this happen some times and not others?

 採用された回答

Sai Sri Pathuri
Sai Sri Pathuri 2019 年 11 月 1 日

0 投票

1 件のコメント

Paul Dostert
Paul Dostert 2019 年 11 月 2 日
移動済み: DGM 2023 年 1 月 12 日
Thanks so much. Makes perfect sense!

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

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeSymbolic Math Toolbox についてさらに検索

製品

リリース

R2019b

質問済み:

2019 年 10 月 28 日

移動済み:

DGM
2023 年 1 月 12 日

Community Treasure Hunt

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

Start Hunting!

Translated by