哪种方法来实现EXP函数在C? [英] which method to implement exp function in c?

查看:395
本文介绍了哪种方法来实现EXP函数在C?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要计算在有限precision EXP函数的错误(数据类型是双)。是泰勒级数或其他特殊的算法?

I want to calculate the error of exp function under finite precision(data type is double). Is taylor series or other special algorithm?

推荐答案

一般情况下,实施电子最好的办法 X 是通过调用 EXP 您计算平台提供的功能。

Generally, the best way to implement ex is by calling the exp function provided by your computing platform.

如果做不到这一点,实施 EXP 功能复杂,需要几个深奥的技巧。实施通常涉及:

Failing this, implementing the exp function is complicated and requires several esoteric skills. An implementation typically involves:


  • 测试输入各种特殊情况下,如NaN。

  • 将日志 2 E的专门prepared重新presentation乘以投入,改造从电子 X 的 2 ,其中的 = X 的•登录 2

  • 移动的的整数部分为一个浮点编码的指数字段。

  • 评估的小数部分的指数的的有极小多项式

  • 这两个结果结合以上。

  • Testing the input for various special cases, such as NaNs.
  • Multiplying the input by a specially prepared representation of log2e, to transform the problem from ex to 2y, where y = x • log2e.
  • Moving the integer part of y into the exponent field of a floating-point encoding.
  • Evaluating the exponential of the fractional part of y with a minimax polynomial.
  • Combining the two results above.

此外:


  • 极小极大多项式工程,常有特殊的软件,使用雷米兹算法或类似的东西。

  • 的工作必须有一些扩展precision这样做的最终结果,可以计算precisely。

  • The minimax polynomial is engineered, often with special software, using the Remez algorithm or something similar.
  • The work must be done with some extended precision so that the final result can be calculated precisely.

泰勒级数不适合,因为它们是不准确的,从它们的中心点距离评估功能。这意味着它们把太多的术语收敛于必要precision。有太多的方面,不仅需要时间,而且也难以准确地做算术。

Taylor series are inappropriate for evaluating functions because they are inaccurate away from their center points. This means they take too many terms to converge to the necessary precision. Having too many terms not only takes time but also makes it difficult to do the arithmetic accurately.

这篇关于哪种方法来实现EXP函数在C?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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