On Jun 2, 4:21 am, Brendan Kenny <[email protected]> wrote: > 2) or, if it needs to remain in js-land, just expose a sinh() function > for use just like the page at your first link suggests: (e^x - e^(- > x)) / 2. Just be careful with your NaNs and Infs.
Actually, be careful with small values of x too. e^x = 1 + x +x^2/2 + x^3/6 +..., but sinh x = x + x^3 / 6 + .... Using e^x directly for small values of x automatically loses significant digits. The mathematical definition of a special function is rarely the way you want to compute it. Look up computational procedures in AMS 55, or the Numerical Recipes series. You might find yourself using continued fractions, or Pade approximants. You almost certainly want to use different procedures for different values of x. Given that you have expm1 available, try sinh x = e^(-x) (e^(2x) - 1) / 2 if you have nothing else available: Math.exp(-x) * Math.expm1(2.0*x) / 2.0. Switch to the standard method when |x| > 0.1. But in any case, use e^(-x) = 1/e^x. Look up AMS 55 (Abromowitz and Stegun), the Numerical Recipes series (Press, et al), and Numerical Methods that (Usually) Work (Acton). Why is the original poster using hyperbolic functions anyway? Respectfully, Eric Jablow -- You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.
