Logarithm of complex sine and cosine avoiding overflow

版本 1.0.0.0 (2.3 KB) 作者: David Young
Functions to compute log(sin(Z)) and log(cos(Z)) avoiding overflow for large abs(imag(Z)).
171.0 次下载
更新时间 2011/9/19

查看许可证

log(cos(Z)) and log(sin(Z)) return infinities for abs(imag(Z)) > 711 in double precision, or abs(imag(Z)) > 90 in single precision. The overflow occurs in the trigonometric function; the correct final result has about the same magnitude as Z, and can be readily computed.

Using logcos(Z) or logsin(Z) instead of log(cos(Z)) or log(sin(Z)) respectively avoids the overflow, greatly extending the range of arguments which give a useful result.

The functions exploit a simple approximation; this is only applied when the approximation error is less than the precision to which numbers can be represented, so there is no loss of accuracy. Both single and double precision computation are supported.

Note that there is no point in using these functions when computing with real numbers, or with complex numbers if it is known that the imaginary part is close to zero.

引用格式

David Young (2024). Logarithm of complex sine and cosine avoiding overflow (https://www.mathworks.com/matlabcentral/fileexchange/32947-logarithm-of-complex-sine-and-cosine-avoiding-overflow), MATLAB Central File Exchange. 检索时间: .

MATLAB 版本兼容性
创建方式 R2011a
兼容任何版本
平台兼容性
Windows macOS Linux
类别
Help CenterMATLAB Answers 中查找有关 Correlation and Convolution 的更多信息

Community Treasure Hunt

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

Start Hunting!
版本 已发布 发行说明
1.0.0.0