views:

125

answers:

2

I need to calculate Tanh-1 in C#
(and Sinh-1 and Cosh-1)

I did not found it in Math library.. Any suggestions ?

EDIT: Tanh not Tan !!

+7  A: 

You need to define them yourself.

http://en.wikipedia.org/wiki/Hyperbolic_function#Inverse_functions_as_logarithms

    -1     1    1 + x
tanh   x = — ln —————
           2    1 - x

    -1               _______
sinh   x = ln ( x + √ x² + 1 )

    -1               _______
cosh   x = ln ( x + √ x² - 1 )
KennyTM
Note that the natural logarithm is also no function in the standard math class, however, the general logarithm is. You can just use the general logarithm with base _e_ (which is a constant in the math class). Which is of course exactly the definition of the natural logarithm. Just a note for the sake of completeness@KennyTM +1 for the Math-art :)
Henri
@Henri: `Math.Log` *is* the natural logarithm...
KennyTM
You're right, I was too fast :) Indeed the default overload of Math.Log which takes only a double is the natural log.
Henri
+4  A: 

You need to derive them yourself using existing functions e.g. Math.sin

You might find this useful:

Secant Sec(X) = 1 / Cos(X) 
Cosecant Cosec(X) = 1 / Sin(X) 
Cotangent Cotan(X) = 1 / Tan(X) 
Inverse Sine Arcsin(X) = Atn(X / Sqr(-X * X + 1)) 
Inverse Cosine Arccos(X) = Atn(-X / Sqr(-X * X + 1)) + 2 * Atn(1) 
Inverse Secant Arcsec(X) = 2 * Atn(1) – Atn(Sgn(X) / Sqr(X * X – 1)) 
Inverse Cosecant Arccosec(X) = Atn(Sgn(X) / Sqr(X * X – 1)) 
Inverse Cotangent Arccotan(X) = 2 * Atn(1) - Atn(X) 
Hyperbolic Sine HSin(X) = (Exp(X) – Exp(-X)) / 2 
Hyperbolic Cosine HCos(X) = (Exp(X) + Exp(-X)) / 2 
Hyperbolic Tangent HTan(X) = (Exp(X) – Exp(-X)) / (Exp(X) + Exp(-X)) 
Hyperbolic Secant HSec(X) = 2 / (Exp(X) + Exp(-X)) 
Hyperbolic Cosecant HCosec(X) = 2 / (Exp(X) – Exp(-X)) 
Hyperbolic Cotangent HCotan(X) = (Exp(X) + Exp(-X)) / (Exp(X) – Exp(-X)) 
Inverse Hyperbolic Sine HArcsin(X) = Log(X + Sqr(X * X + 1)) 
Inverse Hyperbolic Cosine HArccos(X) = Log(X + Sqr(X * X – 1)) 
Inverse Hyperbolic Tangent HArctan(X) = Log((1 + X) / (1 – X)) / 2 
Inverse Hyperbolic Secant HArcsec(X) = Log((Sqr(-X * X + 1) + 1) / X) 
Inverse Hyperbolic Cosecant HArccosec(X) = Log((Sgn(X) * Sqr(X * X + 1) + 1) / X) 
Inverse Hyperbolic Cotangent HArccotan(X) = Log((X + 1) / (X – 1)) / 2 
Logarithm to base N LogN(X) = Log(X) / Log(N) 
David Relihan