gpt4 book ai didi

c - 为什么C语言中的cexp(+infinity+I*infinity)=+/-infinity+I*NaN?

转载 作者:太空狗 更新时间:2023-10-29 17:25:46 24 4
gpt4 key购买 nike

如果我们看一下 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

我知道这有很好的理由,但我不明白。谁能给我解释一下这背后的逻辑?

编辑:这里是链接的摘要:

Summary

最佳答案

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/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com