What is the accuracy of log() and other functions?

9 ビュー (過去 30 日間)
Jon
Jon 2018 年 2 月 8 日
編集済み: Jan 2018 年 2 月 8 日
What is the accuracy of log()? IEEE 754-2008 recommends log() to be "correctly rounded". However, if I run the following:
single(log(single(0.5423648357391357421875)))
single(log(double(single(0.5423648357391357421875))))
single(log(vpa(0.54236483573913574218751,100)))
There appears to be a >0.5ULP difference for the single precision version of log vs the double/variable versions:
-0.6118164
-0.6118163
-0.6118163
Does MatLab just call the OS's C libraries log/logf function? If that is the case, on Linux, for glibc, errors are specified here: http://www.gnu.org/software/libc/manual/html_node/Errors-in-Math-Functions.html#Errors-in-Math-Functions and logf has 1ULP error, whereas log should have none. But what about on Windows?

採用された回答

Jan
Jan 2018 年 2 月 8 日
編集済み: Jan 2018 年 2 月 8 日
In the documentation of older Matlab version you found that e.g. acos was calculated using FDLIBM, see: http://www.netlib.org . There is an excellent discussion about the implementation of log10 in Matlab up to 6.5, see https://people.eecs.berkeley.edu/~wkahan/LOG10HAF.TXT. Interesting, but does not solve your question. But Kahan said (about a very old Matlab version!):
According to my tests, MATLAB's LOG(x) errs by at worst about
0.8 ulp over the interval 1/4 <= x <= 4
At least I can say, that the problem does not concern the conversion from double to single:
a = 0.5423648357391357421875
b = single(a)
c = double(b)
isequal(a, c) % TRUE
Which library function is used for log is not documented in public. Therefore you have to ask TMW directly. Use the "Contact Us" link on this page.

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeData Type Conversion についてさらに検索

製品

Community Treasure Hunt

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

Start Hunting!

Translated by