JavaScript | Math.acosh() function

The Math.acosh() function is an inbuit function in JavaScript which is used to get hyperbolic arc-cosine of a number.
The hyperbolic arc-cosine is known with many names such as hyperbolic inverse cosine and acosh.It is inverse of the hyperbolic cosine function i.e, The inverse hyperbolic cosine of any value say x is the value y for which the hyperbolic cosine of y is x.

if y = acosh(x)
then x = cosh(y)

For all x≥1,
we have acosh(x)=ln(x+√ x2-1 )

Syntax:

Math.acosh(x)

    Parameters:

  • Here x is a number whose hyperbolic arc-cosine is going to be calculated.
  • Return value:

  • It returns the hyperbolic arc-cosine of the given number.If the number is less than 1, it return NaN i.e, not a number.
  • Browser Support:

  • Here 2nd column contain int values which are version of the corresponding browser.
    Feature Basic support
    Chrome 38
    Edge Yes
    Firefox 25
    Internet Explorer No
    Opera 25
    Safari 8
    Android webview Yes
    Chrome for Android Yes
    Edge mobile Yes
    Firefox for Android 25
    Opera Android Yes
    iOS Safari 8

Examples:

Input: Math.acosh(1)
Output: 0

Explanaition:
Here output 0 is the hyperbolic arc-cosine of a number 1.

Input: Math.acosh(2)
Output: 1.3169578969248166
Input: Math.acosh(3)
Output: 1.7627471740390859

Let\’s see JavaScripts program:

filter_none

edit
close

play_arrow

link
brightness_4
code

// Here different values is being used for
// getting hyperbolic cosine function's values.
console.log(Math.acosh(2));
console.log(Math.acosh(1));
console.log(Math.acosh(3));
console.log(Math.acosh(10));

chevron_right


Output:

> 1.3169578969248166
> 0
> 1.7627471740390859
> 2.993222846126381

Errors and Exceptions:

  1. It is an error case because complex number can not be taken as the parameter of the function only integer value can be taken as the parameter.
    filter_none

    edit
    close

    play_arrow

    link
    brightness_4
    code

    // complex number can not be calculated as
    // the hyperbolic arc-cosine.
    console.log(Math.acosh(1 + 2i));

    chevron_right

    
    

    Output:

    Error: Invalid or unexpected token
  2. Other than integer nothing is accepted as the parameter of the function that is why here string as the parameter gives NaN i.e, not a number.
    filter_none

    edit
    close

    play_arrow

    link
    brightness_4
    code

    // Any string value as the parameter of the
    // function gives NaN i.e, not a number
    // because only number can be used as the
    // parameters.
    console.log(Math.acosh("geeksforgeeks"));
    console.log(Math.acosh("gfg"));

    chevron_right

    
    

    Output:

    > NaN
    > NaN
    

Application:

  • Whenever we need to get a get hyperbolic arc-cosine of a number that time we can take help of Math.acosh() function in JavaScript.
    filter_none

    edit
    close

    play_arrow

    link
    brightness_4
    code

    // Here different values is being used for getting
    // hyperbolic cosine function's values.
    console.log(Math.acosh(5));
    console.log(Math.acosh(12));

    chevron_right

    
    

    Output:

    > 2.2924316695611777
    > 3.176313180591656
    


My Personal Notes arrow_drop_up

Check out this Author's contributed articles.

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.