用整数数学解决严格的不等式并解决舍入误差

时间:2016-11-03 15:03:25

标签: floating-point precision floating-accuracy ieee-754 epsilon

我有一个T类型的浮点数,其中T可以是float或double

T x[n];

这些数字是严格正面和分类的,即

0 < x[0] < x[1] < x[2] < ... < x[n-1]

我想找到H类型的最小浮点数T,以便严格满足以下不等式:

int(x[i+1]*H) > int(x[i]*H)   // for i=0..n-2

我们假设数字x使得没有下溢或溢出问题需要担心。

我正在接近下面描述的问题,我不确定它是否健壮,当它起作用时,我认为会产生一个次优的结果。

有没有一种强大而准确的方法来解决这个问题?我可以接受一个次优的解决方案,但至少它需要很强大。

我目前的方法

我使用符号m(x)来表示近似x的浮点数,并可能受到舍入误差的影响。在下面的段落中,我将下面的不等式修改为适当的上限和下限。请注意,以下内容不应被解释为源代码,而是作为获得最终方程的物质步骤和推理。

Let a(x) be the closest floating point number toward -inf
Let b(x) be the closest floating point number toward +inf

// Original inequality, where the operation affected by rounding error
// are marked with m()
int(m(x[i+1]*H)) > int(m(x[i]*H))   // for i=0..n-2

// I remove `atoi` subtracting and adding 0.5 
// this is a conceptual operation, not actually executed on the machine,
// hence I do not mark it with an m()
m(x[i+1]*H) - 0.5 > m(x[i]*H) + 0.5   // for i=0..n-2

// I reorganize terms
m(x[i+1]*H) - m(x[i]*H) >  1.0        // for i=0..n-2

// I would like to resolve the m() operator with strict LHS minorant and RHS majorant
// Note I cannot use `a(x)` and `b(x)` because I do not know `H` 
// I use multiplication by `(1+2*eps)` or `(1-2*eps)` as I hope this 
// will result in a number strictly greater (or lower) than the original one. 
// I already know this does not work for example if x is very small.
// So this seems like a pitfall of this approach.
x[i+1]*H(1-2*eps) - x[i]*H*(1+2*eps) >  b(1)  // for i=0..n-2

// solve the inequality for H, marking the operations affected by rounding 
// with m()
H > m( b(1) / m( x[i+1](1-2*eps) - x[i]*(1+2*eps) ) ) // for i=0..n-2

// take majorant or minorant as appropriate for rounded terms
H > b( b(1) / a( x[i+1](1-2*eps) - x[i]*(1+2*eps) ) )   // for i=0..n-2

// and eventually take a majorant which gives me the final formula for H
H = b( b( b(1) / min{ a( x[i+1](1-2*eps) - x[i]*(1+2*eps) ) } ) )

0 个答案:

没有答案