From c2ae5d3f4cb5925856e9f30618d2940fef0b4cab Mon Sep 17 00:00:00 2001 From: rolux Date: Wed, 13 Jun 2012 00:04:28 +0200 Subject: [PATCH] add acosh, atanh and tanh --- source/Ox/js/Math.js | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/source/Ox/js/Math.js b/source/Ox/js/Math.js index fe0a79c9..4b8f7baf 100644 --- a/source/Ox/js/Math.js +++ b/source/Ox/js/Math.js @@ -1,5 +1,13 @@ 'use strict'; +/*@ +Ox.acosh Inverse hyperbolic cosine + Missing from `Math`. +@*/ +Ox.acosh = function(x) { + return Math.log(x + Math.sqrt(x * x - 1)); +}; + /*@ Ox.asinh Inverse hyperbolic sine Missing from `Math`. @@ -10,6 +18,14 @@ Ox.asinh = function(x) { return Math.log(x + Math.sqrt(x * x + 1)); }; +/*@ +Ox.atanh Inverse hyperbolic tangent + Missing from `Math`. +@*/ +Ox.atanh = function(x) { + return 0.5 * Math.log((1 + x) / (1 - x)); +}; + /*@ Ox.deg Takes radians, returns degrees Missing from `Math`. @@ -140,3 +156,11 @@ Ox.sinh Hyperbolic sine Ox.sinh = function(x) { return (Math.exp(x) - Math.exp(-x)) / 2; }; + +/*@ +Ox.tanh Hyperbolic tangent + Missing from `Math`. +@*/ +Ox.tanh = function(x) { + return (Math.exp(x) - Math.exp(-x)) / (Math.exp(x) + Math.exp(-x)); +};