Hyperbolic functions Sinh, Cosh, Tanh in Action Script 3 (AS3)

355 views Asked by At

I have been implementing a calculator in Action Script 3 and I found Math classes for sin, cos, tan, asin, acos, atan but I do not find any way to implement sinh, cosh, tanh, asinh, acosh, atanh in Action Script 3.

Do I need to write the code on the basis of raw formulas or is there any AS libraries available which do the work. I am not very good in math so do not want to write it using formulas. Also using formula may result in imprecise result.

Please suggest a way to figure it out for both the cases.

1

There are 1 answers

3
Lutz Lehmann On BEST ANSWER

What formulas did you intend to use? With the means at hand you can easily define

cosh(x) = 0.5*(exp(x)+exp(-x))
sinh(x) = 0.5*(exp(x)-exp(-x))
tanh(x) = 1-2/(1+exp(2*x)) = (exp(2*x)-1)/(exp(2*x)+1)

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