Significant figures discrepancy in complex number operations

1 回表示 (過去 30 日間)
Jeff
Jeff 2016 年 11 月 6 日
回答済み: Walter Roberson 2016 年 11 月 6 日
Attached is my m-file where I take 2 complex numbers X & Y and multiply them by a decaying exponenential, F, & then sum the results. I executed the operation in 2 separate ways: 1) X*F+Y*F; 2) (X+Y)*F;
The results do not concur past 10^-16. You can see this by my workspace variable "alert". Is this due to the precision of significant figures within MATLAB? The 2 approaches should yield the identical results if I am correct.
One might ask why be so concerned past 16 significant figures? What concerns me is that some unforeseen error in computing phase information might crop up. Is there some trick I could implement to avert any unforeseen errors?

回答 (1 件)

Walter Roberson
Walter Roberson 2016 年 11 月 6 日
IEEE 754 Double Precision uses (effectively) 53 bits of mantissa, able to reflect relative changes down to 2^(-53) . If you are using values in the approximate range of 1.0, then 2^(-53) of that is 1.1102230246251565404236316680908203125 * 10^(-16) which is not quite as good as 10^(-16) . In the area of 1.0, a single bit difference translates to about 1E-16 change in output.
It is a truism in floating point calculation that the same calculation performed two different ways that are "algebraically equivalent" can give you different results due to differences in rounding. http://matlab.wikia.com/wiki/FAQ#Why_is_0.3_-_0.2_-_0.1_.28or_similar.29_not_equal_to_zero.3F
Also, I seem to recall that some of the hardware instructions are permitted to have an accuracy less than 1 ULP (Unit In The Last Place); the details of the standard would have to be checked for that kind of detail.
If you need higher precision you will need to use a higher precision package such as the Symbolic Toolbox

カテゴリ

Help Center および File ExchangeNumbers and Precision についてさらに検索

製品

Community Treasure Hunt

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

Start Hunting!

Translated by