指令FYL2XP1 [英] Instruction FYL2XP1

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

问题描述

我想知道为什么x86体系结构上的指令 FYL2XP1 能够精确计算数学公式 y ·log 2 ( x +1).

I'm wondering why the instruction FYL2XP1 on x86-architecture computes exactly the mathematical formula y · log2(x + 1).

此公式有什么特别之处?

What's special with this formula?

推荐答案

y 操作数通常是一个编译时间常数,此刻请忽略 x +1 .

The y operand is usually a compile time constant, for the moment forget about the x + 1.

由于 log_b(x)= log_b(2)* log_2(x),因此该指令允许以 x + 1 的任何底数计算对数.
请注意, log_b(2)是一个常数,因为它几乎不需要以底数为自由度来计算对数.

Since log_b(x) = log_b(2) * log_2(x) the instruction allows to compute the logarithm in any base of x + 1.
Note that log_b(2) is a constant since it is seldom necessary to compute the logarithm with a degree of freedom in the base.

FYL2XP1 FYL2X 是仅有的两个计算对数的x87指令.
如果对数是一个代数函数,那么一条指令就足够了,但是由于它是先验的,英特尔给出了两个版本.

FYL2XP1 and FYL2X are the only two x87 instructions that compute the logarithm.
If the logarithm was an algebraic function a single instruction would suffice, but since it is transcendental Intel gave two versions.

FYL2X 可以在对数的整个域上使用,但是在此整个范围内都不是完全准确的,尤其是对于 x 的极小值(我可能会更慢认为它必须缩小范围,使用截断的泰勒展开式或Padé逼近,而不是通过查表来提高准确性.)

FYL2X works on the full domain of the logarithm but it is not perfectly accurate over this full range, particularly for very small values of x (an probably slower, I believe it has to do a range reduction, use a truncated Taylor expansion or a Padé approximation and than improve the accuracy with a table lookup).

FYL2XP1 仅适用于±(1 – sqrt(2)⁄ 2)小范围的输入.
这应该更快(不减小范围),更重要的是,对于给定的输入范围,所使用的近似方法的精度应等于或大于x87 80位浮点精度.

FYL2XP1 instead works only for input in the small range ±( 1 – sqrt(2) ⁄ 2 ).
This should be faster (no range reduction) and more importantly, for the given input range, the approximation method used should have a precision equal or greater than the x87 80-bit floating point precision.

该指令可为epsilon值[寄存器ST(0)中的值]接近0提供最佳精度.小ε(ε)值,与使用FYL2XP1指令相比,可以使用FYL2XP1指令保留更高的有效位数(ε+ 1)作为FYL2X指令的参数.

This instruction provides optimal accuracy for values of epsilon [the value in register ST(0)] that are close to 0. For small epsilon (ε) values, more significant digits can be retained by using the FYL2XP1 instruction than by using (ε+1) as an argument to the FYL2X instruction.

@Mysticial的评论很重要:
在所有其他必要步骤之后, FYL2X 使用的算法可能正在使用 log(x + 1)的近似公式.
要将其转换为 log(x)的公式,必须将输入减一.如果 x 非常小,则 x-1 运算将失去精度(因为两个数字的指数之差会导致大多数 x 的数字向右移).
FYL2XP1 不会执行 x-1 并且不会失去精度.

@Mysticial's comment is a spot on:
The algorithm used by FYL2X is probably using, after all the other necessary steps, an approximation formula for log(x + 1).
To transform this into a formula for log(x) the input must be subtracted by one. A x - 1 operation will lose precision if x is very small (because the big difference in the exponents of the two numbers will shift most of the x's digits off to the right).
FYL2XP1 won't do x - 1 and won't lose precision.

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

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