任意精度算术是否影响数值分析软件?

发布于 2024-07-30 04:40:35 字数 410 浏览 2 评论 0原文

任意精度算术是否影响数值分析软件

我觉得大多数数值分析软件都继续使用相同的浮点数和双精度数。

如果我是对的,我很想知道原因,因为在我看来,有些计算可以从使用任意精度算术中受益,特别是当它与有理数表示结合使用时,就像在GNU 多精度库上完成。

如果我错了,例子会很好。

Has arbitrary-precision arithmetic affected numerical analysis software?

I feel that most numerical analysis software keeps on using the same floats and doubles.

If I'm right, I'd love to know the reason, as in my opinion there are some calculations that can benefit from the use of arbitrary-precision arithmetic, particularly when it is combined with the use of rational number representation, as been done on the GNU Multi-Precision Library.

If I'm wrong, examples would be nice.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(8

凡间太子 2024-08-06 04:40:35

任意精度速度慢。 非常慢。 当您使用产生无理值的函数(例如大多数三角函数)时,您就会失去任意精度优势。

因此,如果您不需要或无法使用该精度,为什么要花费所有 CPU 时间呢?

Arbitrary precision is slow. Very slow. And the moment you use a function that produces an irrational value (such as most trig functions), you lose your arbitrary precision advantage.

So if you don't need, or can't use that precision, why spend all that CPU time on it?

风流物 2024-08-06 04:40:35

具有任意精度算术
影响数值分析软件吗?
我觉得大部分数值分析
软件继续使用相同的
浮动和双打。

有几个不幸的原因导致不使用任意精度 (ap)
更广泛。

  • 缺乏对重要功能的支持:缺少 NaN/Infinities 的值、没有复数或特殊函数、舍入模式的实现缺乏或存在错误(甚至在 GMP 中未实现舍入一半)、缺少重要事件的处理程序(丢失有效数字、溢出、下溢...好吧,这甚至在大多数标准库中都没有实现)。
    为什么这很重要? 因为如果没有它,你必须投入大量精力以任意精度来表达你的问题(曾经在 ap 中编写过复数库或特殊函数吗?),你无法重现你的双精度结果,因为 ap 缺乏你需要的功能
    跟踪更改。

  • 99.9% 的程序员对数字根本不感兴趣。 这里最常被问到的问题之一是:“为什么 0.1+0.1 不是 0.2 ???帮助!!!” 那么程序员为什么要投资
    有时间学习具体的 ap 实现并阐述自己的问题吗?
    如果你的 ap 结果与 double 结果不同,并且你不懂数字,你如何找到错误? 双精度是否太不精确? ap库有bug吗? 到底是怎么回事 ?! 谁知道....

  • 许多确实知道如何计算的数字专家不鼓励使用 ap。 由于对 FP 的硬件实现感到沮丧,他们坚持认为可再现性无论如何“不可能”实现,并且输入数据几乎总是只有几个有效数字。 因此,他们主要分析精度损失并重写关键例程以将其最小化。

  • 基准成瘾。 哇,我的电脑比其他人快。 正如其他评论员正确指出的那样, ap 比硬件支持的浮点数据类型慢得多,因为您必须使用每手的整数数据类型对其进行编程。 其中之一迫在眉睫
    这种态度的危险在于,程序员完全没有意识到问题所在,选择的解决方案却吐出了令人印象深刻的无意义数字。 我对 GPGPU 非常谨慎。 当然,显卡比处理器快得多,但其原因是精度和准确度较低。 如果您使用浮点数(32 位)而不是双精度数(64 位),则需要计算和传输的位数会少得多。 人眼的容错能力很强,因此一两个结果不合格也没关系。 哎呀,作为硬件构造者,您可以使用不精确、四舍五入的计算来加速计算(这对于图形来说确实没问题)。 摆脱那些讨厌的次正规实现或舍入模式。 处理器不如 GPU 快是有充分理由的。

我可以推荐 William Kahans 页面 链接文本 以获取有关数字问题的一些信息。

Has arbitrary-precision arithmetic
affected numerical analysis software?
I feel that most numerical analysis
software keeps on using the same
floats and doubles.

There are several unfortunate reasons that arbitrary-precision (ap) is not used
more extensively.

  • Lack of support for important features: missing values for NaN/Infinities, no complex numbers or special functions, lack or buggy implementation of rounding modes (round half-even not implemented in GMP), lack of handlers for important events (loss of significant digits, overflow, underflow...ok,this isn't even implemented in most standard libraries).
    Why is this important ? Because without that you must invest much energy to formulate your problem in arbitrary precision (ever written a complex number library or special functions in ap ?), you can't reproduce your double result because ap lacks the features you need
    to track the changes.

  • 99,9% of all programmers aren't interested in numerics at all. One of the most asked question here is: "Why is 0.1+0.1 NOT 0.2 ???? HELP !!!" So why should programmers invest
    time to learn a specific ap implementation and formulate their problem in it ?
    If your ap results diverge from the double results and you have no knowledge of numerics, how do you find the bug ? Is double precision too inexact ? Has the ap library a bug ? WHAT IS GOING ON ?! Who knows....

  • Many numeric experts who does know how to compute discourage the use of ap. Frustated by the hardware implementations of FP they insist that reproducability is anyway "impossible" to implement and input data has almost always only few significant digits. So they mostly analyze the precision loss and rewrite the critical routines to minimize it.

  • Benchmark addiction. Wow, my computer is FASTER than others. As the other commentators rightly remarked, ap is much slower than hardware supported floating-point datatypes because you must program it with the integer datatypes per hand. One of the imminent
    dangers of this attitude is that the programmers, totally unaware of the problems, choose solutions who spit out totally impressive nonsense numbers. I am very cautious about GPGPU. Sure, the graphic cards are much, much faster than the processor, but the reason for that is less precision and accuracy. If you use floats (32bit) instead of doubles(64bit), you have much less bits to compute and to transfer. The human eye is very fault-tolerant, so it does not matter if one or two results are off-limits. Heck, as hardware constructor you can use imprecise, badly rounded computations to speed up your computations (which is really ok for graphics). Throw off those pesky subnormal implementation or rounding modes. There is a very good reason why processors aren't so fast as GPUs.

I can recommend William Kahans page link text for some information about the problems in numerics.

苹果你个爱泡泡 2024-08-06 04:40:35

Wolfram 研究所投入了大量的精力,以务实的方式将任意精度区间算术纳入 Mathematica 的核心,并且做得非常出色。 Mathematica 几乎可以透明地以任意精度进行任何计算。

Wolfram Research Institute put a huge amount of effort in getting arbitrary-precision interval arithmetic into the core of Mathematica in a pragmatic way and they did an excellent job. Mathematica will transparently do almost any computation to arbitrary precision.

淡水深流 2024-08-06 04:40:35

如果您查看像 Mathematica 这样的程序,我强烈怀疑您会发现它们在工作中不使用浮点数和双精度数。 如果您查看密码学,您肯定会发现它们不使用浮点数和双精度数(但它们主要使用整数)。

这基本上是一个判断。 那些认为自己的产品将受益于准确性和精度提高的人们使用扩展精度或任意精度算术软件。 那些认为不需要精度的人不会使用它。

If you look at programs like Mathematica, I strongly suspect you'd find that they do not use floats and doubles for their work. If you look at cryptography, you will definitely find that they do not use floats and doubles (but they are mainly working with integers anyway).

It is basically a judgement call. The people who feel that their product will benefit from increased accuracy and precision use extended-precision or arbitrary-precision arithmetic software. Those who don't think the precision is needed won't use it.

梦断已成空 2024-08-06 04:40:35

任意精度不适用于无理值。 我认为把一切颠倒过来会对数值分析软件有所帮助。 您不必计算计算所需的精度,而是应该告诉软件您想要的最终精度,它会计算出所有结果。

这样它就可以使用足够大的有限精度类型来进行计算。

Arbitrary precision doesn't work well with irrational values. I think flip everything upside down would help numerical analysis software. Instead of figuring how what precision is needed for the calculation, you should tell the software what you want the final precision to be and it'll figure everything out.

This way it can use a finite precision type just large enough for the calculation.

一影成城 2024-08-06 04:40:35

您很少需要数值问题的精确答案 - 几乎总是需要结果达到一定的给定精度。 如果由专用硬件执行操作也是最有效的。 总而言之,这意味着硬件面临着提供对大多数常见问题具有足够准确性的实现的压力。

因此,经济压力为常见情况创建了有效的(即基于硬件的)解决方案。

It's very rare that you need an exact answer to a numerical problem - it's almost always the case that you need the result to some given accuracy. It's also the case that operations are most efficient if performed by dedicated hardware. Taken together that means that there is pressure on hardware to provide implementations that have sufficient accuracy for most common problems.

So economic pressure has created an efficient (ie hardware based) solution for the common cases.

找回味觉 2024-08-06 04:40:35

This paper by Dirk Laurie presents a cautionary tale on the use of variable precision.

赤濁 2024-08-06 04:40:35

虽然与您的问题没有直接关系,但您可能还想看看论文< /a> 作者:l Trefethen

Although not directly related to your question you might also want to look at this paper by l Trefethen

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文