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!