How can I use VPA to do 32 digit precision computations?
3 ビュー (過去 30 日間)
古いコメントを表示
I need to do very high precision computation (32 digit) and therefore I started to work with vpa. I eaither can't get it right or there is some bug with this function. Here is a simple test that I run:
>> clear all;syms p; f=p^10; vpa(subs(f,p,0.1),32)
ans =
0.000000000100000000000000055342008016114
>> clear all;syms p; f=p^10; vpa(subs(f,p,0.1),16)
ans =
0.0000000001000000000000001
>> clear all;syms p; f=p^10; vpa(subs(f,p,0.1),8)
ans =
0.0000000001
One would hope that the high precision of 32 digits, would give correct result for 10^(-10). Can you please help me understand what is goin on here?
0 件のコメント
回答 (1 件)
Walter Roberson
2011 年 1 月 28 日
When you are doing the subs(), you are substituting in the binary floating point representation of 0.1 . The closest to 0.1 that can be represented is 0.1000000000000000055511151231257827021181583404541015625 .
You can fix your code by using sym('0.1') instead of 0.1
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Numbers and Precision についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!