数学库中Math.tanh的倒数在哪里?

Isa*_*ger 3 c#

y = Math.Tanh(x)是双曲正切x.但我需要f(y) = x.对于常规切线,有Arctan,但是哪里是Arctanh?

谢谢!

Ben*_*ich 5

我不认为C#库包含弧双曲线三角函数,但它们很容易计算:

atanh(x) = (log(1+x) - log(1-x))/2
Run Code Online (Sandbox Code Playgroud)

在C#中:

public static double ATanh(double x)
{
    return (Math.Log(1 + x) - Math.Log(1 - x))/2;
}
Run Code Online (Sandbox Code Playgroud)


Mar*_*zek 5

你为什么不自己实现一个?你可以在这里找到等式而且 tt 并不难:

public static class MyMath
{
    public static double Arctanh(double x)
    {
        if (Math.Abs(x) > 1)
            throw new ArgumentException("x");

        return 0.5 * Math.Log((1 + x) / (1 - x));
    }
}
Run Code Online (Sandbox Code Playgroud)