Skip to content
Related Articles

Related Articles

Improve Article
Save Article
Like Article

JavaScript Math acosh() Method

  • Last Updated : 07 Jul, 2020

Below is the example of the Math acosh( ) Method.

Hey geek! The constant emerging technologies in the world of web development always keeps the excitement for this subject through the roof. But before you tackle the big projects, we suggest you start by learning the basics. Kickstart your web development journey by learning JS concepts with our JavaScript Course. Now at it's lowest price ever!

  • Example:




    <script>
        // Here different values is being used for
        // getting hyperbolic cosine method's values.
        document.write(Math.acosh(2)+"<br>");
        document.write(Math.acosh(1)+"<br>");
        document.write(Math.acosh(3)+"<br>");
        document.write(Math.acosh(10));
    </script>
  • Output:
    1.3169578969248166
    0
    1.7627471740390859
    2.993222846126381
    

The Math.acosh() method 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 method 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: This method accepts a single parameter as mentioned above and described below:

  • x: 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.

    Below examples illustrate the Math acosh( ) method in JavaScript.

    • Example 1: Here output 0 is the hyperbolic arc-cosine of a number 1.
      Input: Math.acosh(1)
      Output: 0
    • Example 2:
      Input: Math.acosh(2)
      Output: 1.3169578969248166
    • Example 3:
      Input: Math.acosh(3)
      Output: 1.7627471740390859

    More example codes for the above method are as follows:
    Program 1: It is an error case because complex number can not be taken as the parameter of the method only integer value can be taken as the parameter.




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

    Output:

    Error: Invalid or unexpected token

    program 2: Other than integer nothing is accepted as the parameter of the method that is why here string as the parameter gives NaN i.e, not a number.




    <script>
       // Any string value as the parameter of the
       // method gives NaN i.e, not a number
       // because only number can be used as the
       // parameters.
       document.write(Math.acosh("geeksforgeeks")+"<br>");
       document.write(Math.acosh("gfg"));
    </script>

    Output:

    NaN
    NaN
    

    Program 3:v>Whenever we need to get a get hyperbolic arc-cosine of a number that time we can take help of Math.acosh() method in JavaScript.




    <script>
        // Here different values is being used for getting
        // hyperbolic cosine method's values.
        document.write(Math.acosh(5)+"<br>");
        document.write(Math.acosh(12));
    </script>

    Output:

    2.2924316695611777
    3.176313180591656
    

    Supported Browsers:

    • Google Chrome 38.0
    • Internet Explorer 12.0
    • Firefox 25.0
    • Opera 8.0
    • Safari 25.0



    My Personal Notes arrow_drop_up
Recommended Articles
Page :

Start Your Coding Journey Now!