编写公式以减少舍入误差的最佳方法是什么

计算科学 数值分析 正则
2021-11-30 21:39:31

我有如下表达式(无论如何要输入乳胶?),

zm(ln(zz1)k=1mzkk)

对于 m 整数,z 复数

似乎如果我按照以下方式对其进行编码,它会在|z|1

    Z_1=1/Z

    ZV1=LOG(Z/(Z-1))
    ZK=1.0_q
    DO K=1,M;          ZK=ZK*Z_1
      ZV1=ZV1-ZK/K
    ENDDO
    ZV1=ZV1/ZK

关于更好地编码这个表达式的方法有什么建议吗?谢谢,

补充说明:

我已经将以下两个等效表达式与 gfortran 内置函数 Log 和 Mathematica NIntegrate 进行了比较,

ln(zz1)

011zxdx

使变得复杂,并发现这两个在小的. (我将 NIntegrate 推到 PrecisionGoal 的)。这种差异似乎是我寻求帮助的表达错误的原因(如果可能的话,我可以上传一个数字来支持我在这里提出的主张)。z1015|z|1017

你认为这可能是这种情况吗?我应该相信哪个结果,来自内置函数还是来自数值收敛的结果?如果使用泰勒级数来帮助提高数值收敛性,如何处理的情况,这不验证任何级数展开?|z|1

补充说明:

除了 Mathematica 对 Log 函数做得不够好的可能性之外,对于某些输入 z 值,NIntegrate 也可能没有达到规定的精度目标。我试图用 Mathematica 澄清这个问题,看看他们是如何回应的。

2个回答

如果我正确地将要计算的表达式转换为数学符号,那么我们正在处理的是减去的幂级数展开中(对应于的扩展)。这将导致相减抵消,从而放大舍入误差相对于差值的大小。mln(1z1)ln(1+z)

ln(1z1)=k=1zkk

The difference between this power series and its truncation at the k=m index is then scaled by zm. But multiplying by zm for |z|1 should not have substantial impact on the relative error of the final result.

My suggestion is to implement a summation of the tail of the power series, the portion left after the leading terms are subtracted off:

k=m+1zmkk

I will turn my hand to implementing this for complex z in a neighborhood of 1, but note that the Question asks for something different: a computation valid for z in a neighborhood of the unit circle!

Here lies a serious difficulty, in that the natural logarithm is a multi-valued function in the complex plane, and any valid branch cut will intersect the unit circle.

The principal branch of the natural logarithm is formed to agree with the real natural logarithm on the positive real axis. The branch cut is then chosen (as a matter of convention) to be the origin and the negative real axis (in the complex plane).

Therefore some clarification is needed of where in the neighborhood of the unit circle (annulus) the computation is expected to be valid (which branch of the natural logarithm are we going to compare to for accuracy).

You could try asking Herbie, a piece of software that was designed to find more accurate formulas http://herbie.uwplse.org/