- c - 在位数组中找到第一个零
- linux - Unix 显示有关匹配两种模式之一的文件的信息
- 正则表达式替换多个文件
- linux - 隐藏来自 xtrace 的命令
如果我们看一下 C 语言的委员会草案:n1570尤其是关于复杂数学函数行为的 Annex G
,我们可以看到复指数在无穷大处具有以下行为:
cexp(+infinity+I*infinity)=+/-infinity+I*NaN
(where the sign of the real part of the result is unspecified).
我的问题是:为什么?
从数学的角度来看,如果我们以相同的方式逼近实部和虚部的无穷大,则极限是复无穷大(例如参见Wolfram Alpha),对应于无限模数和未定义的参数.
此外,如果我们观察 cexp
函数的行为,它的实部和虚部非常相似(参见 Wolfram Alpha 上的 3D 图)。
所以,我本以为:
cexp(+infinity+I*infinity)=+/-infinity+/-I*infinity
代替:
cexp(+infinity+I*infinity)=+/-infinity+I*NaN
我知道这有很好的理由,但我不明白。谁能给我解释一下这背后的逻辑?
编辑:这里是链接的摘要:
最佳答案
njuffa 链接的文档中确实给出了动机,http://www.open-std.org/jtc1/sc22/wg14/www/C99RationaleV5.10.pdf :
7.3.9.4 The cproj function
Two topologies are commonly used in complex mathematics: the complex plane with its continuum of infinities, and the Riemann sphere with its single infinity. The complex plane is better suited for transcendental functions, the Riemann sphere for algebraic functions. The complex types with their multiplicity of infinities provide a useful (though imperfect) model for the complex plane. The cproj function helps model the Riemann sphere by mapping all infinities to one, and should be used just before any operation, especially comparisons, that might give spurious results for any of the other infinities.
Note that a complex value with one infinite part and one NaN part is regarded as an infinity, not a NaN, because if one part is infinite, the complex value is infinite independent of the value of the other part. For the same reason, cabs returns an infinity if its argument has an infinite part and a NaN part.
G.5.1中也有类似的注释:
... In order to support the one-infinity model, C99 regards any complex value with at least one infinite part as a complex infinity (even if the other part is a NaN), and guarantees that operations and functions honor basic properties of infinities, and provides the cproj function to map all infinities to a canonical one. ...
相关搜索词是黎曼球面中的“黎曼”,黎曼球面是具有单个无穷大的扩展复平面的数学模型,在 Mathematica/Wolfram Alpha 中使用,但在数学中并不普遍。
关于c - 为什么C语言中的cexp(+infinity+I*infinity)=+/-infinity+I*NaN?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17503876/
我是一名优秀的程序员,十分优秀!