필터 지우기
필터 지우기

How can I use VPA to do 32 digit precision computations?

조회 수: 2 (최근 30일)
helia
helia 2011년 1월 28일
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?

답변 (1개)

Walter Roberson
Walter Roberson 2011년 1월 28일
For further reading on this topic, please see the FAQ
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

카테고리

Help CenterFile Exchange에서 Number Theory에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by