JavaScript Math asinh: The Complete Guide
The asinh() method comes in handy in programming contexts dealing with trigonometric expressions. The asinh() is the static Math method, and it can be used without creating an object.
JavaScript Math asinh()
To find the hyperbolic arcsine value of a given argument in JavaScript, use the Math.asinh() method. Javascript Math asinh() is a built-in function used to get the hyperbolic arc-sine of a number.
The hyperbolic arc-sine is known by other names such as hyperbolic inverse sine and asinh. It is the inverse of a hyperbolic sine function, i.e., The inverse hyperbolic sine of any value, say x is a value y for which the hyperbolic cosine of y is x.
Syntax
Math.asinh(x)
Parameter(s)
The variable x, whose hyperbolic arcsine value is to be determined.
Return Value
The hyperbolic arcsine value.
Polyfill
Math.asinh = Math.asinh || function(x) { if(x === -Infinity){ return x; } else { return Math.log(x + Math.sqrt(x*x+1)); } };
See the following figure.
Compatibility
- Google Chrome
- Firefox
- Opera
- Safari
- Android webview
- Chrome for Android
- Edge Mobile
- Firefox for Android
- Opera for Android
- Safari on iOS
- Samsung Internet
- Node.js
Non-compatible with: Internet Explorer
JavaScript version: ECMAScript 6
Consider the following examples.
example1.js
The following code demonstrates the use of the asinh() method.
// example1.js var a = -1; var b = 2; var c = 1; var d = 0; console.log(Math.asinh(a)); console.log(Math.asinh(b)); console.log(Math.asinh(c)); console.log(Math.asinh(d));
Output
node example1 -0.881373587019543 1.4436354751788103 0.881373587019543 0
example2.js
The atanh() method cannot be used with complex arguments as only integer arguments are accepted.
// example2.js // Complex values cannot be passed as arguments as follows // Since only integer arguments are accepted. console.log(Math.asinh(2+i));
Output
node example2 ReferenceError: i is not defined
example3.js
The following code demonstrates the use of polyfill for this method.
// example3.js var a = -1; var b = 2; var c = 1; var d = 0; function myfunc(x) { if (x === -Infinity) return x; else return Math.log(x + Math.sqrt(x * x + 1)); } console.log(Math.asinh(a)); console.log(Math.asinh(b)); console.log(Math.asinh(c)); console.log(Math.asinh(d)); console.log(myfunc(a)); console.log(myfunc(b)); console.log(myfunc(c)); console.log(myfunc(d));
Output
node example3 -0.881373587019543 1.4436354751788103 0.881373587019543 0 -0.8813735870195428 1.4436354751788103 0.8813735870195429 0
Conclusion
Javascript Math.asinh() method returns the hyperbolic arc-sine of a number.