Here you can find the source of acosh(double x)
Parameter | Description |
---|---|
x | Double whose inverse hyperbolic cosine is desired. |
If x is NaN or less than one, the result is NaN.
This method is a modified version of the one in the Visual Numerics Sfun class.
public static double acosh(double x)
//package com.java2s; /* Please see the license information in the header below. */ public class Main { /** Return the inverse (arc) hyperbolic cosine of a double. *//from www .jav a 2s . c om * @param x Double whose inverse hyperbolic cosine is desired. * * @return The inverse hyperbolic cosine of x. * * <p> * If x is NaN or less than one, the result is NaN. * </p> * * <p> * This method is a modified version of the one in the * Visual Numerics Sfun class. * </p> */ public static double acosh(double x) { double ans; if (Double.isNaN(x) || (x < 1)) { ans = Double.NaN; } // 94906265.62 = 1.0/Math.sqrt(EPSILON_SMALL) else if (x < 94906265.62) { ans = safeLog(x + Math.sqrt(x * x - 1.0D)); } else { ans = 0.69314718055994530941723212145818D + safeLog(x); } return ans; } /** Return natural log of a double. * * @param x The number whose natural log is desired. * * @return The natural log of x. If x is zero, * returns 0. */ public static double safeLog(double x) { if (x == 0.0D) { return 0.0D; } else { return Math.log(x); } } }