大数的正弦的标准 [英] Standard for the sine of very large numbers

查看:141
本文介绍了大数的正弦的标准的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在用TeX(只支持32位整数)写一个(几乎)符合IEEE 854的浮点实现。本标准只规定了 + - * / ,比较,余数和 sqrt :对于这些操作,结果应该相同(根据舍入模式)。

我似乎记得IEEE指定超越函数( sin exp ...)应该产生忠实的结果(在缺省的舍入到最近的模式中,它们应该输出围绕精确结果的两个可表示的数字中的一个)。计算小数字的正弦值相当简单:以2 * pi的倍数移位以获得[0,2 * pi]范围内的数字,然后再做一些工作来将范围缩小到[0,pi / 4] ,并使用一个泰勒级数。



现在假设我想计算sin(1e300)。为此,我需要找到1e300模2 * pi。这就需要知道pi的小数点(小数点后三位),因为只有十六位小数,结果就没有任何意义了(特别是它不可信)。

对于 sin(1e300)和类似的非常大的数字的结果是否有标准?

<其他浮点实现是做什么的?解决方案

没有一个标准需要对超越函数进行忠实的四舍五入。 IEEE-754(2008)推荐 ,但并不要求这些函数被正确地舍入。

(是的,即使对于巨大的输入 sin()和类似的困难的情况)。正如你所注意到的,这要求图书馆知道π的更多数字,然后在最大的可表示数字中有数字。这就是所谓的无限pi的论点缩减。

到@spraff提出的观点,好的数学库采用输入无限精确的观点(即,该函数应该像输入总是准确地表示一样)。人们可以辩论,这是否是一个合理的立场,但那是基本上所有好的数学图书馆的工作假设。



所有这些说,有很多图书馆简单的路线,并使用有限-P1减少,它基本上把像 sin()这样的函数看作是π是可表示的有限数。事实证明,这对于大多数用途并不真正造成任何麻烦,而且当然更容易实现。


I am writing an (almost) IEEE 854 compliant floating point implementation in TeX (which only has support for 32-bit integers). This standard only specifies the result of +, -, *, /, comparison, remainder, and sqrt: for those operations, the result should be identical to rounding the exact result to a representable number (according to the rounding mode).

I seem to recall that IEEE specifies that transcendental functions (sin, exp...) should yield faithful results (in the default round-to-nearest mode, they should output one of the two representable numbers surrounding the exact result). Computing the sine of small numbers is rather straightforward: shift by a multiple of 2*pi to obtain a number in the range [0,2*pi], then do some more work to reduce the range to [0,pi/4], and use a Taylor series.

Now assume that I want to compute sin(1e300). For that I would need to find 1e300 modulo 2*pi. That requires to know 300 (316?) decimals of pi, because with only 16 decimals, the result would have no significance whatsoever (in particular, it souldn't be faithful).

Is there a standard on what the result of sin(1e300) and similar very large numbers should be?

What do other floating point implementations do?

解决方案

There is no standard that requires faithful rounding of transcendental functions. IEEE-754 (2008) recommends, but does not require, that these functions be correctly rounded.

Most good math libraries strive to deliver faithfully rounded results over the entire range (yes, even for huge inputs to sin( ) and similarly hard cases). As you note, this requires that the library know somewhat more digits of π then there are digits in the largest representable number. This is called an "infinite-pi" argument reduction.

To the point that @spraff raises, good math libraries adopt the viewpoint that the inputs are infinitely precise (i.e., the function should behave as though the input is always represented accurately). One can debate whether or not this is a reasonable position, but thats the working assumption for essentially all good math libraries.

All that said, there are plenty of libraries that take the easy route and use a "finite-pi" reduction, which basically treats a function like sin( ) as though π were a representable finite number. It turns out that this doesn't really cause any trouble for most uses, and is certainly easier to implement.

这篇关于大数的正弦的标准的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆