Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Where's the inverse of Math.tanh in the math libraries?

Tags:

c#

y = Math.Tanh(x) is the hyperbolic tangent of x. But I need f(y) = x. For the regular tangent there's Arctan, but where's Arctanh?

thanks!

like image 524
Isaac Bolinger Avatar asked Dec 12 '22 08:12

Isaac Bolinger


1 Answers

I don't think the C# libraries include the arc hyperbolic trig functions, but they're easy to compute:

atanh(x) = (log(1+x) - log(1-x))/2

In C#:

public static double ATanh(double x)
{
    return (Math.Log(1 + x) - Math.Log(1 - x))/2;
}
like image 67
Ben Reich Avatar answered Jan 01 '23 01:01

Ben Reich