Java acosh acosh(double x)

Here you can find the source of acosh(double x)

Description

Returns the inverse (arc) hyperbolic cosine of a double.

License

Open Source License

Parameter

Parameter Description
x A double value.

Return

The arc hyperbolic cosine of x. If x is NaN or less than one, the result is NaN.

Declaration

static public double acosh(double x) 

Method Source Code

//package com.java2s;
/*/*from   ww  w .j av a2 s  . com*/
 * =========================================================================
 * Copyright (C) 1997 - 1998 by Visual Numerics, Inc. All rights reserved.
 *
 * Permission to use, copy, modify, and distribute this software is freely
 * granted by Visual Numerics, Inc., provided that the copyright notice
 * above and the following warranty disclaimer are preserved in human
 * readable form.
 *
 * Because this software is licenses free of charge, it is provided
 * "AS IS", with NO WARRANTY.  TO THE EXTENT PERMITTED BY LAW, VNI
 * DISCLAIMS ALL WARRANTIES, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
 * TO ITS PERFORMANCE, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
 * VNI WILL NOT BE LIABLE FOR ANY DAMAGES WHATSOEVER ARISING OUT OF THE USE
 * OF OR INABILITY TO USE THIS SOFTWARE, INCLUDING BUT NOT LIMITED TO DIRECT,
 * INDIRECT, SPECIAL, CONSEQUENTIAL, PUNITIVE, AND EXEMPLARY DAMAGES, EVEN
 * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
 *
 * =========================================================================
 */

public class Main {
    /**
     * Returns the inverse (arc) hyperbolic cosine of a double.
     *
     * @param x
     *            A double value.
     * @return The arc hyperbolic cosine of x. If x is NaN or less than one, the
     *         result is NaN.
     */
    static public double acosh(double x) {
        double ans;

        if (Double.isNaN(x) || x < 1) {
            ans = Double.NaN;
        } else if (x < 94906265.62) {
            // 94906265.62 = 1.0/Math.sqrt(EPSILON_SMALL)
            ans = Math.log(x + Math.sqrt(x * x - 1.0));
        } else {
            ans = 0.69314718055994530941723212145818 + Math.log(x);
        }
        return ans;
    }
}

Related

  1. acosh(double a)
  2. acosh(double x)
  3. acosh(double x)
  4. acosh(double x)