MS Visual c++中缺少的一个双曲圆弧正切函数

atanh arc-hyperbolic tangent function missing in MS Visual C++

本文关键字:一个 函数 c++ Visual MS      更新时间:2023-10-16

我正在处理一些以前在Linux上用gcc编译器编译的代码,当用MS Visual c++ 2008编译时,math.h似乎不包括所有相同的功能,特别是(逆)弧-双曲正切atanh函数。

我试过包括math.h, cmath,使用std::atanh,并没有发现很多其他与谷歌/MSDN搜索。是否有一个简单的头文件,我可以包括,有这个?

错误C3861: 'atanh':标识符未找到

以下是不同版本的数学库中包含的内容和不包含的内容。

Function  POSIX  old ISO  ISO C99  Microsoft(2008)  
acos      Y      Y        Y        Y     
acosh     Y      N        Y        N    
asin      Y      Y        Y        Y     
asinh     Y      N        Y        N    
atan      Y      Y        Y        Y     
atan2     Y      Y        Y        Y     
atanh     Y      N        Y        N 

你不能使用下列公式来实现你自己的函数:

    asinh(x) = log(x + sqrt(x2 + 1))
    acosh(x) = log(x + sqrt(x2 - 1))
    atanh(x) = (log(1+x) - log(1-x))/2

float atanh (float x)
{
   //implements: return (log(1+x) - log(1-x))/2
}

据此,在c++ 11中引入了atanh。由于c++ 11是在2011年推出的,所以你可能无法在VS 2008中使用它。